You are a guest. Restricted access. Read more.

# Integration

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 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 using 5 alternative methods: Gauss4, Gauss8, Richardson, Simpson, Trapezium. The code that does a benchmark of all 5 methods is given below:

You have a limited access to this code example. One can unlock this code example after becoming a full member.

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```

# Integrating rational functions

The Jas integration package allows integration of rational functions.

Snippet from Wikipedia: Rational function

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 $A(x)/B(x)$, where A and B are polynomials. In this section we will show how to integrate rational functions symbolically.

You have a limited access to this code example. One can unlock this code example after becoming a full member.

```A=x^7 - 24 x^4 - 4 x^2 + 8 x - 8