exp(x) = 1 + x + x^2 / 2! + x^3 / 3! + x^4 / 4! + … + x^n / n!

float Exp(float x) {

float result = 0.f;

for(int i = 0; i < n; ++i) {

float a = pow(x, i);

float b = i * (i-1) * (i-2) * … * 1;

result += a/b;

}

return result;

}

Advertisements