@@ -5,20 +5,20 @@ chapter: Math
5
5
---
6
6
## Problem
7
7
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 ] .
9
9
10
10
## 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
12
12
integer operations along with a 'magic number' to calculate floating point
13
13
approximation values of inverse square roots.
14
14
15
15
In 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
17
17
sized magic number.
18
18
19
19
Another 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 ] .
22
22
23
23
Depending on the machine and level of percision this algorithm may still
24
24
provide performance increases over the classic.
@@ -29,14 +29,20 @@ To run this, compile the script with coffee:
29
29
Then copy & paste the compiled js code in to the JavaSript console of your
30
30
browser.
31
31
32
- Note: You will need a browser which supports typed-arrays[ 4] .
32
+ Note: You will need a browser which supports [ typed-arrays] [ 4 ] .
33
33
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 "
40
46
41
47
This code is in gist form here:
42
48
[ https://gist.github.com/1036533 ] ( https://gist.github.com/1036533 )
@@ -50,7 +56,7 @@ Author: Jason Giedymin <jasong _a_t_ apache -dot- org>
50
56
51
57
Appearing in the Quake III Arena source code[ 1] , this strange algorithm uses
52
58
integer 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 ] .
54
60
55
61
In this CoffeeScript variant I supply the original classic, and newer optimal
56
62
32 bit magic numbers found by Chris Lomont[ 2] . Also supplied is the 64-bit
@@ -76,6 +82,7 @@ References:
76
82
[ 2] http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
77
83
[ 3] http://en.wikipedia.org/wiki/Newton%27s_method
78
84
[ 4] https://developer.mozilla.org/en/JavaScript_typed_arrays
85
+ [ 5] http://en.wikipedia.org/wiki/Fast_inverse_square_root
79
86
80
87
###
81
88
0 commit comments