From: Barton W. <wi...@un...> - 2024-11-28 12:06:16
|
Hi, I think your examples are simple enough that you could do the calculations by hand. Likely, that approach would give you the simplest answers; for example, since f vanishes outside [0,1] and is one inside, we have integrate(f(t)*g(x-t), t, -2, +2) = integrate(g(x-t), t, 0,1) Now all you need is an antiderivative of g and you are done. And an antiderivative of g can be found by integrating each piece and choosing the constants of integration to make a continuous function. But maybe your aim is to integrate some more complicated piecewise defined functions. Maxima has a share package that attempts to integrate expressions that can be expressed in terms of signum functions. For your examples: (%i1) load(abs_integrate)$ (%i2) f(x) := (signum(x) - signum(x-1))/2$ (%i3) g(x) := x*f(x)$ (%i4) integrate(f(x),x,-2,4); (%o4) 1 (%i5) integrate(f(t)*g(x-t), t, -2, 2); (%o5) (x^2*signum(x)-3*signum(x-1)*x^2+2*signum(x-2)*x^2+4*signum(x-1)*x-4*signum(x-2)*x+signum(x-1)*(x-1)^2-signum(x-2)*(x-1)^2- signum(x-1)+signum(x-2))/4 Let us know if you have questions. But I have a turkey and a sweet potato casserole to bake this morning, so till later... --Barton ________________________________ From: Jaime Villate via Maxima-discuss <max...@li...> Sent: Thursday, November 28, 2024 01:51 To: Eduardo Ochs <edu...@gm...>; max...@li... <max...@li...> Subject: Re: [Maxima-discuss] Integrating piecewise defined functions Caution: Non-NU Email 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 |