# Calculation time of Runge Kutta method

**URL:** <https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869>\
**Category:** Performance\
**Tags:** question, diffeq, optimization\
**Created:** [October 23, 2020, 7:58am UTC](https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869 "2020-10-23T07:58:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yosuga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yosuga/32/52638_2.png) [@yosuga](https://discourse.julialang.org/u/yosuga)\
**Post date:** [October 23, 2020, 7:58am UTC](https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869/1 "2020-10-23T07:58:21Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

---

<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:** [October 23, 2020, 8:28am UTC](https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869/2 "2020-10-23T08:28:35Z")

</div>

Don’t repost.

> [@yosuga](#):
>
> What causes the difference?

You didn’t compare the same things. The DifferentialEquations.jl one is adaptive time stepping to hit the tolerances. The other RK4 is fixed time step and gets whatever error comes out. Of course calculating the solution with a few orders of magnitude more accuracy is more expensive! They are taking drastically different numbers of time steps so of course the computational cost is different. Try:

```julia
using BenchmarkTools
@btime sol = solve(prob,RK4(),dt=...,adaptive=false)

```

and if both are using the same `dt` then they should be the same.

> Why so fast?

Because it’s not controlling the accuracy, so it’s really quickly giving an answer with an uncontrolled amount of error, which you can force DifferentialEquations.jl to do but it’s not going to do it by default since it’s trying to solve the ODE.
