@@ -5,20 +5,20 @@ chapter: Math
55---
66## Problem
77
8- You would like to calculate a the inverse square root[ 5 ] of a number quickly.
8+ You would like to calculate a the inverse square root of a number [ quickly] [ 5 ] .
99
1010## Solution
11- Appearing in the Quake III Arena source code[ 1] , this strange algorithm uses
11+ Appearing in the Quake III Arena [ source code] [ 1 ] , this strange algorithm uses
1212integer operations along with a 'magic number' to calculate floating point
1313approximation values of inverse square roots.
1414
1515In this CoffeeScript variant I supply the original classic, and newer optimal
16- 32 bit magic numbers found by Chris Lomont[ 2] . Also supplied is the 64-bit
16+ 32 bit magic numbers found by [ Chris Lomont] [ 2 ] . Also supplied is the 64-bit
1717sized magic number.
1818
1919Another feature included is the ability to alter the level of precision.
20- This is done by controling the number of iterations for performing Newton's
21- method[ 3] .
20+ This is done by controling the number of iterations for performing [ Newton's
21+ method] [ 3 ] .
2222
2323Depending on the machine and level of percision this algorithm may still
2424provide performance increases over the classic.
@@ -29,14 +29,20 @@ To run this, compile the script with coffee:
2929Then copy & paste the compiled js code in to the JavaSript console of your
3030browser.
3131
32- Note: You will need a browser which supports typed-arrays[ 4] .
32+ Note: You will need a browser which supports [ typed-arrays] [ 4 ] .
3333
34- References:
35- * [ 1] [ ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip] ( ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip )
36- * [ 2] [ http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf ] ( http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf )
37- * [ 3] [ http://en.wikipedia.org/wiki/Newton%27s_method ] ( http://en.wikipedia.org/wiki/Newton%27s_method )
38- * [ 4] [ https://developer.mozilla.org/en/JavaScript_typed_arrays ] ( https://developer.mozilla.org/en/JavaScript_typed_arrays )
39- * [ 5] [ http://en.wikipedia.org/wiki/Fast_inverse_square_root ] ( http://en.wikipedia.org/wiki/Fast_inverse_square_root )
34+ References:
35+ 1 . [ ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip] ( ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip )
36+ 2 . [ http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf ] ( http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf )
37+ 3 . [ http://en.wikipedia.org/wiki/Newton%27s_method ] ( http://en.wikipedia.org/wiki/Newton%27s_method )
38+ 4 . [ https://developer.mozilla.org/en/JavaScript_typed_arrays ] ( https://developer.mozilla.org/en/JavaScript_typed_arrays )
39+ 5 . [ http://en.wikipedia.org/wiki/Fast_inverse_square_root ] ( http://en.wikipedia.org/wiki/Fast_inverse_square_root )
40+
41+ [ 1 ] : ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip " ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip "
42+ [ 2 ] : http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf " http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf "
43+ [ 3 ] : http://en.wikipedia.org/wiki/Newton%27s_method " http://en.wikipedia.org/wiki/Newton%27s_method "
44+ [ 4 ] : https://developer.mozilla.org/en/JavaScript_typed_arrays " https://developer.mozilla.org/en/JavaScript_typed_arrays "
45+ [ 5 ] : http://en.wikipedia.org/wiki/Fast_inverse_square_root " http://en.wikipedia.org/wiki/Fast_inverse_square_root "
4046
4147This code is in gist form here:
4248[ https://gist.github.com/1036533 ] ( https://gist.github.com/1036533 )
@@ -50,7 +56,7 @@ Author: Jason Giedymin <jasong _a_t_ apache -dot- org>
5056
5157Appearing in the Quake III Arena source code[ 1] , this strange algorithm uses
5258integer operations along with a 'magic number' to calculate floating point
53- approximation values of inverse square roots.
59+ approximation values of inverse square roots[ 5 ] .
5460
5561In this CoffeeScript variant I supply the original classic, and newer optimal
566232 bit magic numbers found by Chris Lomont[ 2] . Also supplied is the 64-bit
@@ -76,6 +82,7 @@ References:
7682[ 2] http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
7783[ 3] http://en.wikipedia.org/wiki/Newton%27s_method
7884[ 4] https://developer.mozilla.org/en/JavaScript_typed_arrays
85+ [ 5] http://en.wikipedia.org/wiki/Fast_inverse_square_root
7986
8087###
8188
0 commit comments