필터 지우기
필터 지우기

Equation in Taylor series to show each iteration?

조회 수: 2 (최근 30일)
Nick Haufler
Nick Haufler 2015년 10월 10일
답변: Geoff Hayes 2015년 10월 10일
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.

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 10월 10일
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개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by