Menu

#4503 rectform operates on lists differently from polarform

None
open
nobody
None
5
2025-02-24
2025-02-24
No

rectform operates on a list by computing two lists - one containing all real parts, one containing all imaginary parts - and then combining them using list arithmetic. But it doesn't bind $listarith to t, so the result depends on $listarith.

polarform, on the other hand, checks for "mbags" and uses (mapcar #'$polarform ...) to create a bag containing the polar form of each element.

(%i1) rectform([1,2,3]), listarith:true;
(%o1)                              [1, 2, 3]
(%i2) rectform([1,2,3]), listarith:false;
(%o2)                      [1, 2, 3] + %i [0, 0, 0]
(%i3) polarform([1,2,3]), listarith:true;
(%o3)                              [1, 2, 3]
(%i4) polarform([1,2,3]), listarith:false;
(%o4)                              [1, 2, 3]

Maybe this is by design, but it's not documented.

Discussion

  • Stavros Macrakis

    rectform's approach also ends up calling risplit twice on the same argument!

     
    • David Scherfgen

      David Scherfgen - 2025-02-24

      Hmm, I don't see that when I trace risplit:

      (%i1) :lisp (trace risplit)
      (RISPLIT)
      
      (%i1) rectform([1,%i]);
        0: (MAXIMA::RISPLIT ((MAXIMA::MLIST MAXIMA::SIMP) 1 MAXIMA::$%I))
          1: (MAXIMA::RISPLIT 1)
          1: RISPLIT returned (1 . 0)
          1: (MAXIMA::RISPLIT MAXIMA::$%I)
          1: RISPLIT returned (0 . 1)
        0: RISPLIT returned (((MLIST SIMP) 1 0) (MLIST SIMP) 0 1)
      (%o1)                               [1, %i]
      
       
      • Stavros Macrakis

        oops

         

Log in to post a comment.