exp-form property (was Taylor series of elliptic_kc(m) about m=0 fails with error)



On 29/09/2012 2:10 AM, Raymond Toy wrote:
>
>
> On Fri, Sep 28, 2012 at 7:24 AM, David Billinghurst 
> <dbmaxima at gmail.com <mailto:dbmaxima at gmail.com>> wrote:
>
>     On 18/09/2012 8:30 PM, David Billinghurst wrote:
>
>         Taylor series of elliptic_kc(m) about m=0 fails with
>         maxima-5.28.0/gcl/windows and clisp/windows.
>
>         taylor(elliptic_kc(m),m,0,1);
>
>         Maxima encountered a Lisp error:
>          Error in MACSYMA-TOP-LEVEL [or a callee]: Bind stack overflow.
>         Automatically continuing.
>         To enable the Lisp debugger set *debugger-hook* to nil.
>
>         According to A&S 17.3.11
>
>         K(m) ~= 1 + (1/2)^2 m + (1.3/2.4)^2 m^2 + ....
>
>
>     I have been having a look at this problem.   I seem to be able to
>     define a separate Taylor series about 0 using the exp-form
>     property, without breaking the existing definition.  The exp-form
>     function is defined for some trig and exponential functions in
>     hayat.lisp.  Just borrowing the expression for sin, as a proof of
>     concept, I see
>
>     (%i2) :lisp (get '%sin 'exp-form)
>     (EXPEXP-FUNS ((1 . 1) 1 . 1) (-1 . 1) (-1 . 1) (2 . 1))
>
>     (%i2) :lisp (putprop '%elliptic_kc (get '%sin 'exp-form) 'exp-form)
>     (EXPEXP-FUNS ((1 . 1) 1 . 1) (-1 . 1) (-1 . 1) (2 . 1))
>
>     (%i4) taylor(elliptic_kc(x),x,0,4);
>                                          3
>                                         x
>     (%o4)/T/                        x - -- + . . .
>                                         6
>
>     and taylor(elliptic_kc(x),x,0,4) still works.  I don't think this
>     is useable for series about x # 0 or for multivariate functions.
>
>
> Presumably you meant the taylor series at some point other than 0 here.
>
> This is interesting.  I haven't had a chance to try it out, but I was 
> thinking of modifying taylor so that if there was a powerseries or 
> deftaylor form (the sp2 property is set), then taylor would check to 
> see if the expansion was at 0 or not.  If so, then the deftaylor form 
> could be used.  If not, then taylor would continue as if deftaylor 
> didn't exist.
>
> I think this would make sense since deftaylor says the expansion is 
> always about 0.
>
> Ray
>
I had similar thoughts.  I don't understand the details.  For sin, the 
'exp-form is used for x <> 0 (and called twice).  This isn't the case 
when I use the same expression for elliptic_kc.  Time to look at the 
code again, although I am struggling with it.

(%i1) :lisp (putprop '%elliptic_kc (get '%sin 'exp-form) 'exp-form)
(EXPEXP-FUNS ((1 . 1) 1 . 1) (-1 . 1) (-1 . 1) (2 . 1))
(%i1) :lisp (trace expexp-funs)
;; Tracing function EXPEXP-FUNS.
(EXPEXP-FUNS)
(%i1) taylor(sin(x),x,0,4);
1. Trace: (EXPEXP-FUNS '(4 . 1) '((1 . 1) 1 . 1) '(-1 . 1) '(-1 . 1) '(2 
. 1))
1. Trace: EXPEXP-FUNS ==> (((1 . 1) 1 . 1) ((3 . 1) -1 . 6))
                                      3
                                     x
(%o1)/T/                        x - -- + . . .
                                     6
(%i2) taylor(sin(x),x,1,4);
1. Trace: (EXPEXP-FUNS '(4 . 1) '((0 . 1) 1 . 1) '(-1 . 1) '(-1 . 1) '(2 
. 1))
1. Trace: EXPEXP-FUNS ==> (((0 . 1) 1 . 1) ((2 . 1) -1 . 2) ((4 . 1) 1 . 
24))
1. Trace: (EXPEXP-FUNS '(4 . 1) '((1 . 1) 1 . 1) '(-1 . 1) '(-1 . 1) '(2 
. 1))
1. Trace: EXPEXP-FUNS ==> (((1 . 1) 1 . 1) ((3 . 1) -1 . 6))
                                                  2                 3
                                    sin(1) (x - 1)    cos(1) (x - 1)
(%o2)/T/ sin(1) + cos(1) (x - 1) - --------------- - ---------------
                                           2                 6
                                                                       4
                                                         sin(1) (x - 1)
                                                       + --------------- 
+ . . .
                                                               24
(%i3) taylor(elliptic_kc(x),x,0,3);
1. Trace: (EXPEXP-FUNS '(3 . 1) '((1 . 1) 1 . 1) '(-1 . 1) '(-1 . 1) '(2 
. 1))
1. Trace: EXPEXP-FUNS ==> (((1 . 1) 1 . 1) ((3 . 1) -1 . 6))
                                      3
                                     x
(%o3)/T/                        x - -- + . . .
                                     6


(%i7) taylor(elliptic_kc(x),x,1/2,2);
                                                         1       2 
3        1
                          (%pi sqrt(%pi) - 4 elliptic_ec(-) gamma (-)) 
(x - -)
          %pi sqrt(%pi)                                  2         
4        2
(%o7)/T/ ------------- - 
----------------------------------------------------
                  2 3                                2 3
           2 gamma (-)                        2 gamma (-)
                    4                                  4
                                                                     1 2
                                                (%pi sqrt(%pi)) (x - -)
                                                                     2
                                              + ------------------------ 
+ . . .
                                                             2 3
                                                      4 gamma (-)
                                                               4