I am trying to translate f(x) = x − e-(x2) in c++ source code but I keep getting errors. I have tried :
double f(double x)
{
exp = pow(-x, 2);
double result = x - exp;
return x;
};
Any insight? If it helps, I am using Code::Blocks
#include <math.h>
double f(double x)
{
return x - exp(-(x*x));
}