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: 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=; 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.