dh-Materialien Einführung in Maple    Übungen
|  Home  |  Back  |  <   >  |

Mathematik
 

Einführung in Maple
  Hinweise
  Übersicht
  Übungen
  Anwendungen
  Stichworte
  Download
 

Numerische Integration: Das Simpsonverfahren

restart;

Definition einer Funktion:

f:= x -> sqrt(x)*sin(x);
plot (f(x), x = 0..3);

Das Integral soll numerisch, und zwar mit Hilfe der Simpsonformel, berechnet werden:

A:= Int (f(x), x = 0..3);

A := Int(x^(1/2)*sin(x),x = 0 .. 3)

Simpson:= proc (a, b, n)
            local i, j, h, fx, s:
            h:= (b-a)/n;
            for i from 0 to n do
              fx[i]:= evalf (f(a + i*h));
            od:
            s:= fx[0] + fx[n]:
            s:= s + 2*sum(fx[2*j], j = 1..(n/2-1)):
            s:= s + 4*sum(fx[2*j+1], j = 0..(n/2-1)):
            1/3*s*h:
          end:

Simpson (0, 3, 10);
Simpson (0, 3, 100);
Simpson (0, 3, 1000);

2.418645673
2.417854215
2.417852019

Die Lösung des gegebenen Integrals durch Maple:

value (A);
evalf (%);

 2.417852014

Copyright

Valid HTML 4.01 Transitional

|  Home  |  Back  |  Top  |