Thiele's interpolation formula: Difference between revisions
Content added Content deleted
m (added whitespace before the TOC, added a Task (bold) header.) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: default to 12 element table, 'cos' converges slowly) |
||
Line 746: | Line 746: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{ |
{{Works with|rakudo|2016.07}}<br> |
||
Implemented to parallel the (generalized) formula. (i.e. clearer, but naive and very slow.) |
Implemented to parallel the (generalized) formula. (i.e. clearer, but naive and very slow.) |
||
<lang perl6>use v6; |
<lang perl6>use v6; |
||
Line 783: | Line 783: | ||
} |
} |
||
sub MAIN($tblsz) { |
sub MAIN($tblsz = 12) { |
||
my %invsin = mk-inv(&sin, 0.05, $tblsz); |
my %invsin = mk-inv(&sin, 0.05, $tblsz); |
||
my %invcos = mk-inv(&cos, 0.05, $tblsz); |
my %invcos = mk-inv(&cos, 0.05, $tblsz); |
||
Line 799: | Line 799: | ||
}</lang> |
}</lang> |
||
Output: |
|||
Output (table size of 6 for want of resources): |
|||
<pre>pi = 3.14159265358979 |
<pre>pi = 3.14159265358979 |
||
estimations using a table of |
estimations using a table of 12 elements: |
||
sin interpolation: 3. |
sin interpolation: 3.14159265358961 |
||
cos interpolation: |
cos interpolation: 3.1387286696692 |
||
tan interpolation: 3. |
tan interpolation: 3.14159090545243</pre> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |