Tuesday, July 14, 2009

How to write an exponetial equation in C code/language?

i am trying to define the following funtion in C code could some please tell me the exact syntax on how to declare this


f(x) = e^(-x^2)





this is how someone told me to do it but it doesnt work


#include(math.h)


y= exp(-x,2)

How to write an exponetial equation in C code/language?
the function is





pow(base, exponent);





and you DO have to include math.h





First define e


const float e = 2.78; //proabably want to be more exact





int x;


x = 10;





pow(e, pow(x, 2)); //This caluculates e to the value of x (which is 10) squared.
Reply:exp(pow(-x,2));

artificial flowers

No comments:

Post a Comment