Numerical integration/Adaptive Simpson's method: Difference between revisions

→‎{{header|COBOL}}: Use signed arithmetic throughout which doesn't affect the result of this sample but could affect the results of other integrations.
(Added Oberon-2 before →‎{{header|ObjectIcon}})
(→‎{{header|COBOL}}: Use signed arithmetic throughout which doesn't affect the result of this sample but could affect the results of other integrations.)
Line 690:
=={{header|COBOL}}==
{{works with|GnuCOBOL|3.1.2.0}}
 
{{improve|COBOL|All the numeric fields are unsigned in this program, so dalta < 0 will never be true - the pictures should have a leading s.}}
Rather than do recursions, I compute the x-intervals iteratively. No attempt is made to avoid recomputing values of sin(x).
 
<syntaxhighlight lang="cobol">
Line 706 ⟶ 703:
data division.
working-storage section.
01 numer picture 9s9(25). *> 25 decimal digits.
01 denom picture 9s9(25).
01 numer2 picture 9s9(25).
01 a picture 9s9(5)V9(20). *> 5+20 decimal digits.
01 b picture 9s9(5)V9(20).
01 tol picture 9s9(5)V9(20).
01 x picture 9s9(5)V9(20).
01 y picture 9s9(5)V9(20).
01 x0 picture 9s9(5)V9(20).
01 y0 picture 9s9(5)V9(20).
01 x1 picture 9s9(5)V9(20).
01 y1 picture 9s9(5)V9(20).
01 x2 picture 9s9(5)V9(20).
01 y2 picture 9s9(5)V9(20).
01 x3 picture 9s9(5)V9(20).
01 y3 picture 9s9(5)V9(20).
01 x4 picture 9s9(5)V9(20).
01 y4 picture 9s9(5)V9(20).
01 ruleval picture 9s9(5)V9(20).
01 ruleval0 picture 9s9(5)V9(20).
01 ruleval1 picture 9s9(5)V9(20).
01 delta picture 9s9(5)V9(20).
01 abs-delta picture 9s9(5)V9(20).
01 tol0 picture 9s9(5)V9(20).
01 tol1 picture 9s9(5)V9(20).
01 delta15 picture 9s9(5)V9(20).
01 stepval picture 9s9(5)V9(20).
01 quadval picture 9s9(5)V9(20).
01 result picture 9V9-9.9(9).
procedure division.
Line 828 ⟶ 825:
{{out}}
<pre>$ cobc -std=cobol2014 -x adaptive_simpson_task.cob && ./adaptive_simpson_task
0.459697694</pre>
 
=={{header|Common Lisp}}==
3,043

edits