Equation in Taylor series to show each iteration?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nick Haufler
am 10 Okt. 2015
Beantwortet: Geoff Hayes
am 10 Okt. 2015
In the attached document, how to I get the difference to display in my outputs. My equation in the taylor series is in the while loop in the variable 'Equation'. Also right now when I run my code it just keeps going continuously and never stops. I don't get any outputs, I'll attach my code for you to look at.
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 10 Okt. 2015
Nick - you may want to review the pdf with your professor since the example showing the differences are not true for the case where x is 1.5. Looking at your code, the important line is that which computes the next estimate
Estimate=(-1)^(count)*(x-1)*((count+1)/(count+1));
Note how you are multiplying the (x-1) by ((count+1)/(count+1));. There are two problems here - the first is that ((count+1)/(count+1)) will always evaluate to one, and the second is that your code is multiplying rather than using an exponent and dividing. Remember that the kth term of your Taylor series is
(-1)^(k+1) * ((x - 1)^k)/k
for k = 1,2,3,... Remember also that you are summing over the above so you need to take that in mind on each iteration (you need to sum the Estmate). Your code should then be as follows
Estimate = Estimate + (-1)^(k+1)*((x-1)^k)/k;
Try incorporating the above into your code and see what happens!
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!