Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions