Jump to content

Numerical integration: Difference between revisions

m
→‎{{header|Perl 6}}: corrected formatting tags
m (→‎{{header|Perl 6}}: Added 'Promise' for concurrency)
m (→‎{{header|Perl 6}}: corrected formatting tags)
Line 3,402:
.say for integrate '*.self', 0, 6_000, 6_000_000, 18_000_000;</lang>
{{out}}
<langpre>{ $_ ** 3 }
in [0..1] / 100
exact result: 0.25
Line 3,436:
rectangle method mid: 18000000
composite trapezoidal rule: 18000000
quadratic simpsons rule: 18000000</langpre>
 
Note that these integrations are done with rationals rather than floats, so should be fairly precise (though of course with so few iterations they are not terribly accurate (except when they are)). Some of the sums do overflow into <tt>Num</tt> (floating point)--currently Rakudo allows 64-bit denominators--but at least all of the interval arithmetic is exact.
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.