# How to use DifferentialEquations with complicated equations

**URL:** <https://discourse.julialang.org/t/how-to-use-differentialequations-with-complicated-equations/20740>\
**Category:** New to Julia\
**Tags:** diffeq\
**Created:** [February 13, 2019, 10:34am UTC](https://discourse.julialang.org/t/how-to-use-differentialequations-with-complicated-equations/20740 "2019-02-13T10:34:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [February 13, 2019, 2:38pm UTC](https://discourse.julialang.org/t/how-to-use-differentialequations-with-complicated-equations/20740/3 "2019-02-13T14:38:33Z")

</div>

> [@HelgavonLichtenstein](#):
>
> For example, the equations I need to use (1,2) could be written to fit within DifferentialEquations structure, but I would be unable to list the parameters (3,4 ect) neatly since they refer to other variables

You can always pass additional parameters to a functional interface by using lexical scoping. (This seems to be a FAQ for libraries that do integration, optimization, root-finding, etcetera.)

For example, the [QuadGK package](https://github.com/JuliaMath/QuadGK.jl) package lets you integrate a function of the form `f(x)` via `quadgk(x, a, b)`. But suppose you have a function `g(x, α, β)` that depends on two additional parameters `α,β` — does that mean you can’t use it with QuadGK, unless you rewrite it to use global variables? No! You would just call `quadgk(x -> g(x, α, β), a, b)`, constructing an anonymous function `x -> ...` that [“captures” the values](https://en.wikipedia.org/wiki/Closure_(computer_programming)) of α, β from e.g. local variables.

Because of this, I think DifferentialEquations didn’t really need an explicit `p` argument `f(x, p, t)` in its basic ODE interface, since parameters could have been passed using closures. My guess is that @ChrisRackauckas defined it this way to make it easier to support parameter estimation and adjoint/sensitivity analysis.

If what you really mean is that you have ODEs coupled to other systems of non-ODE equations that are expressed implicitly, this is known as a [differential algebraic equation (DAE)](https://en.wikipedia.org/wiki/Differential-algebraic_system_of_equations) and is also [supported by DifferentialEquations.jl](http://docs.juliadiffeq.org/latest/tutorials/dae_example.html).

---

_[View the full topic](https://discourse.julialang.org/t/how-to-use-differentialequations-with-complicated-equations/20740)._
