#C14pi Help14pi:=proc(): print(`Leibnitz(D1), LeibnitzN(N) `):end: #Leibnitz(D1): computing Pi to D1 digits,i.e. the first time in the series where #tuncating it gives a rational number appx. of pi with error <=10^(-D1) #Pi=4*(1-1/3+1/5-1/7+...)=add(4*(-1)^i/(2*i+1) Leibnitz:=proc(D1) local su,i: su:=0: for i from 0 while 4/(2*i+1)>1/10^D1 do su:=su+(-1)^i*4/(2*i+1): od: su: end: #LeibnitzN(N): using N terms in the Lebnitz formula to appx. Pi LeibnitzN:=proc(N) local i: evalf(add((-1)^i*4/(2*i+1),i=0..N)): end: