Aritmetics Functions

Good day for everybody.

I want to create one page when stay all aritmetics functions we can to use in ARDUINO. But in special the functions for a RNA Back Propagation. There is a Function for tansig ((e^+n)-(e^-n)/(e^+n)+(e^-n)) and for logsig ((1)/(1)+(e^-n)). Tank you. Add all functions but agree too this.

http://www.cplusplus.com/reference/cmath/ as a start ?

this - avr-libc: <math.h>: Mathematics - ?

There is a Function for tansig ((e^+n)-(e^-n)/(e^+n)+(e^-n)) and for logsig ((1)/(1)+(e^-n)).

did not test them for equality, but the 2nd is slightly faster (1 exp() call less)

float tansig(float n)
{
  float a = exp(n);
  float b - exp(-n);
  return (a-b) / (a+b);
}

float tansig(float n)
{
  return 2.0/(1.0+exp(2*-n)) -1.0;
}

float logsig(float n)
{
  return 1.0/ (1.0 + exp(-n));
}

by the way - ((e^+n)-(e^-n)/(e^+n)+(e^-n)) - ==> tanh() can be directly used in Arduino...

Yes ass a start.. tank u for the link is great. But if this is here in the forum it´d best. Tank you

I use tansig in neural network models, it can be a slow function to compute, you might want to consider alternative ways of calculating it which will be faster on the arduino.

see other sigmoids here - Saturation Function for Sliding Mode Control - Project Guidance - Arduino Forum -

a simple way to optimize the tansig is to shortcut the extremes, but beware that if the function is not called with 'extremes' it is just overhead.

float tansig(float n)
{
  return 2.0/(1.0+exp(2*-n)) -1.0;
}

==> 

float tansig(float n)
{
  if (n < -10) return -1
  if (n > 10) return 1
  return 2.0/(1.0+exp(2*-n)) -1.0;
}

interpolating lookup tables might also be an option - Arduino Playground - MultiMap -