# Multivariate Taylor Series Problem

**URL:** <https://discourse.julialang.org/t/multivariate-taylor-series-problem/124807>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 15, 2025, 6:55pm UTC](https://discourse.julialang.org/t/multivariate-taylor-series-problem/124807 "2025-01-15T18:55:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![usaer](https://avatars.discourse-cdn.com/v4/letter/u/b9bd4f/32.png) [@usaer](https://discourse.julialang.org/u/usaer)\
**Post date:** [January 15, 2025, 6:55pm UTC](https://discourse.julialang.org/t/multivariate-taylor-series-problem/124807/1 "2025-01-15T18:55:05Z")

</div>

Hi,  
I was using the package `TaylorSeries` to find out taylor approximation of a simple multivariate function f(x,y)=x^2+y^2. For the simple approximation around point (0,0) this works fine. However, if i want to expand around any other point e.g (1,1) it gives a wrong estimate. My code is as follows:

```julia
using TaylorSeries

RT(Y1, Y2) = Y1^2 + Y2^2 

    Yref1 = 1
    Yref2 = 1
    x, y = set_variables("x y", order=3)
    tseries = RT(x+Yref1, y+Yref2)

    println(tseries)  
The output is : 2.0 + 2.0 x + 2.0 y + 1.0 x² + 1.0 y² + 𝒪(‖x‖⁴)   
whereas I was expecting : 2.0 + 2.0 (x-1) + 2.0 (y-1) + 1.0 (x-1)² + 1.0 (y-1)² + 𝒪(‖x‖⁴)
```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 16, 2025, 3:41am UTC](https://discourse.julialang.org/t/multivariate-taylor-series-problem/124807/2 "2025-01-16T03:41:58Z")

</div>

I think TaylorSeries.jl is correct and your “expected” answer is wrong.

You have a polynomial function, so its Taylor series it just itself, expanded out. In particular, you are giving it:

\mathrm{RT}(x+1, y+1) = (x + 1)^2 + (y + 1)^2 = 2 + 2x + 2y + x^2 + y^2

which matches the TaylorSeries output.

I think the confusion here is that it is expanding in the variables x and y that you gave it, whereas you seem to be expecting an expansion in terms of `Y1 - 1` (= x) and `Y2 - 1` (= y)?

---

<div class="post-metadata">

**Author:** ![usaer](https://avatars.discourse-cdn.com/v4/letter/u/b9bd4f/32.png) [@usaer](https://discourse.julialang.org/u/usaer)\
**Post date:** [January 16, 2025, 8:50am UTC](https://discourse.julialang.org/t/multivariate-taylor-series-problem/124807/3 "2025-01-16T08:50:02Z")

</div>

I guess neither were wrong. I just needed to subtract the given Yref from the value at the point where I calculate the series value i.e. at the end of the above code I add

`desired_ans=tseries(2-Yref1, 2- Yref2)`

if I want to compute the series expansion value at (2,2)
