User:Mogi Beans/sandbox

Naked Math

 * $$ y = r^n $$


 * $$ n = {\ln y \over \ln r } $$


 * $$ r = e^ {\ln y \over n } $$


 * $$ f = { L_m \over r } + 1 $$


 * $$ f = { L_m \over C_r } + 1 $$


 * $$ C_r = { L_m \over f-1 } $$


 * $$ L_m = r(f-1) $$


 * $$ L_m = C_r(f-1) $$


 * $$ stop = f \, C_r $$


 * $$ f = { stop \over C_r } $$


 * $$ stop = C_r + L_m $$


 * $$ r = {L_m \over (f-1) } $$

Where


 * $$ y $$ = compounded yield


 * $$ r $$ = monthly return


 * $$ n $$ = number of months


 * $$ f $$ = multiplication factor for stop


 * $$ C_r $$ = credit received from option sales


 * $$ L_m $$ = maximum loss if all stops hit

Magic Squares
A magic square is one of those interesting constructs of numbers arranged in a square, where each row, column, and diagonal add up to the same number. We've all seen them before, but how could anyone ever create such a thing? There must be millions of ways to arrange numbers in a square, and to try them all to find which ones work would take hundreds of years. What kind of crazed super genius madman could or would do such a thing? Obviously no one. The magic square must be one of those things that someone just stumbled upon one day, the way you would stumble upon a crashed alien spaceship while hiking through the woods. It's something that was found by accident, not by intention. At least that's what I thought the first time I saw one in the fifth grade.

That's not really the case however, and in just a few minutes we are going to make one. We won't need hundreds of years of trial and error, or super genius math skills, nor will any alien involvement be required. In fact, by using a bit of analysis, we are going to make the magic square create itself, just like magic.

Ours will be a 3 by 3 magic square, that is 3 rows of 3 columns, where each row, each column, and each diagonal add up to 15. We will use only the numbers 1 through 9, and no number can be used more than once. Something like this:


 * $$ \begin{matrix}

1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} $$

First off, I'll tell you that there are not millions of combinations possible with these nine numbers, but only 362,880. And there is not just one possible arrangement that will work, there are eight. Still, to try to guess one of the 8 out of 362,880 possibilities is absurd, so we won't. Let's do a bit of analysis.

We will need a group of three numbers that add up to 15. We will need one such group for each of the three rows, one for each of the three columns, and one for each of the two diagonals, for a total of 8 groups of three numbers. Let's see what kind of groups we can make using the numbers 1 through 9. Just to make it easy to keep track, I'll do it sequentially starting with 1.

We can't make a group starting with 1 and containing the number 2, because 1+2 = 3, and we would need a 12 to add up to 15. The first group we can make is (1 5 9). Those three add up to 15. Notice that we can rearrange those three numbers a total of six different ways and they still add up to 15.... ex. (5 1 9) or (9 1 5). However, each of those permutations still contain the same group of three numbers, so they only count as one group. We may end up using one of the permutations in the square, and likely will, but for our purposes we just need to count the groups. Next up we find (1 6 8). After that is (1 7 7), but since we can't use the same number twice this one doesn't count.

Moving on and starting with two we have (2 4 9), (2 5 8), and (2 6 7). You can easily go through and find these yourself, as we are just adding numbers, but I'll go ahead and list them out.

1. (1 5 9) 2. (1 6 8) 3. (2 4 9) 4. (2 5 8) 5. (2 6 7) 6. (3 4 8) 7. (3 5 7) 8. (4 5 6)

That's all the groups we can make out of the numbers 1 through 9. You may ask, what about groups starting with 5,6,7,8 or 9, such as (6 1 8)? Look closely and you will see that is just a permutation of group 2. In fact, the commutative law tells us that any group starting with a number greater than 4 will be a permutation of one of the previous groups. Try it and you'll see. So we needn't look any further.

As we saw earlier, our square will require 8 groups, which magically is exactly how many groups we have. And with six permutations for each one, we have a total of 48 sets of numbers available for our square. But let's not start guessing which ones to use just yet, let's look a little closer. Here is our square, currently filled with letters.


 * $$ \begin{matrix}

a & b & c \\ d & e & f \\ g & h & i \end{matrix} $$

Whatever number we decide to put in the top left corner will be in the top row group (a b c). Notice it will also need to be in the first column group (a d g), and diagonal group (a e i). Number "a" will need to be in three of our eight groups, as will the numbers we choose for each of the other three corners. The top center spot "b" will need to be in both the top row group, and the center column group. Likewise the numbers for d, f, and h will need to be in two groups. The center position "e" must be in the groups for the middle row, center column, and both diagonals, for a total of four groups. Let's go back and see how many groups each of our nine numbers are in.

Number 1 is only in the first two groups. Number 2 is in the next three groups. You may look and add them up. I'll list them all out here.

1 two groups 2 three groups 3 two 4 three 5 four groups 6 three 7 two 8 three 9 two

Our analysis showed that whatever number we put in the center position must be in four of our groups. And the only number that is in four of our groups is 5. Therefore, 5 has to be in the center of our square!


 * $$ \begin{matrix}

a & b & c \\ d & 5 & f \\ g & h & i \end{matrix} $$

We now have our first number. Now let's take a look at the top left corner. Remember, whatever number we put in the corner must be in three of our groups. The numbers we have that are in three of our groups are [2 4 6 8]. But which is the correct one? Since a square is symmetrical we can start with any of the four numbers in any of the corners. The end result will all be the same pattern of numbers, either rotated or a mirror image of each other. Let's again be systematic and just start with 2 in the top left.


 * $$ \begin{matrix}

2 & b & c \\ d & 5 & f \\ g & h & i \end{matrix} $$

We now have two numbers in the diagonal. 2 + 5 = 7. And 15-7 = 8, which means 8 must go in the bottom right corner. And of course, 8 is in the list of four numbers that must be in a corner.


 * $$ \begin{matrix}

2 & b & c \\ d & 5 & f \\ g & h & 8 \end{matrix} $$

Our first diagonal is complete. Let's continue with the corners. The only two numbers we have left are 4 and 6. Again, it doesn't matter which one we put in which corner. Let's stick the 4 in the top right and see what happens.


 * $$ \begin{matrix}

2 & b & 4 \\ d & 5 & f \\ g & h & 8 \end{matrix} $$

We see that this diagonal now contains 4 + 5 = 9, which requires a 6 in the other corner to make it add up to 15. Good, since that's the only corner number we have left.


 * $$ \begin{matrix}

2 & b & 4 \\ d & 5 & f \\ 6 & h & 8 \end{matrix} $$

Now, with both diagonals complete, there is only one empty space on each of the four sides, and only one number that will fit in each spot that adds up to 15. The only numbers we have left are [1 3 7 9] and it's easy to see where they must go. 9 on top, 1 on the bottom, 7 on the left, and 3 on the right.


 * $$ \begin{matrix}

2 & 9 & 4 \\ 7 & 5 & 3 \\ 6 & 1 & 8 \end{matrix} $$

And there we have our magic square. Each number used only once, and all rows, columns and diagonals add up to 15. Check and see. You can even look and see that each of the sets of numbers are a permutation of one of our eight groups. The top row is a permutation of group 3, the middle row a permutation of group 7, and so on. And we didn't have to make a single guess to see if something would work. True, we did have a couple of choices, but each of those would have still worked. For example, had we put the 6 in the top right corner instead of the 4, we would have gotten


 * $$ \begin{matrix}

2 & 7 & 6 \\ 9 & 5 & 1 \\ 4 & 3 & 8 \end{matrix} $$

which is a sort of flipped and rotated version of what we had. Likewise, we could have started with any of the four even numbers from our list in the upper left corner. All would have worked and given a different orientation to the finished square. With four possible starting corners, each with two possible adjacent corner choices, we end up with eight possible squares that would all work.

No aliens required. Ha! I love it.

Compound Interest with Periodic Deposits

 * $$ V_f = V_c (1+r)^n + d \sum_{i=1}^n (1+r)^i $$


 * $$ V_f = V_c (1+r)^n + d \frac {(1+r)^{n+1} - (1+r) }{ r } $$


 * $$ V_f = 10,000 (1.025)^{60} + 500 \frac {(1.025)^{61} - (1.025) }{ 0.025 } $$


 * $$ V_f = 43,997.90 + 69,695.60  $$


 * $$ V_f = 113,693.50 $$

Where
 * $$ V_f $$ = future account value
 * $$ V_c $$ = current account value
 * $$ r $$ = average monthly rate of return
 * $$ n $$ = number of monthly compounding periods
 * $$ d $$ = amount of monthly deposits


 * $$ NaClH_2O $$


 * $$ NaClH_2O \ Only $$

Newtons Method
Here is a very handy technique to have in our bag of tricks for solving those pesky non-formulaic math problems that always keep popping up. You know the ones I mean, those that have no formula and must be solved by "trial and error" or an algorithm of sorts.

For example, suppose we want to find the square root of 5. There is no math formula for finding square roots, but we know 2 squared is 4, and 3 squared is 9, so the square root of 5 must be somewhere in between 2 and 3. So we pick a number in between, square it, see if it is high or low, make a correction, then do it again. It may take 4 or 5 corrections to get it accurate to a single decimal place. If we want more decimal places it may take 4 or 5 more guesses for each decimal place, adding up to quite a lot of work for any significant amount of accuracy. Naturally, we want to know if there is a more efficient way than just guessing how much of a correction to make each time.

