# Taylor expansion, powers of x-a

Hi all,

I noticed that taylor(...) has a somehow inconsistent behaviour. When used with a function of one variable, it returns an expression that is a sum of powers of $x-a$. For instance taylor(sin(x), x,1,2) gives the result $-\frac{1}{2} \, {\left(x - 1\right)}^{2} \sin\left(1\right) + {\left(x - 1\right)} \cos\left(1\right) + \sin\left(1\right)$ as expected. Same for taylor(sin(x*y), (x,1), (y,2),2) that gives the expected answer.

In contrast taylor(sqrt(1+4*x^2 + y^2),(x,1), (y,2),2) gives a result ending with $\frac{4}{3} x + \frac{2}{3} y + \frac{1}{3}$ , where I was expecting something containing a term on $x-1$ and a term in $y-2$.

Any ideas?

JC

edit retag close merge delete

( 2023-08-01 19:03:29 +0200 )edit

I am using sage 10.0 on ubuntu. Perhaps adding var('x,y')' at the very beggining helps? I tried that in sage cell server ant the restult is the one in my original post.

( 2023-08-01 21:43:41 +0200 )edit

The linear part can be rewritten as follows

maxima('taylor(4/3*x + 2/3*y + 1/3,[x,1,1],[y,2,1])')

((2*(y-2))/3+3)+(4*(x-1))/3

( 2023-08-02 11:33:57 +0200 )edit

Sort by ยป oldest newest most voted

On a (lame for now) Sage 10.1.beta8 :

sage: var("x, y")
(x, y)
sage: taylor(sqrt(1+4*x^2+y^2),(x, 1), (y, 2), 2)
10/27*(x - 1)^2 - 8/27*(x - 1)*(y - 2) + 5/54*(y - 2)^2 + 4/3*x + 2/3*y + 1/3
sage: var("u, v")
(u, v)
sage: taylor(sqrt(1+4*x^2+y^2).subs({x:u+1, y:v+2}),(u, 0), (v, 0), 2).subs({u:x
....: -1, v:y-2})
10/27*(x - 1)^2 - 8/27*(x - 1)*(y - 2) + 5/54*(y - 2)^2 + 4/3*x + 2/3*y + 1/3


Sage insists to develop degree 1 monomials with numerical coefficients :

sage: 1/2*(x-1)+2/3*(y-2)
1/2*x + 2/3*y - 11/6
`

This has already caused much tears, wails and teeth grindings (on this site and elsewhere). Complain fiercely...

EDIT : Same results on Sagecell...

HTH,

more