Equation in Taylor series to show each iteration?

1 view (last 30 days)
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.

Accepted Answer

Geoff Hayes
Geoff Hayes on 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!

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!