The function paridad expects a function, but paridad(h(x)) provides
paridad with the formula for a function. Instead, try paridad(h).
This will work as you expect it once, but not twice. The reason for
the failure on the second attempt is that the assumption assume(0<z and z<l)
is made globally, not locally to paridad. After paridad is executed once,
h(z) simplifies to %pi-z.
The Maxima logical operators are not commutative (I think), so your part
statement works. But it's risky to rely on a user expressing the predicate
as (x>=0 and x<%pi) instead of the logically equivalent (x<%pi and x >=0).
--Barton
-----maxima-bounces at math.utexas.edu wrote: -----
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.
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima