rational in funcs.mac doesn't appear to work. For instance "rational((3+2*%i)/(1+2*%i))" returns "(2*%i+3)/(2*%i+1)" This appears to be related to this:
(%i1) a:(1+2*%i)/(1+%i);
(%o1) (2*%i+1)/(%i+1)
(%i2) conjugate(ratdenom(a));
(%o2) conjugate(%i+1)
(%i3) ratsimp(%);
(%o3) 1-%i
conjugate appears to need an additional ratsimp. A fix for rational is to insert ratsimp, i.e. change
n:ratdisrep(ratnumer(z)*(cd:conjugate(d:ratdenom(z)))),
to
n:ratdisrep(ratnumer(z)*(cd:ratsimp(conjugate(d:ratdenom(z))))),
This probably just a kludge. Maybe conjugate is broken?
Barton Willis
2007-04-05
Logged In: YES
user_id=895922
Originator: NO
I think this is a bug in conjugate:
(%i1) rat(1+%i);
(%o1) %i+1
(%i2) conjugate(%);
(%o2) conjugate(%i+1) <-- should be 1-%i
(%i3) conjugate(1+%i);
(%o3) 1-%i
Barton Willis
2007-04-05
Logged In: YES
user_id=895922
Originator: NO
..and I think a fix is
(defun simp-conjugate (e f z)
(oneargcheck e)
(setq e (simplifya (specrepcheck (nth 1 e)) z))
...
Stavros Macrakis
2007-04-10
Logged In: YES
user_id=588346
Originator: NO
Problem was in conjugate, which didn't work for CRE arguments, e.g. conjugate(rat(%i)) => %i (!!!).
Put in simpcheck at top of simp-conjugate.
Fixed.
Stavros Macrakis
2007-04-10