# Is it possible to do Nested AD ~elegantly~ in Julia? (PINNs)

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888>\
**Category:** General Usage\
**Tags:** machine-learning\
**Created:** [May 15, 2023, 5:12pm UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888 "2023-05-15T17:12:01Z")\
**Posts on this page:** 4\
**Page:** 3

<div class="post-metadata">

**Author:** ![jacob.m.wilson.42](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jacob.m.wilson.42](https://discourse.julialang.org/u/jacob.m.wilson.42)\
**Post date:** [September 19, 2024, 2:09am UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888/42 "2024-09-19T02:09:40Z")

</div>

Hello everyone! I wanted to resurrect this old topic. Has anyone found a better way to do higher order derivatives using PINNs over the last year? It seems as though the best option is still to do finite differences. I also noticed that the same equation I am working with (helmholtz equation) still has an [open topic](https://github.com/JuliaDiff/ReverseDiff.jl/issues/233) that was mentioned in the beginning of this thread.

---

<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:** [September 19, 2024, 3:05am UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888/43 "2024-09-19T03:05:58Z")

</div>

You can do forward-over-reverse (no finite differences required) as described in this thread: [Nested AD with Lux etc](https://discourse.julialang.org/t/nested-ad-with-lux-etc/113573)

---

<div class="post-metadata">

**Author:** ![jacob.m.wilson.42](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jacob.m.wilson.42](https://discourse.julialang.org/u/jacob.m.wilson.42)\
**Post date:** [September 27, 2024, 12:59am UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888/44 "2024-09-27T00:59:19Z")

</div>

Still nothing for Flux/zygote? I really like Flux and have put a lot of time of my research into it. It would be nice to have an option that works with Flux/Zygote. Other than PINNs, Flux has treated me very well.

---

<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:** [September 27, 2024, 2:18am UTC](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888/45 "2024-09-27T02:18:30Z")

</div>

Lux is still a solution, and it’s still the case that nested AD is a terrible way to do PINNs anyways.

[Previous page](https://discourse.julialang.org/t/is-it-possible-to-do-nested-ad-elegantly-in-julia-pinns/98888.md?page=2)
