[Scilab-users] "intg" and i"ntegrate"

Samuel Gougeon sgougeon at free.fr
Mon Feb 26 11:52:42 CET 2018


Hello Fujimoto2005,

Le 22/02/2018 à 14:19, fujimoto2005 a écrit :
> I want to integrate a user function f(x,y1,y2) from a to b with respect to x.
>
> 1, I don't see the difference between "integrate" and "intg". I saw help
> file and find "integrate" can manage multi upper limits.  Except it, I can't
> find any differences between two functions. Is there a difference in the
> accuracy or calculation method?

No, since integrate() actually calls intg() to proceed. integrate() is a 
wrapper for intg().

>   "intg" has a fixed number of partitions.

Its algorithm is adaptative. The partition is dynamically refined when 
some local variations of the function are detected and fast.

> Does "integrate" increase the
> number of partitions automatically until the accuracy is not improved?

Yes, since intg() does it and is called by integrate().

> I do not understand the difference with the help file.
> 2, I could use "intg" with "intg (a, b, list (f, y1, y2))", but I could't
> use "integrate" with "integrate (list ("f", y1, y2), "x", a, b)" or
> "integrate (list (f, y1, y2), "x", a, b)". What is wrong with the syntax?

You are right. This

integrate (list (f, y1, y2), "x", a, b)

syntax could be added. But it is possible to use "local" parameters, 
like this:

a = 3;
x1 = 0:0.1:2*%pi;
X = integrate('sin(a*x)', 'x', 0, x1);
// Checking
norm((1-cos(a*x1))/a -X)

--> norm((1-cos(a*x1))/a -X)
  ans  =
    2.491D-15

The only thing is that the name of "local" parameters must not collide 
an internal parameter of integrate:
--> edit integrate

The list() feature specific to intg() could be included into 
integrate().  Then intg() could be undocumented as an internal function 
of integrate(). If you agree and wish such a merge, would you mind 
filling in a wish report on Bugzilla?

Best regards
Samuel




More information about the users mailing list