How is the value of $\pi$ ( Pi ) actually calculated? When I was a child I was taught $\pi$ (Circumference/Diameter) is an irrational number  and can be approximated to $22/7$ but $= 3.(142857)(\ldots)$.    
But where does this value comes from?
In short How do I derive $\pi$?
 A: When I was a child I was taught this funny experiment:

Bring a thread of known length $l$ and wrap it as a circle. You can easily get the diameter $d$ 
  (measure it) then $\pi = \frac{l}{d}$

Repeat the experiment and you will get approximately equal values.
A: By computing the Riemann sum for approximating the integral $\int_{0}^{1}\frac{1}{1+x^2}dx$, one can get an approximative value of $\frac{\pi}{4}$.
And if we take $x_{n}$ and $y_n$ ramdonly(in an uniform way) from the interval $[0,1]$, then let $S_N = \frac{1}{N}\sum_{n=1}^N \mathbf{1}_{\{x_n^2 + y_n^2 \leq 1\}}$, $S_N$ converge to $\frac{\pi}{4}$ when $N \to \infty$
A: Generate $N$ points $(x_i,y_i)$ uniformly distributed in a unit square with vertice coordinates $(0,0),(0,1),(1,1),(1,0)$. Count the number of points satisfying $x_i^2+y_i^2\leq1$, denoted by $n$. Then pi can be approximately computed by
$$\frac\pi4\approx\frac nN\quad\text{for large $n$}$$
A: There are thousands way to calculate $\pi$, probably because it's one of the most important, if not the most important constant in the maths world.
The one of the most robust ways to caclulate is to measure the circle's diameter and then $\pi = \frac{\text{circumference}}{\text{diameter}}$. Also you can calculate the area of the circle and then use $A = r^2\pi$. The same works with a sphere.
But this methods will only give an approximate value, that accurate to 5-10 decimal places. If you want an exact value the best option is to use calculus. You can use what Archimedes have done. Inscribe and circumscribe a polygon into a circle, as the number of sides rises, the area of the circle will be sandwiched between the areas of the two polygons. If you take "infinit-gon" then you'll get the exact values.
Now when we are in computer world, most of the values for $\pi$ are calculated using infinite sum. To arrive at them you need to use trigonometry and of course calculus. The most infinite sums related to $\pi$ are Basel Problem, Leibniz formula, Viete formula.
Also one of the most "easy" method is to randomly place a huge amount of points, let's say 100 000 on a $1\times1$ square and then to find how many of the point will be withing the circle of a radius $1$. With computer this shouldn't be too difficult. Increasing the number of points and number of trials will get even better approximations.
A: Two of the fastest algorithms are the Brent-Salamin algorithm based on the work of Gauss and Legendre, and the Chudnovsky algorithm based on a variant of one of Ramanujan's formulae. There are also interesting algorithms such as the Bailey-Borwein-Plouffe formula that can calculate specific digits of π efficiently without calculating any other digits! You can also find much more on Wikipedia.
A: There is the famous formula 
$$\dfrac{\pi}{4} = 1 - \dfrac{1}{3} + \dfrac{1}{5} - \dfrac{1}{7} \pm \cdots.$$
Unfortunately, this converges rather slowly.  (If you compute to $n$ terms and multiply by $4$, 
you get within roughly $1/n$ of the value of $\pi$; so to get 3 decimal places of accuracy, you'll need to sum something like the first thousand terms of the series.) 
There is the Machin formula
$$\dfrac{\pi}{4} = 4\arctan \dfrac{1}{5} - \arctan \dfrac{1}{239},$$
which can be combined with an infinite series formula for $\arctan$
to provide a much more rapidly convergent infinite series which can be used to compute
$\pi$ to many digits of accuracy.  
The Wikipedia entry provides more details about these and other methods, both historical and contemporary, for computing $\pi$.
A: If by derive you mean calculate programmatically, you can do it in numerous ways. You can iterate over the x^2 + y^2 = r^2 values, using distance formula to sum each small distance, to get pi as the multiple of the diameter.
There are other better approximations - Yacas book of algorithms suggests 4 other methods to find it.
A: $$\pi \;\approx\; 180 \cdot \frac{\sin 10^{-n}}{10^{-n}}$$
where $n$ is a positive real number.
The greater the value of $n$ the more exact 
the value of π becomes.
