# Differential operators: curl div, grad, laplacian, partial derivatives with automatic differentiation

**URL:** https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375
**Category:** General Usage
**Tags:** forwarddiff
**Created:** [May 13, 2020, 12:00am UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375 "2020-05-13T00:00:34Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)
#### Post date: [May 13, 2020, 12:00am UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/1 "2020-05-13T00:00:34Z")

</div>

Hello,

Is there a package that implements the operators curl div, grad, laplacian, partial derivatives with automatic differentiation for scalar functions and vector fields?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 13, 2020, 5:44am UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/2 "2020-05-13T05:44:36Z")

</div>

No but the AD primatives of jvps and vjps are directional derivatives and gradients, so you can build these from it. This would be nice to add to DiffEqFlux since we use this quite a bit in physics-informed neural nets.

---

<div class="post-metadata">

### Author: ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)
#### Post date: [May 13, 2020, 3:48pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/3 "2020-05-13T15:48:55Z")

</div>

I could not find documentation on the functions jvps and vjps. Can you provide me an example how to compute one partial derivative for a function `f(x,y,z) = x*y*z` for instance?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 13, 2020, 3:55pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/4 "2020-05-13T15:55:52Z")

</div>

The easiest way to do this might be to use

> **[GitHub - JuliaDiff/SparseDiffTools.jl: Fast jacobian computation through...](https://github.com/JuliaDiff/SparseDiffTools.jl#jacobian-vector-and-hessian-vector-products)**
>
> Fast jacobian computation through sparsity exploitation and matrix coloring - GitHub - JuliaDiff/SparseDiffTools.jl: Fast jacobian computation through sparsity exploitation and matrix coloring

and then:

```julia
auto_jacvec(f, u, [1,0,0])

```

would be partial f(u) / partial x.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 13, 2020, 3:56pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/5 "2020-05-13T15:56:41Z")

</div>

My notes on jvps and vjps for autodiff might be helpful here. The relevant part starts on Lecture 9:

[https://mitmath.github.io/18337/lecture9/autodiff\_dimensions](https://mitmath.github.io/18337/lecture9/autodiff_dimensions)

Reverse mode and those are the next parts in [https://github.com/mitmath/18337](https://github.com/mitmath/18337).

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [May 13, 2020, 6:46pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/6 "2020-05-13T18:46:42Z")

</div>

[Grassmann.jl](https://github.com/chakravala/Grassmann.jl) almost supports, there are a few more bugs I need to fix for automatic differentiation, but I’m not currently in a rush to do that right now. I just work on it for fun on my free time when I feel like it, but it will be able to do that once I finalize the AD feature pallette.

It won’t be limited to scalar functions and vector fields, you’ll also be able to apply it to more general tensor fields.

---

<div class="post-metadata">

### Author: ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)
#### Post date: [May 13, 2020, 8:17pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/7 "2020-05-13T20:17:09Z")

</div>

Thank you for your answer, this is very helpful!

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [July 5, 2021, 3:48pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/8 "2021-07-05T15:48:45Z")

</div>

is there now an AD laplacian operator implemented somewhere?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [July 5, 2021, 7:16pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/9 "2021-07-05T19:16:20Z")

</div>

No, it really needs Diffractor.

---

<div class="post-metadata">

### Author: ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)
#### Post date: [July 5, 2021, 7:21pm UTC](https://discourse.julialang.org/t/differential-operators-curl-div-grad-laplacian-partial-derivatives-with-automatic-differentiation/39375/10 "2021-07-05T19:21:52Z")

</div>

Thanks
