Check Machin-like formulas: Difference between revisions

m
added whitespace before the TOC (table of contents), added other whitespace to the task's preamble, added a ;Task: (bold) header. .
m (added whitespace before the TOC (table of contents), added other whitespace to the task's preamble, added a ;Task: (bold) header. .)
Line 1:
{{task}}
 
[[wp:Machin-like_formula|Machin-like formulas]] are useful for efficiently computing numerical approximations to Pi.
 
Verify the following Machin-like formulas are correct by calculating the value of '''tan'''(''right hand side)'' for each equation using exact arithmetic and showing they equal 1:
 
;Task:
Verify the following Machin-like formulas are correct by calculating the value of &nbspl '''tan'''   (''right hand side)''   for each equation using exact arithmetic and showing they equal   '''1''':
 
: <math>{\pi\over4} = \arctan{1\over2} + \arctan{1\over3}</math>
Line 20 ⟶ 24:
: <math>{\pi\over4} = 88 \arctan{1\over172} + 51 \arctan{1\over239} + 32 \arctan{1\over682} + 44 \arctan{1\over5357} + 68 \arctan{1\over12943}</math>
 
and confirm that the following formula is incorrect by showing &nbsp; '''tan''' &nbsp; (''right hand side)'' &nbsp; is ''not'' &nbsp; '''1''':
 
: <math>{\pi\over4} = 88 \arctan{1\over172} + 51 \arctan{1\over239} + 32 \arctan{1\over682} + 44 \arctan{1\over5357} + 68 \arctan{1\over12944}</math>
Line 31 ⟶ 35:
: <math>\tan(-a) = -\tan(a)</math>
 
<br>
You can store the equations in any convenient data structure, but for extra credit parse them from human-readable [[Check_Machin-like_formulas/text_equations|text input]].
 
Note that to formally prove the formula correct you would also have to show that ''<math>{-3 pi \over 4}</math> < right hand side < <math>{5 pi \over 4}</math>'' due to ''<math>\tan()</math>'' periodicity.
<br><br>
 
=={{header|D}}==
This uses the module of the Arithmetic Rational Task.