MATLAB SUMMATION HELP Please????

1 Ansicht (letzte 30 Tage)
nick pa
nick pa am 21 Jul. 2014
Beantwortet: Roger Stafford am 22 Jul. 2014
So i need to know how i can do this summation? ik its a for loop but when i ran it all i got was zeros.
e^x=(1+x/1!+x^2/2!+x^3/3!+⋯,)-50<x<50 Eq (1)
e^'x=A*(1+x/1!+x^2/2!+x^3/3!+⋯),-50<x<50 Eq (2)
For the above equations build a vector named X from -50 to 50 in increment of 0.5. Then calculate the values of ex and e’x. Plot the values of these two functions with the following formats:
I got the vector built, but am stuck
  1 Kommentar
James Tursa
James Tursa am 22 Jul. 2014
Please post your code so far and we can comment on it and offer suggestions.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Roger Stafford
Roger Stafford am 22 Jul. 2014
I notice on your other thread at Answers #142842 you have written:
n = 0:201
x = [-50:0.5:50]
xs = sum((x.^n./factorial(n))
As you may have already seen, this will give you trouble because for both ends of that x-range, the value of both x^201 and 201! will be extremely large and overflow to infinity, thereby producing a NaN in taking their ratio.
The way around this is to use a for-loop which runs through the series backwards. You start with 1. On the first trip you compute 1+x/201*1. On the second trip you get 1+x/200*(1+x/201*1). On the third trip you get
1+x/199*(1+x/200*(1+x/201*1))
And so forth. I think you can see the pattern here. At each step there is first a multiplication of the previous value times x, then a division by an integer that is successively 201, 200, 199, etc., and finally 1 is added. If you follow this method, your computed value of ex will be extremely close to the ideal exp(x) for numbers as extreme as 50 and -50.
You face one additional difficulty. In making a plot, you will find that for the plot to be scaled to fit values for ex with x = 50 on the plot, smaller values of x will give much smaller values for ex and the plot line will look as if those values are all zeros.
I haven't understood the significance of your second equation (2). What is 'A'?

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by