Check Machin-like formulas: Difference between revisions
Content added Content deleted
(Change from draft to non-draft task) |
No edit summary |
||
Line 270: | Line 270: | ||
0</lang> |
0</lang> |
||
'''Notes''': The function <tt>machin</tt> compares the results of each formula to π/4 (expressed as <tt>1r4p1</tt> in J's numeric notation). The first example above shows the results of these comparisons for each formula (with 1 for true and 0 for false). In J, arctan is expressed as <tt>3 o. ''values''</tt> and the function <tt>x:</tt> coerces values to extended precision; thereafter J will maintain extended precision throughout its calculations, as long as it can. |
'''Notes''': The function <tt>machin</tt> compares the results of each formula to π/4 (expressed as <tt>1r4p1</tt> in J's numeric notation). The first example above shows the results of these comparisons for each formula (with 1 for true and 0 for false). In J, arctan is expressed as <tt>3 o. ''values''</tt> and the function <tt>x:</tt> coerces values to extended precision; thereafter J will maintain extended precision throughout its calculations, as long as it can. |
||
=={{header|Mathematica}}== |
|||
<lang>Tan[ArcTan[1/2] + ArcTan[1/3]] == 1 |
|||
Tan[2 ArcTan[1/3] + ArcTan[1/7]] == 1 |
|||
Tan[4 ArcTan[1/5] - ArcTan[1/239]] == 1 |
|||
Tan[5 ArcTan[1/7] + 2 ArcTan[3/79]] == 1 |
|||
Tan[5 ArcTan[29/278] + 7 ArcTan[3/79]] == 1 |
|||
Tan[ArcTan[1/2] + ArcTan[1/5] + ArcTan[1/8]] == 1 |
|||
Tan[4 ArcTan[1/5] - ArcTan[1/70] + ArcTan[1/99]] == 1 |
|||
Tan[5 ArcTan[1/7] + 4 ArcTan[1/53] + 2 ArcTan[1/4443]] == 1 |
|||
Tan[6 ArcTan[1/8] + 2 ArcTan[1/57] + ArcTan[1/239]] == 1 |
|||
Tan[8 ArcTan[1/10] - ArcTan[1/239] - 4 ArcTan[1/515]] == 1 |
|||
Tan[12 ArcTan[1/18] + 8 ArcTan[1/57] - 5 ArcTan[1/239]] == 1 |
|||
Tan[16 ArcTan[1/21] + 3 ArcTan[1/239] + 4 ArcTan[3/1042]] == 1 |
|||
Tan[22 ArcTan[1/28] + 2 ArcTan[1/443] - 5 ArcTan[1/1393] - |
|||
10 ArcTan[1/11018]] == 1 |
|||
Tan[22 ArcTan[1/38] + 17 ArcTan[7/601] + 10 ArcTan[7/8149]] == 1 |
|||
Tan[44 ArcTan[1/57] + 7 ArcTan[1/239] - 12 ArcTan[1/682] + |
|||
24 ArcTan[1/12943]] == 1 |
|||
Tan[88 ArcTan[1/172] + 51 ArcTan[1/239] + 32 ArcTan[1/682] + |
|||
44 ArcTan[1/5357] + 68 ArcTan[1/12943]] == 1 |
|||
Tan[88 ArcTan[1/172] + 51 ArcTan[1/239] + 32 ArcTan[1/682] + |
|||
44 ArcTan[1/5357] + 68 ArcTan[1/12944]] == 1</lang> |
|||
{{Out}} |
|||
<pre>True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
True |
|||
False</pre> |
|||
=={{header|Maxima}}== |
|||
<lang maxima>trigexpand:true$ |
|||
is(tan(atan(1/2)+atan(1/3))=1); |
|||
is(tan(2*atan(1/3)+atan(1/7))=1); |
|||
is(tan(4*atan(1/5)-atan(1/239))=1); |
|||
is(tan(5*atan(1/7)+2*atan(3/79))=1); |
|||
is(tan(5*atan(29/278)+7*atan(3/79))=1); |
|||
is(tan(atan(1/2)+atan(1/5)+atan(1/8))=1); |
|||
is(tan(4*atan(1/5)-atan(1/70)+atan(1/99))=1); |
|||
is(tan(5*atan(1/7)+4*atan(1/53)+2*atan(1/4443))=1); |
|||
is(tan(6*atan(1/8)+2*atan(1/57)+atan(1/239))=1); |
|||
is(tan(8*atan(1/10)-atan(1/239)-4*atan(1/515))=1); |
|||
is(tan(12*atan(1/18)+8*atan(1/57)-5*atan(1/239))=1); |
|||
is(tan(16*atan(1/21)+3*atan(1/239)+4*atan(3/1042))=1); |
|||
is(tan(22*atan(1/28)+2*atan(1/443)-5*atan(1/1393)-10*atan(1/11018))=1); |
|||
is(tan(22*atan(1/38)+17*atan(7/601)+10*atan(7/8149))=1); |
|||
is(tan(44*atan(1/57)+7*atan(1/239)-12*atan(1/682)+24*atan(1/12943))=1); |
|||
is(tan(88*atan(1/172)+51*atan(1/239)+32*atan(1/682)+44*atan(1/5357)+68*atan(1/12943))=1); |
|||
is(tan(88*atan(1/172)+51*atan(1/239)+32*atan(1/682)+44*atan(1/5357)+68*atan(1/12944))=1);</lang> |
|||
{{out}} |
|||
<pre>(%i2) |
|||
(%o2) true |
|||
(%i3) |
|||
(%o3) true |
|||
(%i4) |
|||
(%o4) true |
|||
(%i5) |
|||
(%o5) true |
|||
(%i6) |
|||
(%o6) true |
|||
(%i7) |
|||
(%o7) true |
|||
(%i8) |
|||
(%o8) true |
|||
(%i9) |
|||
(%o9) true |
|||
(%i10) |
|||
(%o10) true |
|||
(%i11) |
|||
(%o11) true |
|||
(%i12) |
|||
(%o12) true |
|||
(%i13) |
|||
(%o13) true |
|||
(%i14) |
|||
(%o14) true |
|||
(%i15) |
|||
(%o15) true |
|||
(%i16) |
|||
(%o16) true |
|||
(%i17) |
|||
(%o17) true |
|||
(%i18) |
|||
(%o18) false</pre> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |