# This Is M4dn355 300

Joined 28 November 2011

This_Is_M4dn355_300 is your average Wikipedian, serving from the United States. He signed up after many years of using the website to gather information for research papers, then deciding to edit pages for the betterment of the community and the retainment of its usefulness.

He has an aptitude for mathematics as well as programming and information technology; having a poor knowledge of foreign language, he is currently learning to speak Polish, Russian, German, and Greek (with varying levels of success.)

## Algorithm for Base Conversion

This is an algorithm created several years ago to turn converting from one base to another an automated process.

The algorithm presented here is stated using pseudo-code:

${\displaystyle -1}$   store  ${\displaystyle r}$

${\displaystyle 0}$   store  ${\displaystyle n_{n}}$

 While  ${\displaystyle n_{o}\neq 0}$

 While  ${\displaystyle {b_{n}}^{r+1}\leq n_{o}}$
${\displaystyle r+1}$   store ${\displaystyle r}$
 ${\displaystyle {n_{o}}-{b_{n}}^{r}}$  store ${\displaystyle n_{o}}$  ${\displaystyle {{b_{o}}^{r}}+n_{n}}$  store ${\displaystyle n_{n}}$  ${\displaystyle -1}$  store ${\displaystyle r}$ 
bo is the base you are converting from, bn is the base you are converting from; no is the number you are converting in its original base, nn is the number in the new base. r is used as a manipulatable variable for converting. ExampleLet us convert 9 from decimal (base10) to binary (base2): ${\displaystyle r=-1}$  ${\displaystyle n_{n}=0}$  ${\displaystyle n_{o}=9\neq 0}$  ${\displaystyle {b_{n}}^{r+1}=2^{0}=1\leq 9=n_{o}}$  ${\displaystyle r=-1+1=0}$  ${\displaystyle {b_{n}}^{r+1}=2^{1}=2\leq 9=n_{o}}$  ${\displaystyle r=0+1=1}$  ${\displaystyle {b_{n}}^{r+1}=2^{2}=4\leq 9=n_{o}}$  ${\displaystyle r=1+1=2}$  ${\displaystyle {b_{n}}^{r+1}=2^{3}=8\leq 9=n_{o}}$  ${\displaystyle r=2+1=3}$  ${\displaystyle {b_{n}}^{r+1}=2^{4}=16>9=n_{o}}$  ${\displaystyle {n_{o}}-{b_{n}}^{r}=9-8=1=n_{o}}$  ${\displaystyle {b_{o}}^{r}+n_{n}=10^{3}=1000+0=1000=n_{n}}$  ${\displaystyle r=-1}$ ${\displaystyle n_{o}=1\neq 0}$  ${\displaystyle {b_{n}}^{r+1}=2^{0}=1\leq 1=n_{o}}$  ${\displaystyle r=-1+1=0}$  ${\displaystyle {b_{n}}^{r+1}=2^{1}=2>1=n_{o}}$  ${\displaystyle {n_{o}}-{b_{n}}^{r}=1-2^{0}=1-1=0=n_{o}}$  ${\displaystyle {b_{o}}^{r}+n_{n}=10^{0}=1+1000=1=n_{n}}$  ${\displaystyle r=-1}$ ${\displaystyle n_{o}=0=0}$  ${\displaystyle n_{n}=1001_{2}=9_{10}}$  This works with integers only; the easiest way to have a decimal is to convert it to a fraction and convert the numerator and denominator. Why does it work?The reason this algorithm works is because of a deviously simple rule: all radix systems operate under the same rules -- other than the number at which to add a digit, of course. You can add, subtract, and, therefore, do anything else -- be it multiplying, dividing, squaring, square-rooting, you name it -- the same way in binary as you do in decimal. But how does a number get from binary to decimal, and vice-versa? The answer lies within the difference between these bases. Digits in base10 each represent that power-1 of 10. 1 is 1*100, while 92 is 9*101+2*100. This seems redundant to us, being as how our numerical thoughts are in decimal. It becomes more practical when we apply this to different bases. Take another look at binary. Each digit is for that power of 2. This means that 12 is 110, 102 is 210. 1002 is 410, and so on. Formula of Areas of regular 2D Objects in r2 FormThe search for this formula ended with trying to find a formula from the original formula for the area of polygons: ${\displaystyle A={1 \over 2}ap}$  Where A is the area of the shape, a is the apothem, and p is the perimeter. This formula was to be merged with the formula for the area of a circle: ${\displaystyle A=\pi r^{2}}$  Again, A is the area of the shape, but r is the radius. This formula is just a special case for the area of a polygon where these requirements are met: ${\displaystyle C=p=2\pi r}$  ${\displaystyle a=r}$  The perimeter, or circumference of a circle, is equal to 2πr, and the apothem is equal to the radius of the circle. The central angle of the circumscribed circle of the triangle formed with each edge and two vertices of these polygons can be defined as: ${\displaystyle c_{a}={360^{\circ } \over n_{s}}}$  Where ca is the central angle and ns is the number of sides that the shape has. Because the triangles must be isosceles, as the radius (r) of the circumscribed circle is the same across the edges of the shape, a division of these triangles yields twice as many right triangles, where the central angles are:   The graph of the r2 function, where x is ns, and y is A⁄r2. The asymptote of this function is y=π, shown in red.${\displaystyle c_{a}={360^{\circ } \over 2n_{s}}}$  Since r must be the hypotenuse of these right triangles, the height of this triangle is: ${\displaystyle h=r\cos c_{a}}$  Or: ${\displaystyle h=r\cos {360^{\circ } \over 2n_{s}}}$  Where the base (½ of the base of the isosceles triangle) is: ${\displaystyle {1 \over 2}b=r\sin {360^{\circ } \over 2n_{s}}}$  Therefore: ${\displaystyle b=2r\sin {360^{\circ } \over 2n_{s}}}$  This means that the area of one of these triangles is equal to ½bh. When plugged in, this equals: ${\displaystyle A_{t}=r^{2}\sin {360^{\circ } \over 2n_{s}}\cos {360^{\circ } \over 2n_{s}}}$  And because the number of sides that a polygon has is also the number of possible bases and therefore the number of triangles in the shape, the area of the figure is equal to the number of sides multiplied by the area of each triangle: ${\displaystyle A=n_{s}A_{t}}$  When expanded, this equals: ${\displaystyle A=n_{s}r^{2}\sin {360^{\circ } \over 2n_{s}}\cos {360^{\circ } \over 2n_{s}}}$  ExampleThis formula works for every possible 2-dimensional regular shape. For example, the formula for the area of an equilateral triangle in r2 form is: ${\displaystyle A=3r^{2}\sin {60^{\circ }}\cos {60^{\circ }}}$  Try this out on an imaginary equilateral triangle with side lengths of 1. To find the area using the old formula for the area of a polygon, we must find the height of the polygon: ${\displaystyle A={1 \over 2}bh}$  Since the base of the triangle is already given (1), we must only find the height (h) ${\displaystyle A={1 \over 2}1h={1 \over 2}h}$  If we have an equilateral triangle, we can split it in two to form two right triangles. From here, we can figure out the height of the equilateral triangle: ${\displaystyle h=b\sin 60^{\circ }=1\sin 60^{\circ }=\sin 60^{\circ }}$  With this, we can now solve for the area of the triangle: ${\displaystyle A={1 \over 2}h={1 \over 2}\sin 60^{\circ }}$  Having obtained the area of the triangle, we can test the formula to see if it holds true: ${\displaystyle {\sin 60^{\circ } \over 2}=3r^{2}\sin 60^{\circ }\cos 60^{\circ }}$  To find r2 we must again use trigonometric ratios to find r: ${\displaystyle r={.5 \over \sin 60^{\circ }}={1 \over 2\sin 60^{\circ }}}$  We must square r to be able to plug it into the formula: ${\displaystyle r^{2}={{1^{2}} \over {2^{2}}{\sin ^{2}60^{\circ }}}={1 \over 4\sin ^{2}60^{\circ }}}$  We can now plug the answer in for r2: ${\displaystyle {\sin 60^{\circ } \over 2}=3{1 \over 4\sin ^{2}60^{\circ }}\sin 60^{\circ }\cos 60^{\circ }={{3\cos 60^{\circ }} \over {4\sin 60^{\circ }}}}$  This is, indeed, correct. The area of the triangle is equal, about .433 for both formulas: ${\displaystyle {\sin 60^{\circ } \over 2}={{3\cos 60^{\circ }} \over {4\sin 60^{\circ }}}}$  Why does it work?Begin by analyzing the formula for the area of a regular polygon: ${\displaystyle A={1 \over 2}ap}$  This formula obscurely references the formula for the area of a triangle: ${\displaystyle A={1 \over 2}bh}$  In this formula, b is the base and h is the height of the triangle. The area of a polygon can be considered the addition of the areas of the triangles that can be made out of the polygon, a is the height of each triangle, and p is the addition of all of the bases. The r2 formula can be thought of as doing the same. Height h in the r2 formula is: ${\displaystyle h=r\cos {360^{\circ } \over 2n_{s}}}$  Whereas base b of one of the triangles is: ${\displaystyle h=2r\sin {360^{\circ } \over 2n_{s}}}$  Plug these into the triangle-area formula and you have: ${\displaystyle A_{t}=r^{2}\sin {360^{\circ } \over 2n_{s}}\cos {360^{\circ } \over 2n_{s}}}$  Now, to get the area of the polygon, all you have to do is multiply by the number of triangles -- which is equal to the number of sides. You end up with the r2 formula: ${\displaystyle A={n_{s}}r^{2}\sin {360^{\circ } \over 2n_{s}}\cos {360^{\circ } \over 2n_{s}}}$  Value for πBecause a curve can be thought of as being composed of infinitely many, infinitely small line segments, a circle can be thought of as being the same. This means that: ${\displaystyle A=\infty r^{2}\sin {360^{\circ } \over 2\infty }\cos {360^{\circ } \over 2\infty }}$  Now, we head back to the original formula for the area of a circle: ${\displaystyle A=\pi r^{2}}$  Dividing by r2, we get: ${\displaystyle {A \over r^{2}}=\pi }$  Therefore, the area of a circle over the square of its radius is equal to π. This can be obtained in the new formula by dividing by r2 again: ${\displaystyle {A \over r^{2}}=\infty \sin {360^{\circ } \over 2\infty }\cos {360^{\circ } \over 2\infty }}$  We can now substitute π in. ${\displaystyle \pi =\infty \sin {360^{\circ } \over 2\infty }\cos {360^{\circ } \over 2\infty }}$  This is more aptly represented using the limit bound because the graph of this function never touches π: ${\displaystyle \lim _{n_{s}\to \infty }n_{s}\sin {360^{\circ } \over 2n_{s}}\cos {360^{\circ } \over 2n_{s}}=\pi }$  What does this mean?Aside from relating π and ∞, this equation is just another representation of what the r2 formula does: it adds the areas of triangles together to find the area of the shape. This means that there are infinitely many triangles inside a circle, and the central angles of these triangles are 1⁄2 of 1⁄∞ degrees wide.