# Setting \`abstol\` and \`reltol\` when solving the Schrödinger equation with OrdinaryDiffEq

**URL:** https://discourse.julialang.org/t/setting-abstol-and-reltol-when-solving-the-schrodinger-equation-with-ordinarydiffeq/125534
**Category:** Quantum
**Tags:** question, ode
**Created:** [February 4, 2025, 2:19pm UTC](https://discourse.julialang.org/t/setting-abstol-and-reltol-when-solving-the-schrodinger-equation-with-ordinarydiffeq/125534 "2025-02-04T14:19:04Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)
#### Post date: [February 4, 2025, 11:57pm UTC](https://discourse.julialang.org/t/setting-abstol-and-reltol-when-solving-the-schrodinger-equation-with-ordinarydiffeq/125534/9 "2025-02-04T23:57:20Z")

</div>

> [@goerz](#):
>
> It’s a little non-ideal that there are two error parameters `abstol`, `reltol` that I have to tweak, and I have to get a better understanding of how to connect my `err` with `abstol` and `reltol`

Firstly, both `abstol` and `reltol` are stepwise, not global. They bound the acceptable error for a single time step, but larger errors may accumulate over the course of the simulation.

For each step, `abstol` is a tolerance on the next value of `norm(Ψ - Ψ_exact)` conditional on the current `Ψ` being exact, while `reltol` is a tolerance on `norm(Ψ - Ψ_exact) / norm(Ψ)`. Of course, you don’t actually know `Ψ_exact`, but if anything the error estimates lean toward the pessimistic side, so this is usually quite robust. (Specifically, for an order `n` algorithm the error is estimated by comparing the proposed step to one computed using an order `n - 1` algorithm. This can really be thought of as a heuristic error estimate for the order `n - 1` algorithm, and should thus be an overestimate for the order `n` algorithm unless something pathological is going on.)

`abstol` specifies what zero means to you in absolute terms, while `reltol` specifies the number of accurate digits you demand. If you know the typical magnitude of your state—say, the typical or maximum value of `norm(Ψ)` during the simulation—it’s natural to set `abstol = scale * reltol`. I think matlab ode solvers can even do this automatically: you specify a reltol, and the integrator keeps track of the largest state encountered and updates abstol accordingly. However, if the norm of your states is fairly constant, at least in order of magnitude terms, you might as well only specify `reltol` while keeping `abstol = 0`.

For quantum states where `norm(Ψ) = 1`, the distinction doesn’t really matter and `abstol` and `reltol` are interchangeable. In this case, I’d set `abstol` to zero and experiment with `reltol`.

---

_[View the full topic](https://discourse.julialang.org/t/setting-abstol-and-reltol-when-solving-the-schrodinger-equation-with-ordinarydiffeq/125534)._
