The Math Forum

Search All of the Math Forum:


Math Forum » Discussions » Software » comp.soft-sys.matlab


Topic: Need some help with a fairly complex function, or so it seems...
Replies: 1   Last Post: May 2, 2013 3:04 PM

Advanced Search


Posts: 1
Registered: 10/11/12
Posted: Oct 11, 2012 11:19 PM


I need a bit of help with this question in the matlab book. I have it pretty much done except for those 2 starred parts...

34) Write a menu-driven program to investigate the constant pi. Model it after the program that explores the constant 'e.' Pi is the ratio of a circle's circumference to its diameter. Many mathematicians have found ways to approximate pi, For example Machin's formula is:


Leibniz found that pi can be approximated by:

This is called a sum of a series. Thre are six terms shown in this series. The first term is 4, the second term is -4/3, the third term is 4/5, and so forth. For example, the menu-driven program might have the following options:

*Print the approximation using Leibniz' formula, allowing the user to specify how many terms to use.
*Print the approximation using Leibniz' formula, looping until a 'good' approximation is found.

Here's what I have so far:
%This function 'leibform' is part of the script 'invpi' that investigates the constant
%'pi' using a menu driven program. Here the approximation of the formula
%will be printed, where user may specify how many terms to use.
numterms=input('Please enter number of terms you wish to use: ');

for i=1:numterms
for i=1:numterms-1

Any help in the right direction would be appreciated.




[Privacy Policy] [Terms of Use]
