From: Eduardo O. <edu...@gm...> - 2024-11-28 11:56:20
|
On Thu, 28 Nov 2024 at 04:51, Jaime Villate <vi...@fe...> wrote: > > On 27/11/24 21:56, Eduardo Ochs wrote: > > Hi list, > > what is the recommended way to integrate piecewise defined > functions? I tried this, > > f(x) := if x<0 then 0 > elseif x<1 then 1 > else 0; > g(x) := if x<0 then 0 > elseif x<1 then x > else 0; > h(x) := integrate(f(t)*g(x-t), t, -2, +2); > > and I couldn't find a way to make Maxima calculate this > integral... > > Hello Eduardo, > > If you mean the convolution of f and g: > > h(x) := integrate(f(x)*g(x-t), t, 0, x) > > I recommend that you use Laplace transforms and expressions, rather than > "functions": > > f: hstep (x) - hstep (x-1); > g: (hstep (x) - hstep (x-1))*x; > F: laplace (f,x,s); > G: laplace (g,x,s); > H: F*G; > h: pwilt (H,s,x); > plot2d ([f,g,h], [x,-2,2], [legend,"f(x)","g(x)","h(x)"]); > > Cumprimentos, > > Jaime > Hola Jaime! Thanks! Excellent modulo a bug, that may be between keyboard and chair or not... I was expecting h(x)=0 for x<=0, and according to the plot we got h(x)=x^2/2 for x<=0. What is going on? Thanks in advance, Eduardo (who has used LTs very little =( ) |