Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the Taylor series expansion: As a concrete example, choose x = 0.85. so

ID: 3693494 • Letter: C

Question

Consider the Taylor series expansion: As a concrete example, choose x = 0.85. so that ln(0.15)=-sigma^infinity_k=1 (0.85)^k/k The series can be evaluated by the recursion: S_k=S_k-1 -(0.85)^k/k, k=1,2,3,--- and initialized at S_0 = 0. Using a forever while-loop, determine the number of iterations A: needed for S_k to get close to the limiting value A=ln(0.15) to within a distance of 10^-12. Determine the accuracy of the calculated value S of the series by computing the difference |S-A|. Repeat using a conventional while-loop. Write your code and numerical results in the spacc below.

Explanation / Answer

The code is as follows


a) using forever while loop

g=true
k=0
s=0
p=0.15
limit = 10^-12
A=ln(0.15)

while g

k=k+1
s=s - ((0.15)^k)/k

if (s-A) < limit
g = false

end
end

acc = abs(s-A)

Disp("Number of iterations needed:")
Disp(k)

Disp("Accuracy of calculation:")
Disp(acc)


b) Using conventional while loop:

k=0
s=0
p=0.15
limit = 10^-12
A=ln(0.15)

while (s-A) > limit

k=k+1
s=s - ((0.15)^k)/k


end

acc = abs(s-A)

Disp("Number of iterations needed:")
Disp(k)

Disp("Accuracy of calculation:")
Disp(acc)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote