-----Original Message-----
From: Mark H Weaver
Sent: Sunday, February 27, 2011 2:34 PM
To: maxima at etherjones.us
Cc: maxima at math.utexas.edu
Subject: Re: [Maxima] numerical integration of IF() function
Ether Jones <maxima at etherjones.us> writes:
> How do I tell maxima that I want a numerical answer to this?
>
> -------------begin----------------
> pulse: IF(x<0.1,1,0)$
> quad_qags(pulse,x,0,1);
> quad_qags(IF(x<0.1,1,0),x,0,1,epsrel=1.0*10^-8,epsabs=0.0,limit=200)
> -----------end--------------------
In Maxima, the syntax you want is:
if x<0.1 then 1 else 0
(%i1) display2d:false$
(%i2) pulse(x) := if x<0.1 then 1 else 0;
(%o2) pulse(x):=if x < 0.1 then 1 else 0
(%i3) quad_qags(pulse,x,0,1);
(%o3) [0.1,1.1102230246251565E-16,441,0]
(%i4) quad_qags(if x<0.1 then 1 else
0,x,0,1,epsrel=1.0*10^-8,epsabs=0.0,limit=200);
(%o4) [0.1,1.1102230246251565E-16,441,0]
Alternatively, if you define pulse in terms of the unit_step function,
then with the help of the abs_integrate package, you can integrate pulse
symbolically:
There is another alternative. If you are working with pulse functions,
there is a third party package available from the Maxima web site that has a
unit_pulse() function which can be integrated, differentiated and etc...
The package is called pw.mac. It can handle math for piecewise functions
hence the name pw. In pw.mac you could do it this way without having to
define the pulse function.
load(pw);
pwint(piecewise([0,1,.1], x),x);
Admittedly this requires learning the piecewise() function in pw.mac
(pwint() is just piecewise integrate) but there is help available.
you could also use the unit_pulse() function directly like this
load(pw);
pwint(unit_pulse(x/10), x),x);
Try this site. It has links to the help and source code of pw.mac.
http://maxima-project.org/wiki/index.php?title=Pw.mac
Rich