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:
(%i5) load(abs_integrate);
(%o5) "/usr/local/share/maxima/5.23.2/share/contrib/integration/abs_integrate.mac"
(%i6) pulse(x) := unit_step(x) - unit_step(x-0.1);
(%o6) pulse(x):=unit_step(x)-unit_step(x-0.1)
(%i7) integrate(pulse(x),x,0,1);
rat: replaced -0.1 by -1/10 = -0.1
rat: replaced -0.1 by -1/10 = -0.1
rat: replaced -0.1 by -1/10 = -0.1
rat: replaced 0.0 by 0/1 = 0.0
rat: replaced 0.9 by 9/10 = 0.9
(%o7) 1/10
Mark