Anonymous user
Numerical integration: Difference between revisions
m
→{{header|REXX}}: changed the format of the output to use arrows, used a better/cleaner name for some algorithms in the output.
m (→{{header|REXX}}: changed the trapezium function's returned value, changed some comments.) |
m (→{{header|REXX}}: changed the format of the output to use arrows, used a better/cleaner name for some algorithms in the output.) |
||
Line 3,588:
say
say center('test' test,65,'─') /*display a header for the test suite. */
say '
say '
say '
say ' Simpson('L", "H', 'i")
say ' trapezium('L", "H', 'i")
end /*test*/
exit /*stick a fork in it, we're all done. */
Line 3,623:
trapezium: procedure expose test; parse arg a,b,n; h=(b-a)/n
$=0
do x=a by h for n; $=$+(f(x)+f(x+h))
return $*h/
'''output'''
<pre>
─────────────────────────────test 1──────────────────────────────
Simpson(0, 1, 100)
trapezium(0, 1, 100)
─────────────────────────────test 2──────────────────────────────
Simpson(1, 100, 1000)
trapezium(1, 100, 1000)
─────────────────────────────test 3──────────────────────────────
Simpson(0, 5000, 5000000)
trapezium(0, 5000, 5000000)
─────────────────────────────test 4──────────────────────────────
Simpson(0, 6000, 5000000)
trapezium(0, 6000, 5000000)
</pre>
|