Menu

#4799 taylor contagion

None
open
nobody
None
5
1 day ago
4 days ago
No

Here are two examples where Taylor contagion fails:

(%i1)   xxx : exp(-(x-1)^2) - exp(-(x+1)^2);
(xxx)   %e^(-(x-1)^2)-%e^(-(x+1)^2)

(%i2)   substitute(x=taylor(x,x,inf,2),%);
Maxima encountered a Lisp error:

 The variable #:G530 is unbound.

Automatically continuing.

To enable the Lisp debugger set *debugger-hook* to nil.

And a similar case with an asksign:

(%i1)   zzz : exp(-(x-a)^2) - exp(-(x+a)^2);
(zzz)   %e^(-(x-a)^2)-%e^(-(x+a)^2)
(%i2)   substitute(x=taylor(x,x,inf,2),zzz);
"Is "a" positive, negative or zero?"z;
debugger invoked on a SIMPLE-CONDITION in thread

#<THREAD tid=8388 "main thread" RUNNING {1100038003}>:

  bad singular datum

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):

  0: [CONTINUE    ] Return from COMMON-LISP:BREAK.

  1: [MACSYMA-QUIT] Maxima top-level

  2:                Ignore runtime option --eval "(progn (load (maxima::$sconcat (namestring (pathname (maxima::maxima-getenv \"MAXIMA_PREFIX\"))) \"/bin/win_signals.lisp\")) (cl-user::run))".

  3: [ABORT       ] Skip rest of --eval and --load options.

  4:                Skip to toplevel READ/EVAL/PRINT loop.

  5: [EXIT        ] Exit SBCL (calling #'EXIT, killing the process).

(ADJOIN-SING-DATUM (((MEXPT) $%E ((MTIMES RATSIMP) $A $X)) ((2 . 1)) $ZEROA NIL))

   error finding frame source: Bogus form-number: the source file has probably

                               changed too much to cope with.

   source: NIL

0] 

Maxima 5.49 + SBCL 2.6.0.

Discussion

  • Stavros Macrakis

    Bizarrely, it seems to be the negation that is responsible for the problem:

    tt: subst(taylor(x,x,inf,2)$
    
    subst(tt,x, %e^-(x+1)^2 ) => +(+%e^-1*(%e^-x)^2)*%e^-x^2
    subst(tt,x, -%e^-(x+1)^2 ) => ERROR, only difference is initial "-"
    
    subst(tt,x, %e^-x^2 ) => +%e^-x^2   <<< OK
    subst(tt,x, -%e^-x^2 ) => -1+...   <<< ???, only difference is initial "-"
    

    Even simpler case (getting 20 taylor terms to make sure it's not a truncation issue):

    subst(taylor(x,x,inf,20),x,exp(-x)) => +%e^-x
    subst(taylor(x,x,inf,20),x,-exp(-x)) => +(-1)  <<< !!!
    

    And more:

    taylor(exp(x),x,inf,5) => +1/%e^-x
    subst(taylor(exp(x),x,inf,5),x,x) => +1/%e^-x   << OK
    subst(taylor(exp(x),x,inf,5),x,x^2) => +1  << !!!
    taylor(exp(x),x,inf,5)^2 => +1   << !!!
    

    Tested in Maxima 5.49.0 SBCL 2.6.0

     

    Last edit: Stavros Macrakis 3 days ago
    • David Scherfgen

      It's any multiplication, not just negation. And we don't need subst:

      (%i1) tt : taylor(x, x, inf, 2)$
      
      (%i2) %e^tt;
      (%o2) +1/%e^-x
      
      (%i3) 2*%e^tt;
      (%o3) +2
      
       

      Last edit: David Scherfgen 1 day ago
      • David Scherfgen

        It works correctly when we use a finite expansion point, e.g. taylor(x, x, 0, 2).

         
      • David Scherfgen

        The same bug exists for addition:

        (%i1) tt : taylor(x, x, inf, 2)$
        
        (%i2) %e^tt;
        (%o2) +1/%e^-x
        
        (%i3) %e^tt + 10;
        (%o3) +11
        
         
  • David Scherfgen

    This is not a bug in the simplifier (simptimes, simplus), but in the Taylor code:

    (%i1) xx : taylor(x, x, inf, 2)$
    (%i2) eexx : %e^xx$
    (%i3) :lisp (setq $ans ($taylor (list '(mtimes) 2 $eexx)))
    (%i3) ans;
    (%o3) +2
    (%i4) :lisp (setq $ans ($taylor (list '(mplus) 10 $eexx)))
    (%i4) ans;
    (%o4) +11
    
     

Log in to post a comment.

Auth0 Logo