Anonymous user
Numerical integration/Gauss-Legendre Quadrature: Difference between revisions
Numerical integration/Gauss-Legendre Quadrature (view source)
Revision as of 03:42, 27 January 2012
, 12 years agoD 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!(
writeln("Roots: ", glq.lroots);
writeln("Weight: ", glq.weight);
Line 303:
exp(3.0) - exp(-3.0));
}</lang>
<pre>Roots: [0.
Weight: [0.
Integrating exp(x) over [-3, 3]: 20.
Compred to actual: 20.035749854820</pre>
|