Menu

Numeric evaluation of embedded integration/differentiation

Jim Bowery
2015-11-26
2015-12-16
  • Jim Bowery

    Jim Bowery - 2015-11-26

    Is there any way of applying the romberg (or other numeric) method to a definite integral embedded in an expression?

    When wxMaxima fails to find a closed form solution, as in:

    f(x):=sin(%e^x)/x^2;
    integrate(f(x),x,1,2);

    one is left with an expressioin that includes the integrate symbol with the definite integral bounds.

    Of course, if one attempts:

    romberg(%);

    one gets the error message:

    romberg: wrong number of arguments.

    rather than the desired:

    romberg(f(x),x,1,2);
    −0.14527907494713

     

    Last edit: Jim Bowery 2015-11-26
  • Ago77

    Ago77 - 2015-12-15

    load(romberg)$
    f(x):=sin(%e^x)/x^2$
    romberg(f(x), x, 1, 2);

     
  • Franz Graf

    Franz Graf - 2015-12-15

    f(x):=sin(%e^x)/x^2;
    integrate(f(x),x,1,2);
    apply(romberg, args(%));

    Does this do what you want? However, romberg must have been loaded. Otherwise:

    a: args(%);
    load(romberg);
    apply(romberg, a);

     
  • Studs Kreitzer

    Studs Kreitzer - 2015-12-16

    That's a beautiful solution, Franz. If one were going to use it repeatedly, then it might even be phrased as a function to save some typing:

    numeric(x):=apply(romberg,args(x));

    After a symbolic integration fails, then one could simply type:

    numeric(%)

    By the way, in the Windows version, I find that romberg() is loaded by default, cutting down even further on the typing.