Numerical integration: Difference between revisions

Content added Content deleted
(→‎{{header|J}}: use symbols)
Line 855:
)</lang>
'''Example usage'''<br>
Integrate <code>square</code> (<code>*:</code>) from 0 to &pi; in 10 steps using various methods.
<lang j>
*: rectangle integrate 0 1p1 10
Line 864:
10.3354255601
</lang>
Integrate <code>sin</code> from 0 to &pi; in 10 steps using various methods.
<lang j>
sin=: 1&o.
Line 879:
0 p.. 0 0 1x NB. or using rationals
0 0 0 1r3</lang>
That is: <math>0x^0 + 0x^1 + 0x^2 + 0.3333x\tfrac{1}{3}x^3</math><br>
So to integrate <math>x^2</math> from 0 to &pi; :
<lang j> 0 0 1 (0&p..@[ -~/@:p. ]) 0 1p1
10.3354255601</lang>