[Maxima] About simpson and traprule funcions
Juan Pablo Romero Bernal
jromerobernal at gmail.com
Sun Mar 19 14:02:33 CST 2006
------=_Part_9685_25445427.1142798553444
Content-Type: multipart/alternative;
boundary="----=_Part_9686_10070391.1142798553445"
------=_Part_9686_10070391.1142798553445
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi all,
I have a question about the function simpson and traprule of the share
folder
(numeric section). I have an example:
(%i1) load("simpsn.mac");
(%o1) simpsn.mac
(%i2) simpson(x^2,0,5,7);
f evaluates to x^2
Improper name or value in functional position.
#0: simpson(f=3Dx^2,a=3D0,b=3D5,n=3D7)(simpson-max.mac line 6)
-- an error. Quitting. To debug this try debugmode(true);
I don't understand this behavior. The same way, i get an error with
the function traprule with several functions. Some explain about this ??
(in the documentation files don't exists information).
However, i have re-written the code of simpson and traprule functions. I
send an
attach file.
The code has been "tested" in the CVS version under CLisp and Debian
GNU/Linux Sarge.
Bye,
Juan Pablo Romero Bernal
Grupo Linux Universidad Distrital - Linux Group Distrital University
Universidad Distrital Francisco Jose de Caldas
Bogota - Colombia
Visita el sitio del Software Libre en Colombia:
http://www.el-directorio.org
Visit the Free Software site in Colombia:
http://www.el-directorio.org
------=_Part_9686_10070391.1142798553445
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<font size=3D"2">
<p>Hi all,</p>
<p>I have a question about the function simpson and traprule of the share f=
older</p>
<p>(numeric section). I have an example:</p>
<p>(%i1) load("simpsn.mac");</p>
<p>(%o1) simpsn.mac</p>
<div>(%i2) simpson(x^2,0,5,7);</div>
<div> &nbs=
p; &=
nbsp; </div>
<p>f evaluates to x^2</p>
<p>Improper name or value in functional position.</p>
<p>#0: simpson(f=3Dx^2,a=3D0,b=3D5,n=3D7)(simpson-max.mac line 6)</p>
<p>-- an error. Quitting. To debug this try debugmode(true);</p>
<p>I don't understand this behavior. The same way, i get an error with </p>
<p>the function traprule with several functions. Some explain about this ??=
</p>
<p>(in the documentation files don't exists information). </p>
<div>However, i have re-written the code of simpson and traprule functions.=
I send an </div>
<div>attach file. </div>
<div> </div>
<div>The code has been "tested" in the CVS version under CLisp an=
d Debian GNU/Linux Sarge.</div>
<p>Bye, </p>
<p>Juan Pablo Romero Bernal</p>
<p>Grupo Linux Universidad Distrital - Linux Group Distrital University </p=
>
<p>Universidad Distrital Francisco Jose de Caldas</p>
<p>Bogota - Colombia</p>
<p> </p>
<p>Visita el sitio del Software Libre en Colombia: </p>
<p><a href=3D"http://www.el-directorio.org">http://www.el-directorio.org</a=
></p>
<p>Visit the Free Software site in Colombia: </p>
<p><a href=3D"http://www.el-directorio.org">http://www.el-directorio.org</a=
></p></font>
------=_Part_9686_10070391.1142798553445--
------=_Part_9685_25445427.1142798553444
Content-Type: application/octet-stream; name=simpsn.mac
Content-Transfer-Encoding: 7bit
X-Attachment-Id: f_ekzsqjlc
Content-Disposition: attachment; filename="simpsn.mac"
traprule(f,var,a,b,n):=
if(is(a >= b)) then false
else((b-a)/n*((subst(a,var,f) + subst(b,var,f))/2 +
sum(subst(a+(i*(b-a)/n),var,f),i,1,n-1)))$
simpson(f,var,a,b,n):=
if(is(a >= b) or oddp(n)) then false
else((b-a)/n/3 * (subst(a,var,f)+subst(b,var,f) +
4*sum(subst(a+(b-a)/n*(2*i-1),var,f),i,1,n/2) +
2*sum(subst(a+(b-a)/n*(2*i),var,f),i,1,(n-2)/2)))$
------=_Part_9685_25445427.1142798553444--
More information about the Maxima
mailing list