[ Home | GAUSS | GAUSS Engine | GAUSS Apps | 3rd Party Apps | Keywords Index ]

Analytical integration

This example shows how Symbolic Tools can use the Maple kernel to evaluate integrals analytically.

library symbolic; // define the library
call symstate(reset);

// turns on symbolic processing

// Integration
txt = " fn = 1/(1+x^2);
fint = intquad(fn,{x}); ";
//infinity norm

call symrun(txt);

fint = symget("fint"); // Still a symbol

"\n int(1/(1+x^2)) " fint;

call symput(1.5,"x");
fint_s = symget("fint"); // Now evaluated
fint_g = atan(1.5);
"\n fint_g fint_s: " fint_g~fint_s;

We want to integrate a function (1/(1+x^2)), and then evaluate the function at some point.  The GAUSS code to do this is put in a string (txt), and sent to the Maple kernel using the symrun command.  Note that we use the GAUSS command intquad to do the integration, but have extended the language to allow for symbols, which is shown in the second argument.  The symbolic integral is returned as a string (fint). The integral is evaluated in the kernel by specifying a numeric value for x, (using symput) and then returning the result in (fint_s) using symget.

The output from this example is :

int(1/(1+x^2)) arctan(x)
fint_g fint_s: 0.98279372 0.98279372