Hi to all:
Suppose that I have a piecewise-defined function on [-l,l] (in this
example, l=%pi):
(%i1) h(x):=if (x>=-%pi and x<0) then x+%pi elseif (x>=0 and x<%pi) then
%pi-x$
Suppose also that I want to know if it is even. I can do the following
to extract the right extremum l (I think this should be always valid for
any function defined piecewise "from left to right"):
(%i2) l:part(h(x),length(h(x))-3,2,2);
(%o2) %pi
then:
(%i3) assume(0<z and z<l);
(%o3) [z>0,z<%pi]
and finally
(%i4) is(equal(h(-z),h(z)));
(%o4) true
which tells me that it is an even function. If I try to store these
steps in a function like this:
(%i5) paridad(f):=
block(
l:part(f,length(f)-3,2,2),
assume(0<z and z<l),
is(equal(f(-z),f(z)))
)$
then what I get is
(%i6) paridad(h(x));
(%o6) apply: found f evaluates to if x>=-%pi and x<0 then x+%pi elseif
x>=0 and x<%pi then %pi-x where a function was expected.
#0: paridad(f=if x >= -%pi and x < 0 then x+%pi elseif x >= 0 and x <
%pi then %pi-x)
-- an error. To debug this try: debugmode(true);
This is strange to me: "found f evaluates to if x>=-%pi and x<0 then
x+%pi elseif x>=0 and x<%pi then %pi-x", so f evaluates to a function of
x, but then what does it mean "where a function was expected"?.
Cheers,
J. A.