Use SCaVis to perform numeric integration. SCaVis contains several Java libraries to do this.
In addition to the above, SCaVis has several classes to perform integration. They are based on
jhplot.F1D class. Let us give a small example showing how to integrate <m>cos(x)^3</m> using a trapezium rule.
We will integrate this function between 1 and 10 using 10k iterations.
from jhplot import F1D f1=F1D('cos(x)^3') print f1.integral(10000,1,10)
The output is “-1.13321491381”.
Let us perform integration of a function <m>sin(1.0/x)*x^2+10*cos(x)^3</m> using 5 alternative methods: Gauss4, Gauss8, Richardson, Simpson, Trapezium. The code that does a benchmark of all 5 methods is given below:
The output of the above code is:
gauss4 = 49.1203116758 time (ms)= 155.088374 gauss8 = 49.1203116758 time (ms)= 57.245523 richardson = 49.1203116758 time (ms)= 53.369496 simpson = 49.1203116758 time (ms)= 27.088362 trapezium = 49.1203116663 time (ms)= 20.023047
The Jas integration package allows integration of rational functions.
In mathematics, a rational function is any function which can be defined by a rational fraction, i.e. an algebraic fraction such that both the numerator and the denominator are polynomials. The coefficients of the polynomials need not be rational numbers, they may be taken in any field K. In this case, one speaks of a rational function and a rational fraction over K. The values of the variables may be taken in any field L containing K.
Thus, a function is called rational if it is written as , where A and B are polynomials. In this section we will show how to integrate rational functions symbolically.
The answer is:
A=x^7 - 24 x^4 - 4 x^2 + 8 x - 8 B=x^8 + 6 x^6 + 12 x^4 + 8 x^2 Result: [1 , x, 6 x, x^4 + 4 x^2 + 4 , ( -1 ) x + 3 , x^2 + 2 ] , [0, 1 , x]