Anonymous user
Numerical integration/Gauss-Legendre Quadrature: Difference between revisions
Numerical integration/Gauss-Legendre Quadrature (view source)
Revision as of 15:52, 1 November 2013
, 10 years ago→version 2: added more optimization. -- ~~~~
Walterpachl (talk | contribs) m (→version 1: added my Prolog that was removed by GS) |
m (→version 2: added more optimization. -- ~~~~) |
||
Line 1,237:
Note that the function values for '''pi''' and '''e''' should have more precision than the number of digits specified.
<lang rexx>/*REXX pgm does numerical integration using Gauss-Legendre Quadrature. */
/*REXX pgm does numerical integration using Gauss-Legendre Quadrature. */
digs=40; d2=digs*2; tiny = '1E-'d2 /*equivalent to 1÷10**d2 */
numeric digits digs; pi=pi(); a=-3; b=3;
numeric digits d2; true = exp(b)-exp(a); bmaH=bma/2; bpaH=bpa/2
numeric digits digs+10; times = digs%2 + 1
numeric digits d2; true = exp(b) - exp(a)
numeric digits digs+10; times = digs%2 + 1
Line 1,271 ⟶ 1,274:
end /*!*/
sum=0
do m=1 for step; sum=sum+r.2.m*exp(
end /*m*/
z=
say right(step,4) format(z,2,digs) translate(format(z-true,2,4,,0),'e',"E")
end /*step*/
|