Menu

#2514 Taylor result inconsistent T/x^2 vs. T/x/x

None
open
nobody
taylor (27)
5
2012-12-14
2012-12-07
No

taylor(x,x,0,5)/x^2 => 1/x+...
Internally: ((MRAT SIMP ($X) (#:X1942) (($X ((5 . 1)) 0 NIL #:X1942 . 1)) TRUNC) PS
(#:X1942 . 1) ((3 . 1)) ((-1 . 1) 1 . 1))

(taylor(x,x,0,5)/x)/x => 1/x (without ellipses)
Internally: ((MRAT SIMP ($X) (#:X1945) (($X ((5 . 1)) 0 NIL #:X1945 . 1)) TRUNC) PS
(#:X1945 . 1) * (NIL) * ((-1 . 1) 1 . 1))

taylorinfo of both expressions remains [[x,0,5]]

Versions: 5.27.0 2012-04-30 11:59:06 i686-apple-darwin11.3.0 SBCL 1.0.55.0-abb03f9

Discussion

  • Rupert Swarbrick

    When dividing twice by x the result is, as you say:

    ((MRAT SIMP ($X) (#:X1461) (($X ((5 . 1)) 0 NIL #:X1461 . 1)) TRUNC) PS
     (#:X1461 . 1) (NIL) ((-1 . 1) 1 . 1))
    

    Printing is done by FORM-MRAT, which decides the result is "exact"
    (because of the NIL) and intentionally doesn't print a trailing ...

    Another way to get the same result is:

    taylor(1, x, 0, 5) / x;
    
     
  • Rupert Swarbrick

    Something that definitely appears wrong shows up when you trace
    TAYLOR2 in the division taylor(1, x, 0, 5) / x;:

    0: (TAYLOR2
        ((MTIMES)
         ((MRAT SIMP ($X) (#:X1480) (($X ((5 . 1)) 0 NIL #:X1480 . 1)) TRUNC) 1
          . 1)
         ((MEXPT SIMP) $X -1)))
    0: TAYLOR2 returned (PS (#:X1481 . 1) (NIL) ((-1 . 1) 1 . 1))
    

    The (NIL) is "<trunc-lvl>" as explained in the comment at the top of
    hayat.lisp and I think it should probably be set to ((4 . 1)) not
    NIL!

    Digging into TAYLOR2, and tracing TSTIMES, this looks pretty bogus:

    1: (TSTIMES
        (((MRAT SIMP ($X) (#:X1480) (($X ((5 . 1)) 0 NIL #:X1480 . 1)) TRUNC) 1
          . 1)
         ((MEXPT SIMP) $X -1)))
      2: (TAYLOR2 ((MEXPT SIMP) $X -1))
      2: TAYLOR2 returned (PS (#:X1485 . 1) (NIL) ((-1 . 1) 1 . 1))
      2: (TAYLOR2
          ((MRAT SIMP ($X) (#:X1480) (($X ((5 . 1)) 0 NIL #:X1480 . 1)) TRUNC)
           1 . 1))
        3: (TAYLOR2 1)
        3: TAYLOR2 returned (1 . 1)
      2: TAYLOR2 returned (1 . 1)
      2: (TAYLOR2 ((MEXPT SIMP) $X -1))
      2: TAYLOR2 returned (PS (#:X1485 . 1) (NIL) ((-1 . 1) 1 . 1))
    1: TSTIMES returned (PS (#:X1485 . 1) (NIL) ((-1 . 1) 1 . 1))
    

    Basically, I think the second call to TAYLOR2 should probably result
    in something like

    (PS (#:X1485 . 1) ((5 . 1)) (1 . 1))
    

    which would say "This is a power series in X, which is 1 up to
    x^5". If something like this doesn't get returned, there's no way for
    the following code to work out the truncation order.

     

Log in to post a comment.