Back to index

wims  3.65+svn20090927
Static Public Member Functions | Static Private Member Functions
rene.zirkel.expression.Romberg Class Reference

List of all members.

Static Public Member Functions

static double compute (FunctionObject F, double a, double b, int nstart, double eps, int maxiter) throws ConstructionException
 Romberg-Verfahren.

Static Private Member Functions

static double sumUp (FunctionObject F, double x, double h, int n) throws ConstructionException
 Summiere f(x),f(x+h),...,f(x+n*h)

Detailed Description

Definition at line 10 of file Romberg.java.


Member Function Documentation

static double rene.zirkel.expression.Romberg.compute ( FunctionObject  F,
double  a,
double  b,
int  nstart,
double  eps,
int  maxiter 
) throws ConstructionException [inline, static]

Romberg-Verfahren.

Parameters:
a,b= Intervall-Grenzen
F= Funktion, die integriert wird
nstart= Anzahl der ersten Unterteilungen
eps= Relative Genauigkeit zum Abbruch
maxiter= Maximale Iterationen
Returns:
Integral oder RuntimeException

Definition at line 34 of file Romberg.java.

       {                    
              // Ergebnisse der Trapezregel mit Schrittweite h/2^i
              double t[]=new double[maxiter];
              int n=nstart;
              
              // Anfangsschrittweite
              double h=(b-a)/n;
              // Berechne Trapezregel dazu und d[0]
              double tlast=t[0]=(F.evaluateF(a)+F.evaluateF(b)+
                                   2*sumUp(F,a+h,h,n-2))*h/2;
              double tlastbutone=tlast;
              // Bisheriges Ergebnis festhalten
              double old=t[0];
       
              // Halbiere Schrittweite bis Genauigkeit erreicht              
              for (int i=1; i<maxiter; i++)
              {      // Halbiere Schrittweite:
                     h=h/2;
                     n=n*2;
                     
                     // Berechne Trapezregel (unter Verwendung des
                     // letzten Ergebnisses:
                     t[i]=tlast/2+sumUp(F,a+h,2*h,n/2-1)*h;
                     tlastbutone=tlast;
                     tlast=t[i];
                     
                     // Update der t[i]:
                     double q=4;
                     for (int j=i-1; j>=0; j--)
                     {      t[j]=t[j+1]+(t[j+1]-t[j])/(q-1);
                            q=q*4;
                     }
                            
                     // Abbruch-Kriterium
                     double res=t[0];
                     if (Math.abs((res-old)/res)<eps) return res;
                     old=res;
              }
              
              // Bei ‹berschreiten der Interationsgrenze:
              return tlast;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

static double rene.zirkel.expression.Romberg.sumUp ( FunctionObject  F,
double  x,
double  h,
int  n 
) throws ConstructionException [inline, static, private]

Summiere f(x),f(x+h),...,f(x+n*h)

Definition at line 14 of file Romberg.java.

       {   double sum=F.evaluateF(x);
         
           for (int i=1; i<=n; i++)
           {   sum=sum+F.evaluateF(x+i*h);
           }
           return sum;
       }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: