Successfully reported this slideshow.
Your SlideShare is downloading. ×

Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 1 Ad

Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

Download to read offline

Hello,
using matlab, how do I approximate this sum? I
Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation
Solution
s=[];
s(1)= sqrt(12);
s(2)=s(1)+sqrt(-3);
n=3;
while abs(s(n-1)-s(n-2))>1e-6
s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2));
n=n+1;
end
s(n-1)
.

Hello,
using matlab, how do I approximate this sum? I
Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation
Solution
s=[];
s(1)= sqrt(12);
s(2)=s(1)+sqrt(-3);
n=3;
while abs(s(n-1)-s(n-2))>1e-6
s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2));
n=n+1;
end
s(n-1)
.

Advertisement
Advertisement

More Related Content

More from rtodd588 (20)

Recently uploaded (20)

Advertisement

Hello- using matlab- how do I approximate this sum- I Use While loop w.docx

  1. 1. Hello, using matlab, how do I approximate this sum? I Use While loop write a script in MATLAB to calculate the approximate value of With the desired of accuracy within 10^6. Prefer to the example on lecture 7 slides (using for a loop) Hint: Write the While loop based on the following Pseudocode: 1st: Define s(1) and s(2) (1 and 2rd partial sums) 2nd: Start with element n=3 of list (n is which element comes next) 3rd: Loop s(n)=s(n-1)+next term n=n+1 REPEAT LOOP WHILE |s(n-1) - s(n2)| > 10^-6 4th: Display output appropriate explanation Solution s=[]; s(1)= sqrt(12); s(2)=s(1)+sqrt(-3); n=3; while abs(s(n-1)-s(n-2))>1e-6 s(n)=s(n-1)+sqrt(12.*(((-1).^n)./n.^2)); n=n+1; end s(n-1)

×