-4

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

abelenky
  • 58,532
  • 22
  • 99
  • 149
Shay
  • 19
  • 5

1 Answers1

1
#include <math.h>
double f(double x)
{
    return x - exp(-(x*x));
}
Jive Dadson
  • 15,176
  • 9
  • 47
  • 65