Integrating a Taylor series?



There is a big difference between 1 and 10 terms.
I typically use 30 using automatic numeric differentiation.
Check the sode link below.

- 
Dennis J. Darland
student at dennisdarland.com
http://dennisdarland.com/
http://dennisdarland.com/philosophy/
http://sode.sourceforge.net/

On Saturday, May 11, 2013 03:09:47 PM you wrote:


Your integral should return instantaneously.  I don't know why an earlier correspondent 
claimed that this would take a long time and lots of memory.


The fact that Maxima runs forever on this simply indicates that there is a bug. (Sorry!)




Here's a little more detail:


The correct answer is very simple.  taylor(f(x),x,a,1) returns 


             f(a)+('at('diff(f(x),x,1),x = a))*(x-a)


f(a) is clearly independent of x, so integrate(f(a),x) =>x*f(a).


'at('diff(f(x),x,1),x = a) is /also/ independent of x -- x in this expression is a _dummy 
variable_, so this expression means the same thing as 'at('diff(f(y),y,1),y = a).  So 
integrate('at('diff(f(x),x,1),x = a) *(x-a) should be 'at('diff(f(x),x,1),x = a) *(x^2/2-a*x).


Instead, Maxima is apparently getting into an infinite loop.  This is a bug. The simplest way 
I've found to elicit it is integrate(at(diff(f(x),x),x=3),x).


A simple workaround is to rename all the dummy variables. Here's a simple way to do that:


rename_dummies(expr) :=
    subst(nounify(at) = 
                 lambda([ex,vareq],
                        subst(gensym(),lhs(vareq),at(ex,vareq))),
                    expr)$


So now you can do 


     integrate( rename_dummies( taylor(f(x),x,a,1) ), x,a,a+h) 


and get the correct answer instantaneously.


Bizarrely, Maxima is numbering gensyms starting at 34100, which makes the answer ugly, 
but still correct.


                   -s


I'm running Maxima 5.28 on GCL 2.6.8 on Windows


On Sat, May 11, 2013 at 2:30 PM, Thomas D. Dean <tomdean at speakeasy.org[1]> wrote:


On 05/09/13 14:39, Dennis J. Darland wrote:


It might take a very long time, if you have enough memory!




http://maxima.sourceforge.net[2]
Maxima at math.utexas.edu[3]
http://www.math.utexas.edu/mailman/listinfo/maxima[4]






--------
[1] mailto:tomdean at speakeasy.org
[2] http://maxima.sourceforge.net
[3] mailto:Maxima at math.utexas.edu
[4] http://www.math.utexas.edu/mailman/listinfo/maxima