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.softsys.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



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


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 menudriven 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 menudriven 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:numterms1 pidenoms(end+1)= end
Any help in the right direction would be appreciated.
Thanks,
Hady



