Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1163 rational doesn't work

closed
5
2012-12-04
2007-04-05
No

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?

Discussion

  • Barton Willis
    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
    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))
    ...

     
  • 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.

     
    • status: open --> closed
    • labels: 460523 --> Lisp Core - Simplification
    • assigned_to: nobody --> macrakis