From: Barton W. <wi...@un...> - 2024-03-15 22:17:34
|
Here is a way to the simplification unit_step(X) + unit_step(-X) --> 1 without using matchdeclare. This simplification is OK for X real and nonzero. Maybe the freeof(x,ax) check isn't wanted. (%i1) load("opsubst")$ (%i2) unit_step_reduce(e,x) := block([a : gatherargs(e,'unit_step)], for ax in a do ( ax : first(ax), if equal(imagpart(ax),0) and not freeof(x,ax) then ( e : ratsubst(1, unit_step(ax)+unit_step(-ax),e))), e)$ OK: (%i13) unit_step_reduce(x+unit_step(x) + unit_step(-x),x); (%o13) x+1 OK: (%i14) unit_step_reduce(x + unit_step(x) + unit_step(-x),z); (%o14) unit_step(x)+x+unit_step(-x) Not wrong, but maybe not what you all want: (%i15) unit_step_reduce(x + 5*unit_step(x) - unit_step(-x),x); (%o15) 6*unit_step(x)+x-1 --Barton ________________________________ From: Majzoub, Eric <eri...@um...> Sent: Friday, March 15, 2024 15:57 To: rob...@gm... <rob...@gm...> Cc: max...@li... <max...@li...> Subject: Re: [Maxima-discuss] fourie.mac package fails for simple square wave Caution: Non-NU Email Hi Robert: Thanks for the reply. I tried using tellsimpafter by itself and your suggestion with matchdeclare as well. But the code in fourie.mac still returns the wrong answer -- the coefficients are returned as functions of x, which should integrated out. In any case, the pdefourier package works and there is code infrastructure for piecewise continuous functions there. -Eric _______________________________________________ Maxima-discuss mailing list Max...@li... https://lists.sourceforge.net/lists/listinfo/maxima-discuss |