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