1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="intg" xml:lang="en">
16 <refname>intg</refname>
17 <refpurpose>definite integral</refpurpose>
20 <title>Calling Sequence</title>
21 <synopsis>[v,err]=intg(a,b,f [,ea [,er])</synopsis>
24 <title>Arguments</title>
29 <para>real numbers.</para>
35 <para>external (function or list or string).</para>
41 <para>real numbers.</para>
47 <para>absolute error required on the result. Default value:
55 <para>relative error required on the result. Default value:
63 <para>estimated absolute error on the result.</para>
69 <title>Description</title>
71 <literal>intg(a,b,f)</literal> evaluates the definite integral from
72 <literal>a</literal> to <literal>b</literal> of <literal>f(t)dt</literal>.
73 The function <literal>f(t)</literal> should be continuous.
75 <para>The evaluation hopefully satisfies following claim for accuracy:
76 <literal>abs(I-v)<= max(ea,er*abs(I))</literal> where
77 <literal>I</literal> stands for the exact value of the integral.
80 <literal>f</literal> is an external :
83 If <literal>f</literal> is function its definition must be as
84 follows <literal> y = f(t) </literal>
87 If <literal>f</literal> is a list the list must be as follows:
88 <literal> list(f,x1,x2,...)</literal> where <literal>f</literal> is a
89 function with calling sequence <literal>f(t,x1,x2,...)</literal>.
92 If <literal>f</literal> is a string it refers to the name of a
93 Fortran function or a C prodedure with a given calling sequence:
96 In the fortran case the calling sequence should be <literal>double
97 precision function f(x)
99 where <literal>x</literal> is also a
100 double precision number.
103 In the C case the calling sequence should be <literal>double
110 <title>Examples</title>
111 <programlisting role="example"><![CDATA[
112 // Function written in the Scilab language
113 function y=f(x),y=x*sin(30*x)/sqrt(1-((x/(2*%pi))^2)),endfunction
118 // Function with an argument written in the Scilab language
119 function y=f1(x,w),y=x*sin(w*x)/sqrt(1-((x/(2*%pi))^2)),endfunction
120 I=intg(0,2*%pi,list(f1,30))
124 // Function written in Fortran (a Fortran compiler is required)
125 // define a Fortran function
127 F=[' double precision function ffun(x)'
128 ' double precision x,pi'
129 ' pi=3.14159265358979312d+0'
130 ' ffun=x*sin(30.0d+0*x)/sqrt(1.0d+0-(x/(2.0d+0*pi))**2)'
133 mputl(F,fullfile(TMPDIR,'ffun.f'))
135 // compile the function
136 l=ilib_for_link('ffun',fullfile(TMPDIR,'ffun.f'),[],'f');
138 // add the function to the working environment
141 // integrate the function
142 I=intg(0,2*%pi,'ffun')
145 // Function written in C (a C compiler is required)
146 // define a C function
147 C=['#include <math.h>'
148 'double cfun(double *x)'
150 ' double y,pi=3.14159265358979312;'
152 ' return *x*sin(30.0e0**x)/sqrt(1.0e0-y*y);'
154 mputl(C,fullfile(TMPDIR,'cfun.c'))
156 // compile the function
157 l=ilib_for_link('cfun',fullfile(TMPDIR,'cfun.c'),[],'c');
159 // add the function to the working environment
162 // integrate the function
163 I=intg(0,2*%pi,'cfun')
167 <refsection role="see also">
168 <title>See Also</title>
169 <simplelist type="inline">
171 <link linkend="intc">intc</link>
174 <link linkend="intl">intl</link>
177 <link linkend="inttrap">inttrap</link>
180 <link linkend="intsplin">intsplin</link>
183 <link linkend="ode">ode</link>
188 <title>Used Functions</title>
189 <para>The associated routines can be found in SCI/modules/differential_equations/src/fortran directory
192 <para>dqag0.f and dqags.f from quadpack</para>