# exp(-x) problem....three algorithms

Discussion in 'C' started by dolby home, Mar 9, 2013.

1. ### dolby homeNew Member

Joined:
Mar 9, 2013
Messages:
1
0
Trophy Points:
0
hiiiii c fanatics!!! i have a problem over here. i did for nearly everything but then i got stuck.. please help me. . i think that the point of this problem is to show that errors are here for every variable (float and double becouse of their size) and not to eliminate them. so here it is: :p

Apply three different algorithms in calculating values of the function exp(-x) for x=0-100 in steps of 10(for 0,10,20..), and explore possible sources of error in numerical calculation of the function. Calculate separately the cases using float and double types of variables. Write the results in the form of tables.
1) apply direct expansion

exp(-x)= sum(0->oo) ((-1)^n) (x^n)/n!

2) apply recursion relation

exp(-x)=sum(0->infinity) S_n
s_n=-s_(n-1)*x/n

3) calculate exp(x) with recursion relation, and then take the inverse
exp(x)=sum(0->infinity) S_n

exp(-x)=1/exp(x)