Indeed there is, and it was invented by Issac Newton (who also invented gravity) so we know it must be good. Basically it says that for any function, the optimal correction is equal to the function divided by its derivative.


 * $$ \Delta x = { f(x) \over f'(x)} $$

To see why this is so, and to see how it works, lets put it into a geometric representation where it is easier to visualize. The first thing we need to do is create a function, as the square root of 5 is not a function, but an irrational number. Let's assign it a variable to make it into an equation.


 * $$ x = \sqrt 5 $$

Now a little algebraic manipulation


 * $$ x^2 = 5 $$
 * $$ x^2 - 5 = 0 $$

We can easily see that when x is the square root of 5 our equation equals zero. Let's use that as our function,


 * $$ f(x) = x^2 - 5 $$

and when our function equals zero we know we have found the square root of 5. We can assign a variable to our function if we like,


 * $$ y = f(x) = x^2 - 5 $$

and then graph it on a standard x,y coordinate system to see what it looks like.

newton1 goes here

Being a second degree equation, the graph is a parabola. Where the line crosses the x axis is the point where y = 0 and therefore x equals the square root of 5. We see there are two such points, one positive and one negative.

newton1a

Let's zoom way in for a close look.

newton2a

We need to find the exact point where the line crosses the x axis. Suppose we pick a point on the x axis and draw a vertical line up to intersect the curve, like so.

newton2b

From there, we draw a line tangent to the curve which intersects back down to the x axis making a new point.

newton2c

From that new point on the x axis we repeat the process.

newton2d

We see that the line converges on our desired point very quickly, and in only a few iterations it will be immeasurably close. So how do we accomplish this mathematically instead of graphically? Let's take a look at one of the triangles and label the relevant parts.

newton2c2

Whenever we pick a value for X, which will be point (X,0) in the above figure, we can find the length of the vertical line, which is simply the value of our function, y = f(x). To find the length of side delta x we make use of the tangent function, which is the length of the side opposite the angle divided by the side adjacent the angle.


 * $$ \tan a = {f(x) \over \Delta x } $$

Rearranging to solve for delta x,


 * $$ \Delta x = {f(x) \over \tan a } $$

Finally we make use of a property of derivatives which tells us the derivative of a function is equal to the tangent to the function at that point. In other words,


 * $$ f'(x) = \tan a $$

and therefore


 * $$ \Delta x = {f(x) \over f'(x) } $$

which gives us the correction formula. Now this is a rather long winded explanation of a very simple process. Obviously, graphing and drawing lines are not necessary when actually using the technique. One merely picks a value for x, calculates the delta x, applies the correction to get the next x, and repeats,


 * $$ x_{i + 1} = x_i - \Delta x $$

Let's continue on using real numbers and actually find the square root of 5. Our function is


 * $$ f(x) = x^2 - 5 $$

and the derivative is


 * $$ f'(x) = 2x $$

which gives us our delta x formula


 * $$ \Delta x = {x^2 - 5 \over 2x } $$

Let's work out the first iteration in detail to show the steps. As stated earlier, we know the square root of 5 is somewhere between 2 and 3. Let's pick 2.5 as our first value of x. Now we calculate the value of the correction,


 * $$ \Delta x = {(2.5)^2 - 5 \over 2(2.5) } = 0.25 $$

Then apply the correction to get the next value for x,


 * $$ 2.5 - 0.25 = 2.25 $$

Now we repeat using the new value of 2.25 for x. Putting the results into a table

When the required correction becomes zero, we have arrived at our answer


 * $$ \sqrt{5} = 2.236068 $$

Of course, being a square root function, we know there is the negative value as well. Normally one would not use this method to find a square root, as these can easily be done by any calculator. However, that's not always the case.

Let's look at a much more interesting example from orbital mechanics. Suppose our spaceship is in geostationary orbit, having released a new weather satellite for NOAA, and now it's time to come home. We need to make a series of maneuvers to lower our altitude down to the standard deorbit altitude, from which all of our re-entries are made. Moreover, we need to arrive there at a precise time to be aligned with our landing site on Earth below, which is constantly rotating. The equation for determining the time required for the maneuver contains several parameters, one of which is unknown.


 * $$ t = \frac { \pi \left ( \sqrt{ (r_1 + x )^3 } + \sqrt{ (r_2 + x )^3 }  \right ) }  { \sqrt {2u} } $$

t is the number of seconds the maneuver will take, r1 and r2 are the initial and target altitudes, and u is the standard gravitational parameter for earth. The unknown value x represents an altitude at which a second retro-fire must take place. We must find the value for x so the time to complete our maneuver exactly matches the time required for the Earth to rotate into the proper position. Unfortunately, the variable x appears in two different non-linear terms in the numerator, and try as we may we can't algebraically rearrange the equation to solve for x. Attempts to expand the cubics only make things worse, leading to a sixth degree equation of the type


 * $$ ax^6 + bx^5 + cx^4 + \ldots $$

Trying to solve sixth degree equations is the second leading cause of insanity in mathematicians, the first of course being trying to make sense of the income tax form. Instead, we will use Newtons method. First we arrange the equation into a function of x


 * $$ f(x) = \sqrt{ (r_1 + x )^3 } + \sqrt{ (r_2 + x )^3 } - { t \sqrt {2u} \over \pi } $$

Once again, we will have found the proper value for x when the function equals zero. In order to calculate the delta x we will also need the functions derivative


 * $$ { \partial y \over \partial x } = {3 \over 2} \left ( \sqrt {r_1 + x} + \sqrt {r_2 + x} \right ) $$

giving us our delta x equation of


 * $$ \Delta x = \frac { \sqrt{ (r_1 + x )^3 } + \sqrt{ (r_2 + x )^3 } - { t \sqrt {2u} \over \pi } }  { {3 \over 2} \left ( \sqrt {r_1 + x} + \sqrt {r_2 + x} \right )  } $$

and our problem can now be easily solved. Simply pick an x, calculate the correction, apply, and repeat until delta x is zero. We won't show the actual numbers this time because some of them are pretty large, $$ u = 398,600.4418 {km^3 \over s^2 } $$ so would take up lots of room, I don't have the rest of them handy, and it's just simple algebra anyway.

In situations like these it's sometimes possible there is a different formula that will find the value directly. But if we don't know what it is, and don't feel like hunting for it, it's easier to just "Newton it". We will get the same answer either way.

Our last example comes from a function containing a constantly changing rate, which when integrated results in something called an Omega function.


 * $$ t_s = \frac { x \, e^ {\frac {\ln 10} {x} t }} { \ln 10 } $$

Notice that x is both a factor and an exponent of the same term. Again, there is no way to algebraically rearrange this to solve for x. We'll have to Newton it. First, our function in terms of x


 * $$ f(x) = \frac { x \, e^ {\frac {\ln 10} {x} t }} { \ln 10 } - t_s $$

and then its derivative


 * $$ { \partial y \over \partial x } = \frac { 10^{t \over x} }  { \ln 10 }   \left ( 1 - { \ln 10 \over x } t \right ) $$

and that's all we need to use Newton.

As we can see, problems that may be impossible to solve otherwise, can be easily solved with this technique. How cool is that! On the other hand, if this does not seem terribly useful to you, then you probably aren't really a geek.

''Disclaimer: The examples used here are not made up, but were actually encountered during everyday experience by the author. Your experience may vary.''

Brainzillas Guide to Triangles
The power of trigonometry allows us to solve many kinds of problems that simply can't be done any other way. But many people avoid trigonometry because it has a reputation of being really hard. To be sure, calculating the values of trig functions is a very tedious endeavor at best. However, in the same manner that we don't need to build our own power station in order to use electricity, we don't need to calculate trig functions in order to use them. Nowadays, with all the hard parts being done for us by calculator, spreadsheet, or even Google, we are free to concentrate on just the fun parts of trigonometry.

Solving triangles involves two steps. First, finding the correct formula for the particular situation. The formula is a simple equation that usually contains one or more trigonometric functions. Second, we must find the values for the trig functions to plug into the equation. Therein lies the difficulty.

Nowadays trig functions can be solved instantly with a calculator, leaving us a simple math problem to finish. The hardest part now is finding which formula to use for a particular situation. That's what we will learn here.

Using simple algebra and the techniques shown here, we will be able to solve any problem likely to be encountered in everyday life. We'll cover problems ranging from simple right triangles to such problems as "Given my current latitude, what direction will the sun rise on the summer solstice". We won't cover techniques for triangles on irregular curved surfaces, such as those found in differential geometry, Riemannian manifolds, or curved space-time, as those situations occur somewhat less frequently.

Pythagorean theorem


 * $$ a^2 + b^2 = c^2 $$

SOHCAHTOA


 * Sine equals Opposite over Hypotenuse
 * Cosine equals Adjacent over Hypotenuse
 * Tangent equals Opposite over Adjacent

Law of Sines


 * $$   \frac{a}{\sin A} \,=\, \frac{b}{\sin B} \,=\, \frac{c}{\sin C} \! $$


 * $$   \frac{\sin A}{a} \,=\, \frac{\sin B}{b} \,=\, \frac{\sin C}{c} \! $$

Law of Cosines


 * $$   c^2 = a^2 + b^2 - 2ab\cos C $$

Napiers Circle

Law of Sines


 * $$ \frac{\sin A}{\sin \alpha} = \frac{\sin B}{\sin \beta} = \frac{\sin C}{\sin \gamma} $$

Law of Cosines


 * $$ \cos c= \cos a \cos b + \sin a \sin b \cos C $$

Time Acceleration in Orbiter Playback
The Time Acceleration opcode used in the playback of Orbiter recordings has an optional parameter for Delay. The acceleration is exponential and increases by one order of magnitude each delay period.


 * $$ t_a = 10^ \frac {t} {d} $$

Where $$ t_a $$ is the time acceleration (playback speed), $$ t $$ is the real time in seconds, $$ d $$ is the delay period in seconds

This can be written as an exponential function for easier integration.


 * $$ t_a = e^ { \frac {t} {d} \ln 10 } $$

The amount of simulation time covered while accelerating through t seconds is found by the integral


 * $$ t_s = \int e^ {\frac {\ln 10} {d} t } dt $$

giving


 * $$ t_s = \frac { d \, e^ {\frac {\ln 10} {d} t }} { \ln 10 } + C $$

provided t is within the acceleration period.

The time to accelerate is found using


 * $$ t = \frac { d \, \ln t_a } { \ln 10 }  $$

where $$ t_a $$ cannot be greater than the value specified in the time acceleration function in orbiter.

Equation 4 can be solved for d using Newtons Method.

Use care when evaluating for $$ t_s $$. The lower bound at 0 is not 0.

Pi
With the release of the movie Life of Pi, now seems the perfect time to do an article about the number $$ \pi $$. In the movie our hero, named Pi, writes the value of $$ \pi $$ on the blackboard to about a hundred decimal places or so. We all know that $$ \pi $$ is an irrational number, which is mathspeak meaning it can't be expressed as a fraction. Mr. Spock put it more eloquently as a transcendental figure without resolution when he told the evil robot taking over the Enterprise to calculate it to the last digit. Modern supercomputers have calculated $$ \pi $$ to over a trillion decimal places. This naturally causes a head-scratching ponderance in the curious among us who must know how it is done.

Since $$ \pi $$ is defined as the ratio of the circumference of a circle to its diameter, we could simply measure a circle and calculate the value that way. There are obvious limitations to this method, that being the accuracy to which we can measure. Even if we had a perfectly round object, and some super laser measuring device from NASA that could measure down to the size of a single proton ( $2.5 m$ ) that would only give us an accuracy of 15 decimal places. So how is it possible to get to a trillion decimal places? There must be some way to calculate $$ \pi $$ by purely mathematical means without having to measure anything. Indeed, there are several methods. Let's see if we can't come up with one, it shouldn't be too hard. We will derive one using a very intuitive approach so it is easy to understand how it works.

Area of a circle
We'll begin by using the simple formula for determining the area of a circle.


 * $$ A = \pi r^2 $$

And if the radius of the circle is 1,


 * $$ A = \pi $$

the area of the circle will be exactly $$ \pi $$. So find the area of the circle and we find $$ \pi $$. But our formula for calculating the area contains $$ \pi. $$ Is there another way to find the area of a circle without using $$ \pi $$? Yes there is. Recall from calculus class (it's ok if you don't) that on the graph of a function, the area under the curve is equal to the integral of the function. Integrating the function of a unit circle will then give us its area. All we need is the equation for a circle, which we learned in high school.


 * $$ x^2 + y^2 = r^2 $$

A unit circle has a radius of 1,


 * $$ x^2 + y^2 = 1 $$

and with a little algebra we can rearrange it into an easier to graph form.


 * $$ y^2 = 1 - x^2 $$


 * $$ y = \sqrt { 1 - x^2 } $$

and in functional notation,


 * $$ f(x) = \sqrt { 1 - x^2 } $$

insert figure 1 here

When it comes to integrals the simpler the better. So to avoid having to deal with negative values of $$ x $$ and $$ y $$ we will only consider the values of $$ x $$ from 0 to 1, the shaded portion of the graph. The area of this part is exactly one forth of the circle, and therefore exactly one forth of $$ \pi $$. The equation for this integration is then


 * $$ \frac {\pi} {4} = \int_0^1 \sqrt { 1 - x^2 } \, dx $$

so then


 * $$ \pi = 4 \int_0^1 \sqrt { 1 - x^2 } \, dx $$

Evaluating the integral
This innocent looking integral will prove somewhat uncooperative to evaluate, but we can do it, as we have a big bag of tricks at our disposal. First, we will simplify it as much as possible by concentrating on just the indefinite integral. We will apply the bounds and the factor of 4 later. The indefinite integral is


 * $$ \int \sqrt { 1 - x^2 } \, dx $$

The normal process for integration is to add 1 to the exponent and divide the function by the new exponent, thus:


 * $$ \int x^n \, dx = \frac {x^{n+1}} {n+1} + C $$

where C is the constant of integration. But this method doesn't work in our case because of the radical sign. We'll have to try a different approach. Let's look in our bag and see what else we have.

With integration by substitution we replace a more complex expression, such as the terms of the radical, with a single variable,


 * $$ u = 1 - x^2 $$

and then undo the substitution afterward. But for that to work the derivative of $$ u $$, in this case $$ 2x $$ , must also be part of the function so they can cancel each other out. We don't have that here, so no luck.

Integration by parts: For this we need more than one factor in our function. Nope.

Integration by partial fractions. No fractions here. Sorry.

Integration by trig substitution. The mere mention of the word trigonometry strikes terror in the hearts of men, and the thought of combining integrals with trig functions is sheer madness. But we are madmen, and madness is what we do best. This will work perfectly.

Trig substitution
The idea is to substitute one of the variables with a trigonometric function. Then, using one of the many trigonometric identities, replace our function with one that is equivalent but easier to evaluate. Afterward we undo the substitution back to the original variable. It's not really difficult, but there are a lot of steps. We will begin by substituting


 * $$ x = \sin \theta $$

Trig review: In the expression above, $$ x $$ is a number and $$ \theta $$ is an angle, either in degrees or radians. Sin is a sine function, which is nothing more than the ratio of the lengths of two sides of a triangle. (Nothing scary about that) In English the expression translates into: x is the "ratio of lengths" of two sides of a right triangle, where the angle is theta degrees, and to be more precise, the side opposite the angle divided by the hypotenuse.

 insert Fig. 2. here

So our expression takes in a known angle, and outputs a number. To reverse the operation, i.e. take in a number and output the corresponding angle, we need an inverse function. An inverse function "undoes" the operation of a function. For example, if we square a number and then take its square root, we end up back with the original number because the two operations are inverse functions of each other. The inverse function of sin is arcsin.

Later we will need to know the value of $$ \theta $$ in terms of $$ x $$. Might as well find it now. We find it by applying the inverse function and get


 * $$ \arcsin (x) = \arcsin (\sin \theta ) $$


 * $$ \arcsin (x) = \theta $$

The arcsine function has undone the sine function on theta. This is sometimes written


 * $$ \sin^{-1} x = \theta $$

but they both mean the same thing. Now let's put our substitution for x into our integral


 * $$ \int \sqrt { 1 - x^2 } \, dx $$

and it becomes


 * $$ \int \sqrt { 1 - \sin^2 \theta } \, {\color{red} dx } $$

Notice our function is now in terms of theta, while the differential, dx, is still in terms of x. We must get this in terms of theta also. We do that by recognizing that a derivative is a ratio of differentials. So when we take the derivative of the sine function


 * $$ \frac {d} {d \theta} \sin \theta $$

we get a ratio of differentials


 * $$ \frac {dx} {d \theta} = \cos \theta $$

and by algebra


 * $$ {\color{red} dx } = {\color{blue} \cos \theta \, d \theta } $$

Now we can substitute this value for dx into our integral and we will have the differential in terms of theta.


 * $$ \int \sqrt { 1 - \sin^2 \theta } \, {\color{blue} \cos \theta \, d \theta } $$

Identities
Our integral is now a trig function containing both exponents and roots. Before we can evaluate it we need to remove those by using identities. Identities differ from equations in that an equation such as


 * $$ x = 5 $$

is true only when x equals 5. Whereas an identity such as


 * $$ 2x = x + x $$

is true for all values of x. So an identity is just a different way of saying the same thing. This is obvious when the variables are just x, but not so when they are trig functions. And sometimes a simple trig function can be identical to a more complex one, thereby allowing us to exchange a complex one for a more favorable one without changing the value of an equation.

The first identity we will use is


 * $$ \cos^2 \theta + \sin^2 \theta = 1 $$

If that looks strangely similar to the equation for a circle, it's because both are derived from the Pythagorean theorem. With a little algebraic rearrangement


 * $$ \cos^2 \theta = 1 - \sin^2 \theta $$


 * $$ \cos \theta = \sqrt { 1 - \sin^2 \theta } $$

you see we have a simple cosine function with which we can replace that entire radical expression. So lets do. Our integral


 * $$ \int \sqrt { 1 - \sin^2 \theta } \, \cos \theta \, d \theta $$

becomes


 * $$ \int \cos \theta \, \cos \theta \, d \theta $$

which is


 * $$ \int \cos^2 \theta \, d \theta $$

and we are rid of the nasty radical. But we still have an exponent to take care of. For that we will use the cosine double angle formula.


 * $$ \cos (2 \theta) = \cos^2 \theta - \sin^2 \theta $$

In reverse order it's a little easier to follow.


 * $$ \cos^2 \theta - {\color{red} \sin^2 \theta } = \cos (2 \theta) $$

Let's see if we can replace that sine term to get everything in this formula in terms of cosine. By again using our first identity and a little algebra we can get


 * $$ \cos^2 \theta + \sin^2 \theta = 1 $$


 * $$ {\color{red} \sin^2 \theta} = {\color{blue} 1 - \cos^2 \theta} $$

Lets use that to replace the sine term.


 * $$ \cos^2 \theta - ( {\color{blue} 1 - \cos^2 \theta} ) = \cos (2 \theta) $$

and a bit of algebra to arrange it how we need it


 * $$ \cos^2 \theta - 1 + \cos^2 \theta = \cos (2 \theta) $$


 * $$ 2\cos^2 \theta - 1 = \cos (2 \theta) $$


 * $$ 2\cos^2 \theta = 1 + \cos (2 \theta) $$

and finally


 * $$ \cos^2 \theta = \frac {1} {2} (1 + \cos (2 \theta)) $$

We now have a function without exponents to replace the squared cosine. Our integral


 * $$ \int \cos^2 \theta \, d \theta $$

is now


 * $$ \int \frac {1} {2} (1 + \cos (2 \theta)) \, d \theta $$

or to break into terms


 * $$ \int \frac {1} {2} + \frac { \cos (2 \theta) } {2} \, d \theta $$

It is now free of exponents and radicals and can now be evaluated.


 * $$ \int \frac {1} {2} + \frac { \cos (2 \theta) } {2} \, d \theta = {\color{blue} \frac {1} {2} \theta + \frac {1} {4} \sin (2 \theta ) + C } $$

Don't worry about what the value of C might be. When we apply the bounds it will disappear. However, our evaluation is still in terms of theta. We must change it back into terms of x.

Removing the substitutions
First let's get rid of that double sine by using the double sine identity:


 * $$ \sin (2 \theta ) = 2 \sin \theta \cos \theta $$

Plugging that into our expression


 * $$ \frac {1} {2} \theta + \frac {1} {4} \sin (2 \theta ) + C $$

gives us


 * $$ \frac {1} {2} \theta + \frac {1} {2} \sin \theta \, {\color{blue} \cos \theta } + C $$

We know what x is in terms of theta, and in terms of sine, but not in terms of cosine. So lets rid ourselves of the cosine function. As we saw above


 * $$ {\color{blue} \cos \theta} = {\color{red} \sqrt{ 1 - \sin^2 \theta }} $$

So substituting that in we get


 * $$ \frac {1} {2} \theta + \frac {1} {2} \sin \theta {\color{red} \sqrt{ 1 - \sin^2 \theta }} + C $$

and factor out the 1/2


 * $$ \frac {1} {2} \left ( \theta + \sin \theta \sqrt{ 1 - \sin^2 \theta }\; \right ) + C $$

Now we are ready to convert back into terms of x. We found way back at the beginning that


 * $$ \arcsin (x) = \theta $$

So let's put that in


 * $$ \frac {1} {2} \left ( \arcsin (x) + \sin \theta \sqrt{ 1 - \sin^2 \theta }\; \right ) + C $$

and our original substitution of


 * $$ x = \sin \theta $$

can go back in as well, replacing all the sines with x's, giving


 * $$ \frac {1} {2} \left ( \arcsin (x) + x \sqrt{ 1 - x^2 }\; \right ) + C $$

We are now back into terms of x, and our trig substitution is complete. But this was only the indefinite integral we were concentrating on. We still have to apply the bounds and the factor of 4. We might as well apply the factor now. Multiplying by 4 will give us


 * $$ 2 \left ( \arcsin (x) + x \sqrt{ 1 - x^2 }\; \right ) + C $$

Bounds
Let's now review our entire equation with all the factors and bounds, to see exactly where we are at so far.


 * $$ \pi = 4 \int_0^1 \sqrt { 1 - x^2 } \, dx = 2 \left ( {\color{blue} \arcsin (x) + x \sqrt{ 1 - x^2 }} \; \right ) \bigg |_0^1 $$

Excellent! Evaluating the bounds of the equation will change it from an expression of variables to one of actual numbers. We do this by taking the value of the expression when x equals the upper bound (1), and subtracting from it the value of the expression when x equals the lower bound (0). Again, by leaving out the factor of 2 and concentrating only on the part containing the variable x


 * $$ {\color{blue} \arcsin (x) + x \sqrt{ 1 - x^2 }} $$

and evaluating it when x equals 1, we get


 * $$ \arcsin (1) + 1 \sqrt{ 1 - 1^2 } $$

The term on the right goes to zero


 * $$ \arcsin (1) + 1 \sqrt{ 0 } $$

leaving the value at the upper bound to simply


 * $$ \arcsin (1) $$

The lower bound is evaluated when x equals zero


 * $$ \arcsin (0) + 0 \sqrt{ 1 - 0^2 } $$

and here the right term again goes to zero, leaving simply


 * $$ \arcsin (0) $$

So our formula for pi is now


 * $$ \pi = 2 \left ( \arcsin (1) - \arcsin (0) \right ) $$

Recall now that arcsin(0) means the angle whose sine is 0. Looking again at Fig. 2, we see that the sine of an angle is the length of side o divided by the length of side h.

copy figure 2 here

The only way for the sine to be zero is for the length of side o to be zero, and that only happens when the angle is zero. So in other words,


 * $$ \arcsin (0) = 0 $$

which leaves us with a formula for pi of


 * $$ \pi = 2 \arcsin (1) $$

''By the way, just in case you try to punch this into your calculator and come up with 180, it's because the calculator is set for angles in degrees. It must be set to do angles in radians to get the proper answer.''

Power series
We can calculate the arcsine of a number using an infinite series.

Series review: A series is the sum of the terms of a sequence, which is an ordered list of terms, either increasing or decreasing, that differ by a specific amount. A simple sequence would be


 * $$ 1 + \frac {1} {2} + \frac {1} {4} + \frac {1} {8} $$

where each term is exactly half of the preceding term. A sequence can have a fixed number of terms, or an infinite number. Rather than write out all the terms, which is often impossible, sequences are written using a shorthand sigma notation which describes the expression used to calculate the terms.

The formula for arcsine, expressed in this shorthand notation, is


 * $$ \arcsin (x) = \sum_{n=0}^\infty \left( \frac {(2n)!} {2^{2n}(n!)^2} \right) \frac {\color{red} {x^{2n+1}}} {(2n+1)}; \qquad | x | \le 1 $$

which we will use the generate the terms we need. But first we will simplify it a little. Since we are only interested in evaluating the function for x equal to 1, the expression


 * $$ {\color{red} x^{2n+1}} $$

will always be equal to 1, since 1 raised to any power is still 1. So we can replace it thusly


 * $$ \arcsin (1) = \sum_{n=0}^\infty \left( \frac {(2n)!} {2^{2n}(n!)^2} \right) \frac {(2n+1)} $$

Recalling that we still have a factor,


 * $$ \pi = {\color{blue} 2 } \arcsin (1) $$

we can apply our factor either after making the sum,


 * $$ {\color{blue} 2 } \arcsin (1) = {\color{blue} 2 } \cdot \sum_{n=0}^\infty \left( \frac {(2n)!} {2^{2n}(n!)^2} \right) \frac {1} {(2n+1)} $$

or more conveniently apply it to each term like this


 * $$ {\color{blue} 2 } \arcsin (1) = \sum_{n=0}^\infty \left( \frac {(2n)!} {2^{2n}(n!)^2} \right) \frac {(2n+1)} $$

So then our formula for pi, in shorthand notation, is


 * $$ \pi = \sum_{n=0}^\infty \left( \frac {(2n)!} {2^{2n}(n!)^2} \right) \frac {2} {(2n+1)} $$

In order to use this formula, we first generate each term with incrementing values of n. Power series like this always generate incremental looking terms, so once the pattern is determined additional terms can be created visually rather than having to evaluate the factorials each time. First let's take a look at the second factor,


 * $$ \frac {2} {(2n+1)} $$

The expression in the denominator is the well known formula for odd numbers. As n is incremented this factor in each term will be a succession of odd number denominator fractions.


 * $$ {\color{red} \frac {2} {1}}, \; {\color{red} \frac {2} {3}} , \; {\color{red} \frac {2} {5}} , \; {\color{red} \frac {2} {7}} \; \cdots $$

The first factor has a couple of factorials to deal with. A factorial, $$ n! $$, is evaluated as


 * $$ n! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot . . .  \cdot n $$

and by definition


 * $$ 0! = 1 $$

Let's evaluate the first factor for a few of the terms.


 * $$ \frac {(2n)!} {2^{2n}(n!)^2}  $$

For successive values of n the factor becomes


 * $$ n = 0 ; \quad \frac {(0)!} {2^{0}(0!)^2} = \frac {1} { 1 \cdot 1 } = {\color{blue} 1 } $$


 * $$ n = 1 ; \quad \frac {(2)!} {2^{2}(1!)^2} = \frac {2} { 4 \cdot 1 } = {\color{blue} \frac {1} {2}} $$


 * $$ n = 2 ; \quad \frac {(4)!} {2^{4}(2!)^2} = \frac {24} { 16 \cdot 4 } = {\color{blue} \frac {3} {8}} $$


 * $$ n = 3 ; \quad \frac {(6)!} {2^{6}(3!)^2} = \frac {720} { 64 \cdot 36 } = {\color{blue} \frac {5} {16}} $$

Combining the first and second factors for the terms we just calculated, we get this sequence.


 * $$ ( {\color{blue} 1 }) {\color{red} \frac {2} {1}} + \left( {\color{blue} \frac {1} {2}} \right) {\color{red} \frac {2} {3}} + \left( {\color{blue} \frac {3} {8}} \right) {\color{red} \frac {2} {5}} + \left( {\color{blue} \frac {5} {16}} \right) {\color{red} \frac {2} {7}} $$

But the visual pattern we are looking for is not yet evident. We see it in the second factor but not the first. What we need is to see the change in the factors of each succeeding term. To do that we can divide the first factor of a term by the first factor of the preceding term and get a ratio. We can then apply these ratios to generate the next terms factors. Lets find the ratio between the first factors of terms two and three.


 * $$ \frac { \frac {3} {8} } { \frac {1} {2} } = \frac {3} {4} $$

Applying this ratio to term two will give us the factor for term three.


 * $$ {\color{blue} \frac {1} {2} \cdot \frac {3} {4}} = \frac {3} {8} $$

Repeating the process with terms three and four,


 * $$ \frac { \frac {5} {16} } { \frac {3} {8} } = \frac {5} {6} $$


 * $$ \frac {3} {8} \cdot \frac {5} {6} = \frac {5} {16} $$

or, by using the factored version for term three,


 * $$ {\color{blue} \frac {1} {2} \cdot \frac {3} {4} \cdot \frac {5} {6}} = \frac {5} {16} $$

our pattern is now revealing itself. Rewriting the four terms of our sequence in their factored versions it becomes clear.


 * $$ 2 + \left( {\color{blue} \frac {1} {2}} \right) \frac {2} {3} + \left( {\color{blue} \frac {1 \cdot 3} {2 \cdot 4}} \right) \frac {2} {5} + \left( {\color{blue} \frac{1 \cdot 3 \cdot 5} {2 \cdot 4 \cdot 6 }} \right) \frac{2} {7} $$

Further calculation of terms and ratios verifies that the pattern does continue. So it is no longer necessary to evaluate the factorials and calculate each term mathematically. Each new term can be created by extending the pattern. We thus have arrived at our usable formula for pi.


 * $$ \pi = 2 + \left( \frac {1} {2} \right) \frac {2} {3} + \left( \frac {1 \cdot 3} {2 \cdot 4} \right) \frac {2} {5} + \left( \frac{1 \cdot 3 \cdot 5} {2 \cdot 4 \cdot 6 } \right) \frac{2} {7} + \left( \frac{1 \cdot 3 \cdot 5 \cdot 7} {2 \cdot 4 \cdot 6 \cdot 8} \right) \frac{2} {9} + \cdots $$

Sequences like this are perfect for the kind of algorithms computers like to do. As many terms as needed can be added until the desired accuracy of decimal places is reached, or extended indefinitely if you are going for a new record. And that's how we can calculate pi to a trillion decimal places. Sequences similar to this are what our calculators use to do trigonometry, logarithms, and exponential operations.

In theory we could do this with pencil and paper, although it is rather inefficient. It converges slowly towards pi, and after 100 terms it is only up to 3.029 so it would take a really long time. But it's good to know that when the zombie apocalypse occurs, society has collapsed, the power grid has failed, and the Internet no longer exists, we can still calculate pi whenever we need.

''Text and graphics by Madman Marcus. Formula graphics created using Wikipedia markup language.''

Help and misc
This is where I can try to figure out how all this works.

See Help:Displaying a formula for how to enter math formulas.

See Help:Wiki markup for general Wiki syntax.

Is this correct?


 * $$ \int_{0}^{\frac{\pi} {2}} \cos x \, dx = 1$$

Absolutely. Most excellent.

Will this render as a single png?


 * $$ \text {What if } x = 1/2 \text { then does } 2x = 1 \text { ?} $$

Why yes it does. But the fonts don't match the text fonts.

What if $$ x=1/2 $$ then does $$ 2x=1 $$ ?

What if $$ \; x=1/2~ $$ then does $$ \text { } 2~x=1~ $$ ?

It seems the spacing codes only work between characters within the math group, not between text outside the group and the math formulas.

This is the process for determining the standard deviation of a group of numbers.


 * 1) Find the mean value of the group of numbers.
 * $$\bar x = \frac {x_1 + x_2 + x_3 + \cdots + x_n} {n} $$
 * 1) For each number find its difference from the mean.
 * $$\bar x - x_i $$
 * 1) Square it.
 * $$ ( \bar x - x_i )^2 $$
 * 1) Add all of the squared differences together.
 * $$\sum_{i=1}^n ( \bar x - x_i )^2 $$
 * 1) Find the mean value of the total squared differences.
 * $$\frac {\sum_{i=1}^n ( \bar x - x_i )^2} {n} $$
 * 1) Finally take the square root.
 * $$\sigma = \sqrt {\frac {\sum_{i=1}^n ( \bar x - x_i )^2} {n} }$$

And there it is. However, if you are only using a sample of the total group the formula becomes


 * $$\sigma = \sqrt {\frac {\sum_{i=1}^n ( \bar x - x_i )^2} {n-1} }$$


 * $$ \frac { \ln { \frac {1,000,000} {1,000} }} { \ln {1.005} } = 1385 $$ days

Does a space make this go in a box? Yes!