value of π by Gregory-Leibniz series in fortran
An infinite sum series first given by Madhava and later rediscovered by Gregory and Leibniz is expressed as,
∞∑n=0(-1)n2n+1=π4or, π4=∞∑n=0(-1)n2n+1
∴
Where n = 0,1,2,3,4,5, .................................., positive integer.
For n =0
\pi = 4 \times 1
For n = 0,1
\pi = 4 \times (1- \frac{1}{3})
For n = 0,1,2
\pi = 4 \times (1 - \frac{1}{3} + \frac{1}{5})
For n = 0,1,2,3
\pi = 4 \times (1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7}) and so on.
Continuiing this process up to n \approx \infty, you obviously get,
\pi =4 \times ( 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \frac{1}{11} + ....................) (2)
This is called Gregory-Leibniz series to estimate value of \pi.
fig. 1. n vs. \pi plot
n gives number of terms in the series.
To get fortran code for estimation of value of \pi by using Gregory-Liebniz series, click on the given button : Get Files
Learn to create gif animation in gnuplot software: Click Here.
Comments
Post a Comment