Question: Whats wrong with my code? the series limit to four decimal places is 0.4567. Your program should compute the approximation in two ways: formula. computed

 Whats wrong with my code? the series limit to four decimal

places is 0.4567. Your program should compute the approximation in two ways:formula. computed term should be a scalar value. Do not use elementWhats wrong with my code?

the series limit to four decimal places is 0.4567. Your program should compute the approximation in two ways: formula. computed term should be a scalar value. Do not use element by element operations or MATLAB's sum function. 4. Test your program for N=1,N=10, and N=100 on your own MATLAB installation. n=50 % define true limit of the series for k=5 lim=.4567; \%2. Do the magic - calculate the required outputs \%1. element by element method to approximate sum \%define a vector starting form 1 to n that contains n terms nArray =[1:1:n]; \%calculate the sum using element by element operation with the nArray elementSum =sum(1./( nArray ( Array +5))); \%2. using for loop to approximate sum, assign the result to forsum forsum = 0 ; for a=1:n forsum = forSum +1/(a(a+5)); end \%3. Calculate the the percent errors between your two approximations and the limit of the series respectively. \% Subtract the limit from your calculated approximation and divide the result by the limit and it multiply it with 100 \%calculate the percent error for element-by-element approximation diffel =abs(( elementSum 1lm)/lim)100; \%Calculate the percent error for the loop approximation difffor = abs (( forsum 1lm)/lim)100; \%3. displaying results and accuracy fprintf(' Using element by element operations, the approximation of the series is \%f for n=%f. The percent error is \%f \%\% fprintf('Using for loop operations, the approximation of the series is %f for n=%d. \ ThTe percent error is %f%%, forSum, n, di Previous Assessment: 2 of 5 Tests Passed (40%) Is nArray correct? Is elementSum correct? Is for Sum using for loop correct? Variable forSum has an incorrect value. Use a for loop to calculate forSum Is diffEl correct? Variable diffEl has an incorrect value. Is diffFor correct? Variable diffFor has an incorrect value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!