Equation in Taylor series to show each iteration?

1 vue (au cours des 30 derniers jours)
Nick Haufler
Nick Haufler le 10 Oct 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.

Réponse acceptée

Geoff Hayes
Geoff Hayes le 10 Oct 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!

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by