# ForwardDiff 3rd (or even higher) order derivatives

**URL:** <https://discourse.julialang.org/t/forwarddiff-3rd-or-even-higher-order-derivatives/8011>\
**Category:** New to Julia\
**Tags:** differentiation\
**Created:** [December 27, 2017, 12:42am UTC](https://discourse.julialang.org/t/forwarddiff-3rd-or-even-higher-order-derivatives/8011 "2017-12-27T00:42:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 27, 2017, 10:24pm UTC](https://discourse.julialang.org/t/forwarddiff-3rd-or-even-higher-order-derivatives/8011/6 "2017-12-27T22:24:32Z")

</div>

Can you specify a bit more precisely exactly what you need? Here’s a starter example with TaylorSeries.jl (which is a registered package, so just `Pkg.add("TaylorSeries")` to install):

```julia
julia> using TaylorSeries

julia> f(x, y) = cos(x*y) + sin(x - y^2);

julia> xx, yy = set_variables("x y", order=15);

julia> f(xx, yy)
 1.0 + 1.0 x² - 1.0 y² - 0.5 x² y² - 0.16666666666666666 x⁶ + 0.5 x⁴ y² - 0.5 x² y⁴ + 0.16666666666666666 y⁶ + 0.041666666666666664 x⁴ y⁴ + 0.008333333333333333 x¹⁰ - 0.041666666666666664 x⁸ y² + 0.08333333333333333 x⁶ y⁴ - 0.08333333333333333 x⁴ y⁶ + 0.041666666666666664 x² y⁸ - 0.008333333333333333 y¹⁰ - 0.0013888888888888887 x⁶ y⁶ - 0.00019841269841269839 x¹⁴ + 0.0013888888888888885 x¹² y² - 0.004166666666666666 x¹⁰ y⁴ + 0.006944444444444443 x⁸ y⁶ - 0.006944444444444443 x⁶ y⁸ + 0.004166666666666666 x⁴ y¹⁰ - 0.0013888888888888885 x² y¹² + 0.00019841269841269839 y¹⁴ + 𝒪(‖x‖¹⁶)

```

There are various `derivative` methods available to extract derivatives, or you can just access the coefficients of this multivariate polynomial.

If you need to expand e.g. around (-3, 4), you can do

```julia
f(3+xx, -4+yy)

```

Here, `xx` and `yy` now represent small perturbations around -3 and 4, respectively.

---

_[View the full topic](https://discourse.julialang.org/t/forwarddiff-3rd-or-even-higher-order-derivatives/8011)._
