Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or 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

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

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

Hello,

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:

pi/4=4arctan(1/5)-arctan(1/239)

Leibniz found that pi can be approximated by:
pi=(4/1)-(4/3)+(4/5)-(4/7)+(4/9)-(4/11)+...

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.
pinumers=[];
pidenoms=[1];
numterms=input('Please enter number of terms you wish to use: ');

for i=1:numterms
pinumers(end+1)=4
end
for i=1:numterms-1
pidenoms(end+1)=
end


Any help in the right direction would be appreciated.

Thanks,

Hady



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.