CORDIC: Difference between revisions

1,194 bytes added ,  11 months ago
m (→‎{{header|J}}: remove deadcode)
Line 144:
CORDIC 6
0.405107 1.39209</syntaxhighlight>
 
=== Notes ===
 
Here, we use three constants, two of which are lookup tables (<code>tent</code> gives us negative powers of ten as a lookup table):
 
<syntaxhighlight lang=J> epsilon
1e_12
phin
0.785398 0.0996687 0.00999967 0.001 0.0001 1e_5 1e_6 1e_7 1e_8 1e_9 1e_10 1e_11 1e_12
tent
1 0.1 0.01 0.001 0.0001 1e_5 1e_6 1e_7 1e_8 1e_9 1e_10 1e_11 1e_12</syntaxhighlight>
 
By default, J displays the first six digits of floating point numbers (floating point numbers are more precise, but in most circumstances the values being operated on are not more accurate than six digits). But of course, J retains the values at higher precision. For example:
 
<syntaxhighlight lang=J> {&phin
{ &0.785398163397448279 0.0996686524911620381 0.00999966668666523936 0.000999999666666867007 9.99999996666667089e_5 9.99999999966667302e_6 9.99999999999667283e_7 9.9999999999999744e_8 1.00000000000000085e_8 1.00000000000000089e_9 1.00000000000000107e_10 1....</syntaxhighlight>
 
Also: [[j:Vocabulary/SpecialCombinations#Preexecuting_verbs_with_.28.28_.29.29|double parenthesis around a noun phrase]] tells the interpreter that that expression is a constant which should be evaluated once, ahead of time.
 
=={{header|Julia}}==
6,962

edits