Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Romberg Calculator

Romberg

Function: romberg (<expr>, <x>, <a>, <b>)

f (x) := sin(x^2 + 0.2);
numer : true;
a : 1;
 b : %pi/2;
epsilon : 0.001;
romberg(f (x), x, a, b);
Jt(n) := ev((b-a)/2*n*(f(a) + f(b)+2*sum(f(a + (b-a)/n*i), i, 1, n-1)), numer);
n:1;

Function: romberg (<F>, <a>, <b>) Computes a numerical integration by Rombergs method.

romberg(<expr>, <x>, <a>, <b>) returns an estimate of the integral integrate(<expr>, <x>, <a>, <b>). <expr> must be an expression which evaluates to a floating point value when <x> is bound to a floating point value.

romberg(<F>, <a>, <b>) returns an estimate of the integral integrate(<F>(x), x, <a>, <b>) where x represents the unnamed, sole argument of <F>; the actual argument is not named x. <F> must be a Maxima or Lisp function which returns a floating point value when the argument is a floating point value. <F> may name a translated or compiled Maxima function.

The accuracy of romberg is governed by the global variables rombergabs and rombergtol. romberg terminates successfully when the absolute difference between successive approximations is less than rombergabs, or the relative difference in successive approximations is less than rombergtol. Thus when rombergabs is 0.0 (the default) only the relative error test has any effect on romberg.

romberg halves the stepsize at most rombergit times before it gives up; the maximum number of function evaluations is therefore 2^rombergit. If the error criterion established by rombergabs and rombergtol is not satisfied, romberg prints an error message. romberg always makes at least rombergmin iterations; this is a heuristic intended to prevent spurious termination when the integrand is oscillatory.

romberg repeatedly evaluates the integrand after binding the variable of integration to a specific value (and not before). This evaluation policy makes it possible to nest calls to romberg, to compute multidimensional integrals. However, the error calculations do not take the errors of nested integrations into account, so errors may be underestimated. Also, methods devised especially for multidimensional problems may yield the same accuracy with fewer function evaluations.

load(romberg) loads this function.

See also QUADPACK, a collection of numerical integration functions.

Examples:

A 1-dimensional integration.

          (%i1) load (romberg);
          (%o1)    /usr/share/maxima/5.11.0/share/numeric/romberg.lisp
          (%i2) f(x) := 1/((x - 1)^2 + 1/100) + 1/((x - 2)^2 + 1/1000)
                        + 1/((x - 3)^2 + 1/200);
                              1                 1                1
          (%o2) f(x) := -------------- + --------------- + --------------
                               2    1           2    1            2    1
                        (x - 1)  + ---   (x - 2)  + ----   (x - 3)  + ---
                                   100              1000              200
          (%i3) rombergtol : 1e-6;
          (%o3)                 9.9999999999999995E-7
          (%i4) rombergit : 15;
          (%o4)                          15
          (%i5) estimate : romberg (f(x), x, -5, 5);
          (%o5)                   173.6730736617464
          (%i6) exact : integrate (f(x), x, -5, 5);
          (%o6) 10 sqrt(10) atan(70 sqrt(10))
           + 10 sqrt(10) atan(30 sqrt(10)) + 10 sqrt(2) atan(80 sqrt(2))
           + 10 sqrt(2) atan(20 sqrt(2)) + 10 atan(60) + 10 atan(40)
          (%i7) abs (estimate - exact) / exact, numer;
          (%o7)                7.5527060865060088E-11

A 2-dimensional integration, implemented by nested calls to romberg.

          (%i1) load (romberg);
          (%o1)    /usr/share/maxima/5.11.0/share/numeric/romberg.lisp
          (%i2) g(x, y) := x*y / (x + y);
                                              x y
          (%o2)                   g(x, y) := -----
                                             x + y
          (%i3) rombergtol : 1e-6;
          (%o3)                 9.9999999999999995E-7
          (%i4) estimate : romberg (romberg (g(x, y), y, 0, x/2), x, 1, 3);
          (%o4)                   0.81930239628356
          (%i5) assume (x > 0);
          (%o5)                        [x > 0]
          (%i6) integrate (integrate (g(x, y), y, 0, x/2), x, 1, 3);
                                                    3
                                              2 log(-) - 1
                              9                     2        9
          (%o6)       - 9 log(-) + 9 log(3) + ------------ + -
                              2                    6         2
          (%i7) exact : radcan (%);
                              26 log(3) - 26 log(2) - 13
          (%o7)             - --------------------------
                                          3
          (%i8) abs (estimate - exact) / exact, numer;
          (%o8)                1.3711979871851024E-10

There are also some inexact matches for romberg. Try ?? romberg to see them.

(%o1)                                true
(%i2) 

Romberg Example

Related Examples

romberg

romberg(1/(x*x+1),x,-...

Calculate

romberg

romberg (x^2/(2*(2^.5...

Calculate

romberg

romberg (e^x, x, 0, 5);

Calculate

romberg

romberg(ln(x^2),x,-5,...

Calculate

romberg

romberg (x^2/(2*(2^.5...

Calculate

romberg

romberg (x^2/(2*(2^.5...

Calculate

romberg-sqrt-tan

h=0.15;

b=0.5;

I=b*h^3/12;

Calculate

romberg-sqrt-tan

h=0.15;

b=0.5;

I=b*h^3/12;

Calculate

romberg

romberg (e^(-x^2),x,0...

Calculate

romberg-sin

romberg(sin(x^2),x,-1...

Calculate