Question

In this problem you will utilize a for loop to compute the an approximation of the value of using the Leibnizs formula for P Please complete using matlab
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans:-

Code:-

%number of iteration i
i = 5;
%from n = 0 to 5
n = 0:i;
%each terms whose sum is approx of pi
S = 4.*((-1).^n)./(2.*n.+1);
%first approx equal to first term of sum
A(1) = S(1);
%rest of approximation equal to sum of previous approximation and next term
for j = 2:5%loop for next approximations
A(j) = A(j-1)+S(j);%sum of previous approx and next term
end
%find the difference
diff = abs(A.-pi)./((A.+pi)./2) .*100;
disp(diff);%display the difference %

lebiniz. mx number of iteration i 2 i = 5; 3 from n = 0 to 5 4 n = 0:i; Peach terms whose sum is approx of pi 6 S = 4.*((-1).

Output:-

>> lebiniz 24.0397 16.3535 9.8384 8.1617 6.1127

If any doubt, ask in comments.

Please appreciate the work by giving a thumbs up.

Stay safe and keep Chegging.

Add a comment
Know the answer?
Add Answer to:
Please complete using matlab In this problem you will utilize a for loop to compute the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS....

    MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS. THE PROGRAM TO BE MODIFIED IS THE NEXT ONE: clc clear % Approximate the value of e ^ x using the Taylor Series x = input( 'Enter the value of x for e^x. x = ' ); t = input( 'Enter the amount of desired terms. t = ' ); i = 1; e_taylor = 0; % initializing the variable for the accumulator while...

  • THIS IS USING MATLAB 1. The value of a can be approximated by: a. Write a...

    THIS IS USING MATLAB 1. The value of a can be approximated by: a. Write a script which asks the user to input the number of iterations (n), then computes the expression, using a for loop to compute the summation with the specified number of iterations. The larger the number of iterations, the closer the result should be to it. Print out the value of n, and the result using fprintf with 8 digits after the decimal to see the...

  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

  • Please code in MatLab or Octave Output should match Sample Output in Second Picture Thank you...

    Please code in MatLab or Octave Output should match Sample Output in Second Picture Thank you 5. In this problem we will investigate using the Secant Method to approximate a root of a function f(r). The Secant Method is an iterative approach that begins with initial guesses , and r2. Then, for n > 3, the Secant Method generates approximations of a root of f(z) as In-1-In-2 n=En-1-f (x,-1) f(Fn-1)-f(-2) any iteration, the absolute error in the approximation can be...

  • Calculation of the value of pi: The Nilakantha Series was developed in the 15th century as...

    Calculation of the value of pi: The Nilakantha Series was developed in the 15th century as a way to calculate the value of pi: pi = 3 + 4/(2*3*4) -4/(4*5*6) + 4/(6*7*8) -4/(8*9*10)+... . Use a for loop to approximate pi using this technique (5 points). Continue the calculations until the absolute value of the difference between the value of pi stored in MATLAB and the approximation is less than 0.001. Report the appproximation and the number of iterations required...

  • clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold...

    clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold = 0.5; % this is the initial guess test = 1; % this simply ensures we have a test value to enter the loop below. %If we don't preallocate this, MATLAB will error when it trys to start the %while loop below k = 1; %this is the iteration counter. Similar to "test" we need to preallocate it %to allow the while loop to...

  • in matlab Using the polynomial entered and the starting guess , compute the root of the...

    in matlab Using the polynomial entered and the starting guess , compute the root of the polynomial using the Newton-Raphson method. Repeat the method until the percent error between the most recent two iterations is less than the percent error entered by the user . Determine the percent error of the most recent two iterations using the formula. Output the final value of the root found with the Newton-Raphson method and the number of iterations the method took to converge...

  • Complete using MatLab 1. Consider the following initial value problem 3t2-y, y(0) = 1 Using Euler's...

    Complete using MatLab 1. Consider the following initial value problem 3t2-y, y(0) = 1 Using Euler's Method and the second order Runge-Kutta method, for t E [0, 1] with a step size of h 0.05, approximate the solution to the initial value problem. Plot the true solution and the approximate solutions on the same figure. Be sure to label your axis and include an a. appropriate legend b. Verify that the analytic solution to the differential equation is given by...

  • Submission Items: (1) A Word document in which you: a. Describe in brief the problem you...

    Submission Items: (1) A Word document in which you: a. Describe in brief the problem you are solving and the numerical method used. b. Snapshot of the output, when you run the program for the conditions mentioned in the questions. c. Discuss your results. (2) MATLAB code (m) file() Question 1: [10 points) Write a MATLAB function that calculates the approximate value of arctan(x) using the Maclaurin series approximation: arctan(x) = x- + +... The function should accept 3 parameters:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT