The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 1
Registered: 10/11/12
Need some help with a fairly complex function, or so it seems...
Posted: Oct 11, 2012 11:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.