# Does declaring jacobian and redefining ODEProblem with jacobian accelerate \`solve\`?

**URL:** <https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507>\
**Category:** General Usage\
**Tags:** diffeq, modelingtoolkit\
**Created:** [November 15, 2021, 4:30pm UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507 "2021-11-15T16:30:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [November 15, 2021, 4:30pm UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/1 "2021-11-15T16:30:51Z")

</div>

[https://diffeq.sciml.ai/dev/features/performance\_overloads/#ode\_explicit\_jac](https://diffeq.sciml.ai/dev/features/performance_overloads/#ode_explicit_jac)

following from this example,…  
Does explicitly declaring jacobian for an ODEproblem like this accelerate the solution using `solve()`

---

<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:** [November 15, 2021, 8:51pm UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/2 "2021-11-15T20:51:38Z")

</div>

It can, if you write a better version that autodiff would build.

---

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [November 16, 2021, 3:23am UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/3 "2021-11-16T03:23:26Z")

</div>

@ChrisRackauckas

Like in case of symbolic generated Jacobian using MTK? that is better than AutoDiff, right?

In case of Reactionsystem converted to ODESystem, we do not have generic function `f` used for creating odeproblem with Jacobian right?? In such case, how do we assign this Jacobian to converted ODESystem?

---

<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:** [November 16, 2021, 3:35am UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/4 "2021-11-16T03:35:14Z")

</div>

> [@yewalenikhil65](#):
>
> Like in case of symbolic generated Jacobian using MTK? that is better than AutoDiff, right?

Not necessarily. Depends on whether you can get simplifications or exploit sparsity.

> [@yewalenikhil65](#):
>
> In case of Reactionsystem converted to ODESystem, we do not have generic function `f` used for creating odeproblem with Jacobian right??

You do.

> [@yewalenikhil65](#):
>
> In such case, how do we assign this Jacobian to converted ODESystem?

You just generate it with `jac=true` at problem construction time.

---

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [November 16, 2021, 4:54am UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/5 "2021-11-16T04:54:44Z")

</div>

> You just generate it with `jac=true` at problem construction time.

Like a kwarg as follows ?

```julia
oprob = ODEProblem(odesys, x₀map, tspan, pmap;jac=true);

```

---

<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:** [November 16, 2021, 10:45am UTC](https://discourse.julialang.org/t/does-declaring-jacobian-and-redefining-odeproblem-with-jacobian-accelerate-solve/71507/6 "2021-11-16T10:45:49Z")

</div>

Yup, just as the docstring describes.

[https://mtk.sciml.ai/dev/systems/ODESystem/#SciMLBase.ODEProblem](https://mtk.sciml.ai/dev/systems/ODESystem/#SciMLBase.ODEProblem)
