# Solving semilinear ODE with changing linear operator

**URL:** <https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747>\
**Category:** Modelling & Simulations\
**Created:** [November 1, 2021, 5:04pm UTC](https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747 "2021-11-01T17:04:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [November 1, 2021, 5:04pm UTC](https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747/1 "2021-11-01T17:04:14Z")

</div>

I am trying to solve a semilinear ODE whose linear operator depends on the solution: `du/dt = A(u) u + f(u,t)`. The “linear” operator `A(u)` is diagonal. I am wondering what is the best approach to solve this problem by `DifferentialEquations.jl`.

Strictly speaking, `A(u) u` is not a linear term as `A` depends on `u`, but `SplitODEProblem` documented [here](https://diffeq.sciml.ai/stable/solvers/split_ode_solve/#Semilinear-ODE) seems to support `u`-dependent linear operator, so I gave it a try. Specifically, I define `A(u)` as `DiffEqArrayOperator(Diagonal(...), update_func=...)` such that `update_func` updates the diagonal matrix as a function of `u`. The performance of this approach is unsatisfactory: using `SplitODEProblem` is slower than using `ODEProblem`.

I think the best approach depends a lot on the properties of `A(u)` and `f(u, t)`, but any general advices will be appreciated!

---

<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 1, 2021, 7:49pm UTC](https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747/2 "2021-11-01T19:49:34Z")

</div>

I don’t know of a solver that would do this very effectively. Semilinear methods usually specialize on A being constant.

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [November 1, 2021, 7:51pm UTC](https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747/3 "2021-11-01T19:51:28Z")

</div>

Do you know anything about the order of `f` w.r.t. `u`?

---

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [November 1, 2021, 8:47pm UTC](https://discourse.julialang.org/t/solving-semilinear-ode-with-changing-linear-operator/70747/4 "2021-11-01T20:47:19Z")

</div>

> [@josuagrw](#):
>
> Do you know anything about the order of `f` w.r.t. `u` ?

It’s roughly `u.^3`, if that’s helpful.
