Question: MATLAB Problem 4: Leibniz found that can be approximated by the following series: 2n 1 n-0 Madhava (with Leibniz) later suggested an alternative series In

MATLAB  MATLAB Problem 4: Leibniz found that can be approximated by the

Problem 4: Leibniz found that can be approximated by the following series: 2n 1 n-0 Madhava (with Leibniz) later suggested an alternative series In this exercise, you are asked to write a function testpi.m to compare how fast the two series can approximate the value of for a given tolerance. The function should have the following declaration: function api, nterm] = testpi(tol, method) where tol is the input tolerance defined as the absolute difference between the approximated and the default value of in MATLAB divided by the default value. Method is a string input being either 'Leibniz' or 'Madhava'. The function outputs are the approximated value of apl and the number of terms nterm in the series needed to compute the approximate value In the function, you may want to consider the relationship between abs(api-pi)/pi and tol as a condition to truncate n in the two series above. Give the function a description. In the following exercises, set the tolerance to 107 (a) Set p4eval('help testpi') (b,c) For the Leibniz series, what is the approximated value of and how many terms of the series are needed to compute that value? Put the answers in p4b and p4c, respectively (d,e) For the Madhava series, what is the approximated value of and how many terms of the series are needed to compute that value? Put the answers in p4d and p4e, respectively (f) Which method converges faster? Give answer in p4f-'... series converges faster

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!