Thiele's interpolation formula: Difference between revisions

→‎{{header|Haskell}}: 100 -> 1000 (+ updated outputs)
(→‎{{header|Haskell}}: hlint, hindent + a couple of reductions)
(→‎{{header|Haskell}}: 100 -> 1000 (+ updated outputs))
Line 523:
-- Inverted interpolation function of f
invInterp :: (Double -> Double) -> [Double] -> Double -> Double
invInterp f xs = thiele (fmap <$>f xs) xs
 
main :: IO ()
Line 536:
[inv_sin, inv_cos, inv_tan] =
uncurry ((. div_pi) . invInterp) <$>
[(sin, (2, 31)), (cos, (2, 100)), (tan, (4, 1001000))]
-- N points taken uniformly from 0 to Pi/d
div_pi (d, n) = (* (pi / (d * n))) <$> [0 .. n]</lang>
Line 542:
<pre>3.141592653589795
3.141592653589791
3.1415926535897905141592653587783</pre>
 
=={{header|J}}==
9,655

edits