Jean-Marc Sac-Epée on Fri, 03 Nov 2000 10:37:24 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Integrating functions


Thanks to your help, I know now how to integrate a function  using
intnum0:

> #include <math.h>
> #include <stdio.h>
> #include <pari.h>
>
> GEN integrate(char *f, char *var, GEN a, GEN b, long prec)
> {
>   entree *ep_var = is_entry(var);
>   return intnum0(ep_var, a,b, f, 0,prec);
> }
>
> int
> main()
> {
>   pari_init(1000000,2);
>   output(integrate("x^2+3", "x", gzero, gun, DEFAULTPREC));
>   return 0;
> }

Now, I would like to know if it is also possible with more complicated
fonctions. For example, it is easy to prove that for each t>0, the
polynomial 10*x^5 + 0.1*x^3 - t*x^2 - t has a unique real root. So, we
can define the fonction f: t -> this real root.

Under gp, it is easy to integrate this function;
? f(t)=real(polroots(10*x^5+0.1*x^3-t*x^2-t)[1])
? intnum(t=0,1,f(t))

In a C program, I can define this fonction for example with

GEN f(GEN t)
{
 const long var = 0;
 const long prec = 4;
 GEN pol;
 pol = cgetg(deg+3,t_POL);
 pol[1] = evalsigne(1) | evalvarn(var) | evallgef(deg+3);
 pol[deg+2]=dbltor(10); pol[deg]=dbltor(0.1);
 pol[deg+1]=pol[deg-2]=gzero;
 pol[deg-1]=pol[deg-3]=gneg(t);
 return(greal(roots(pol,prec)[1]));
}

But now, what is the correct syntax to integrate f?

Thank you for your help,

J.-M.



begin:vcard 
n:Sac-Epée;Jean-Marc 
tel;fax:03 87 31 52 73
tel;work:03 87 54 72 69
x-mozilla-html:FALSE
url:http://www.mmas.univ-metz.fr/~jmse
org:Université de Metz;Mathématiques
adr:;;;;;;
version:2.1
email;internet:jmse@poncelet.univ-metz.fr
title:Ingénieur de Recherches
x-mozilla-cpt:;0
fn:Jean-Marc Sac-Epée
end:vcard