Numerical integration/Gauss-Legendre Quadrature: Difference between revisions

D code: the task asked for N=5
(+ D entry)
(D code: the task asked for N=5)
Line 295:
 
void main() {
const glq = new GaussLegendreQuadrature!(75, real);
writeln("Roots: ", glq.lroots);
writeln("Weight: ", glq.weight);
Line 303:
exp(3.0) - exp(-3.0));
}</lang>
<pre>Roots: [0.94910890618, 0.741531538469, 0.405845, 0, -0.405845, -0.741531538469, -0.94910890618]
Weight: [0.129485236927, 0.279705478629, 0.38183568889, 0.417959478629, 0.38183, 0.279705, 0.129485236927]
Integrating exp(x) over [-3, 3]: 20.035749819727035577718386
Compred to actual: 20.035749854820</pre>
 
Anonymous user