# ODE solvers - Matlab ode23s vs Rosenbrock23 implementations

**URL:** https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950
**Category:** Numerics
**Created:** [June 6, 2023, 3:32pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950 "2023-06-06T15:32:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://discourse.julialang.org/u/Nick1)
#### Post date: [June 6, 2023, 3:32pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/1 "2023-06-06T15:32:51Z")

</div>

I am working on solving stiff ODEs and I was comparing MATLAB and Julia solvers. While both give the same solution when the system reaches a steady state, at the beginning there is a small difference for the same relative and absolute tolerances. Do you have any idea why it happens? I observed that the ode23s implementation uses more time points (smaller time step) compare to the implementation in Julia

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [June 6, 2023, 3:37pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/2 "2023-06-06T15:37:46Z")

</div>

This is likely a difference in the time step control. The time stepping of ODEs is half science, half random guessing, so there’s a lot of room for differences.

---

<div class="post-metadata">

### Author: ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://discourse.julialang.org/u/Nick1)
#### Post date: [June 6, 2023, 3:39pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/3 "2023-06-06T15:39:50Z")

</div>

That’s what I suspect. Do you know I can control the time stepping in Julia so I can match them? I am curious

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [June 6, 2023, 3:45pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/4 "2023-06-06T15:45:47Z")

</div>

see [Timestepping Method Descriptions · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/extras/timestepping/#OrdinaryDiffEq.PIController)

---

<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: [June 6, 2023, 11:45pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/5 "2023-06-06T23:45:12Z")

</div>

I’m not going to look at the MATLAB source code for obvious reasons, but we default to a PI Controller and I would guess MATLAB defaults to an I Controller like what Hairer and Wanner do. Also, We default to using automatic differentiation while MATLAB uses finite differences, and Rosenbrock methods can be sensitive to gradient accuracy so that’s another piece that would give a difference.

---

<div class="post-metadata">

### Author: ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://discourse.julialang.org/u/Nick1)
#### Post date: [June 8, 2023, 9:15pm UTC](https://discourse.julialang.org/t/ode-solvers-matlab-ode23s-vs-rosenbrock23-implementations/99950/6 "2023-06-08T21:15:20Z")

</div>

Thanks for your answer!
