# Automatic Differentiation with custom functions within likelihood function

**URL:** <https://discourse.julialang.org/t/automatic-differentiation-with-custom-functions-within-likelihood-function/31594>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [November 27, 2019, 6:03pm UTC](https://discourse.julialang.org/t/automatic-differentiation-with-custom-functions-within-likelihood-function/31594 "2019-11-27T18:03:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 28, 2019, 7:10am UTC](https://discourse.julialang.org/t/automatic-differentiation-with-custom-functions-within-likelihood-function/31594/3 "2019-11-28T07:10:16Z")

</div>

You may find this discussion relevant, has a lot of nice suggestions:

> [@AD step for iterative solution](https://discourse.julialang.org/t/ad-step-for-iterative-solution/26404):
>
> Sometimes it would be useful to AD through an iterative algorithm, eg solving a parametric problem f(x, a) = 0 which implicitly defines x(a), but in practice uses an iterative rootfinding method. The math is clear ([implicit differentiation](https://en.wikipedia.org/wiki/Implicit_function_theorem)), I am aware of the nice tricks for the multivariate case ([adjoint method](https://math.mit.edu/~stevenj/18.336/adjoint.pdf)), this question is about practical Julia implementation. For simple presentation, let’s work with scalars, and use f(x, a) = x^3 - a which we treat as a black box. We assume deri…

---

_[View the full topic](https://discourse.julialang.org/t/automatic-differentiation-with-custom-functions-within-likelihood-function/31594)._
