leftimage for poohprod.ru

Integral Calculator using Scilab

We can use Scilab as a definite integral calculator. The numerical integration of functions in one dimension can be performed with intg(a, b, f) and it’s very easy to use. First, we define the function to integrate...

In this example,
we define it in a single line, but it can also be defined by writing a separate file and uploading it. Second, we call intg with the limits of the integral. If the function has other arguments besides the variable of integration, you can use a list. This definite integral:

an integral to illustrate Scilab's capabilities

Can be calculated in Scilab, like this, in two lines:

function y = f(x), y = exp(-x^2), endfunction
I = intg(1/2, 3/2, f)

and the answer is I = 0.3949074

Notice that we can define the function to be integrated in just one line, if the function is simple. We can also use the function deff for the definition of the function, like this:

deff('y = f(x)', 'y = exp(-x^2)')

Integration with Matlab

If we happen to need the integration of this other function, where we have to calculate the absolute value of the sine function, from –pi to pi radians

integrating a function with Scilab

we can calculate it like this

function y = f1(x), y = abs(sin(x)), endfunction
I = intg(-%pi, %pi, f1)

and the answer is I = 4

There are specialized functions to integrate 2D and 3D. As usual, the best reference for the syntax and examples is the online help. Just type "help" (or "help function" without quotes) on your command window.

Function int2d uses an adaptive algorithm in which if a function is rapidly changing, it is divided into finer grids and the integral is recalculated until a convergence is achieved. These type of algorithms are included in many of Scilab’s (or Scicoslab’s) built-in functions such as intg or integrate.

For example
, the function int2d performs definite two-dimensional integrals by the quadrature and cubature methods. The calling sequence is

[I, err] = int2d(X, Y, f [,params])

The region of integration is determined by a series of triangles whose vertices are passed through two matrices (X and Y). These vectors have dimension 3xN, where N is the number of triangles and indicates each coordinate of the vertices of the triangles.

The following example computes the integrand over the two triangles with coordinates (0, 0), (5, 5), (5, 0) and (0, 0), (0, 5) and (5, 5). This describes the rectangle from (0, 0) to (5, 5) and parallel lines to the axes.

double integral with Scilab

X = [0 0; 5 5; 5 0];
Y = [0 0; 0 5; 5 5];
function z = f(x, y), z = cos(x + y), endfunction
[I, error] = int2d(X, Y, f)

the result is

error = 1.078D-09
I = 0.4063959

From 'Integral Calculator' to Matlab home

From 'Integral Calculator' to Scilab menu


footer for integral calculator page

Related pages

scilab to matlab conversionconverting between polar and cartesian coordinatessum to infinity formulaformula for charging a capacitorquadratic equation c programming codematlab tutorial for engineerspermutation combination calculatorquadratic equation calcresistor colour code calculator downloadsimpson rule calculatormatlab plot boxscrap car value calculatorcartesian to polar convertertrapezoid functioncalculate scrap value of cartransients in rc circuitscalculating bmi manuallycalculate pythagorasquad function matlabhow do you convert binary to hexadecimalgetframe matlabalgorithm for pascal trianglecapacitor charging and discharging graphlinear algebra in matlabmaclaurin series cos xascii characters chartmatlab function declarationcompound interest calculator spreadsheetexamples of concentric circlesgauss jordan matrix inversiondefinition of impulse functionmatlab to java convertercalculus integration calculatorsolve matlab equationcreating a function in matlabformula for simple interest loanmortgage amortisationhow to draw a piecewise functionmatlab sinprogram to find pascal triangle in cleast squares fitting matlabhexadecimal to decimal methodpythagorean calculatormaclaurin sinxdefinition of periodic functionfit straight line matlabconverter octal to decimaldecimal to gray code convertersalvage title car value calculatorletter a in asciinormal distribution plot matlabmatlab factorial functionarea of irregular polygon calculatorhow to draw piecewise functionsascii code of letterseuclidean algorithm for gcfmatlab tutorial basicssawtooth fourierfind the sum of the given infinite geometric seriesfactorial program using functionhow to draw a 3d cuboidlinear regression code matlabascii values for alphabetspascal's triangle solverdraw circle matlabcallback function matlabwhile loop in matlab examples4 band resistor codeoctal to binary conversionlagrange matlabmatlab permutationmatlab gui tutorial for beginnerschi square matlabfourier series matlab code