Numerical integration: Difference between revisions

→‎{{header|Haskell}}: (Adjusted output labelling, to bracket range, and label approximation count)
m (→‎{{header|Haskell}}: (Changed one name))
(→‎{{header|Haskell}}: (Adjusted output labelling, to bracket range, and label approximation count))
Line 2,351:
putStrLn $
justifyLeft 20 ' ' ("f(x) = " ++ s) ++
unwords (show <$> [a, b]) ++ " (" ++ show n ++ " approximations)"
mapM_
(\(s, integration) ->
Line 2,362:
justifyLeft n c s = take n (s ++ replicate n c)</lang>
{{Out}}
<pre>f(x) = x^3 [0.0 ,1.0] (100 approximations)
rectangular left: 0.24502500000000005
rectangular middle: 0.24998750000000006
Line 2,369:
simpson: 0.25000000000000006
 
f(x) = 1/x [1.0 ,100.0] (1000 approximations)
rectangular left: 4.65499105751468
rectangular middle: 4.604762548678376
Line 2,376:
simpson: 4.605170384957135
 
f(x) = x [0.0 ,5000.0] (500000 approximations)
rectangular left: 1.2499975000000006e7
rectangular middle: 1.2499999999999993e7
Line 2,383:
simpson: 1.2499999999999998e7
 
f(x) = x [0.0 ,6000.0] (600000 approximations)
rectangular left: 1.7999970000000004e7
rectangular middle: 1.7999999999999993e7
9,659

edits