Square pulse function?



On 2008-05-29 20:03:54 +0100, Jaime Villate <villate at fe.up.pt> said:
> 
> (%i16) g(t):= (signum(t+1/2)-signum(t-1/2))/2$
> (%i17) g(-0.6);
> (%o17)                       0
> (%i18) g(0.1);
> (%o18)                       1
> (%i19) g(0.6);
> (%o19)                       0
> (%i20) quad_qags(f(t),t,0,3);
> (%o20) [.5000000000000001, 5.551115123125784e-16, 273, 0]
> (%i21) quad_qags(f(t),t,-3,3);
> (%o21)      [1.0, 1.110223024625157e-15, 567, 0]
> (%i22) quad_qags(f(t),t,3,6);
> (%o22)               [0.0, 0.0, 21, 0]
> 
> The result of the integral is the first element in the list returned by
> quad_qags. integrate does not work because it tries to find the
> indefinite integral first, to calculate the definite integral. quad_qags
> uses an approximate numerical method.

Okay thanks, I'll read up on the QUAD package.

> The g(x) above is equal to 1/2 in t=+-1/2, and not 1 as you wanted.
> unit_step could be used instead of signum, but quad_qags doesn't work
> with unit_step.

I didn't know unit_step existed (so much to learn in Maxima!). Strange 
that it doesn't seem to evaluate numerically though, e.g.
(%i35) unit_step(0.5), numer;
(%o35)                          unit_step(0.5)

Regards,
Paul