I have a number of expressions that should evaluate to zero, but remain as, e.g. abIc-Iacb.
Even if I algsubs abc=1
, it remains I-I for calls to eval, evala, or evalc. What am I
missing?
Could it be that you just forgot the multiplication operator *
which is necessary for the
Maple input but does not appear in the prettyprinted output?
> a*b*I*c-I*a*c*b; 0
It looks like you have returned a local variable from a procedure:
> restart; > f:=proc(a,b,c) local I; a*b*I*c-sqrt(-1)*a*c*b end: > f(a,b,c); a b I c - I a c b > eval(%),evala(%),evalc(%); a b I c - I a c b, a b c (I - I), a b I c - I a c b > subs({a=1,b=1,c=1},%%); I - I
The manipulations involved pages of equations, but I did finally track down the problem. One of the elements involved an alias which contained an expression defined in terms of what was intended to be the imaginary number ’I’. A greatly simplified equivalent would be:
restart; alias(y=I*x); z:=I*x; f:=diff(y,x)-diff(z,x);
Beware the aliased alias!
To understand the problem, try the following:
> alias(y=I*x); > z:=I*x; > z; > diff(y,x)-diff(z,x); I - I > simplify(%); I - I > a1:=diff(y,x); a1 := I > whattype(%); symbol
Here I is only a symbol , not an alias !!!!
Maple help writes:
When alias is called, the equations are evaluated from left to right but are not subjected to any existing aliases. This means that you cannot define one alias in terms of another.
But using I in the above equation you defined one alias in terms of another.
> a2:=diff (z,x); a2 := I > whattype(%); ^ > a1-a2;; I - I > whattype(%); + > alias(v=sqrt(-1)*x); > a3:=diff(v,x); a3 := I > whattype(a3); ^ > a2-a3; 0