# DifferentialEquations.jl: Complex function results in Inexact Error

**URL:** <https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591>\
**Category:** Numerics\
**Created:** [December 10, 2020, 7:44am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591 "2020-12-10T07:44:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ess3sq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ess3sq/32/26834_2.png) [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Post date:** [December 10, 2020, 7:44am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/1 "2020-12-10T07:44:19Z")

</div>

I am trying to solve a one dimensional Schrödinger equation which has been reduced to a first-order linear ODE of the kind \psi’(x) = f(x) \psi(x), where all functions have complex args (`Complex{Float64}`) I believe.

Either way, the solver (`solve(::ODEProblem)`) seems to be having a hard time dealing with the complex numbers because it spits out an `Inexact Error`. If I change the ode and take the absolute value of both sides, it does not complain…

So does anyone know what kind of setting of the solver I need to change to allow complex numbers?

Ty in advance…

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [December 10, 2020, 7:57am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/2 "2020-12-10T07:57:37Z")

</div>

Welcome @ess3sq! Please post a minimal working example when asking for help:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

Having said this, are you initializing your variables (in the IC) as complex, floating-point numbers?

---

<div class="post-metadata">

**Author:** ![ess3sq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ess3sq/32/26834_2.png) [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Post date:** [December 10, 2020, 8:07am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/3 "2020-12-10T08:07:17Z")

</div>

Thanks for replying this quickly;

I was not aware of the guideline, but I currently do not have a satisfying working example because I probably used it wrong with complex functions.

About your question, I did in fact not make the initial conditions complex, I shall try that in a moment. For now just the wave function and the parameters are complex.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [December 10, 2020, 8:12am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/4 "2020-12-10T08:12:26Z")

</div>

You’re right, it doesn’t need to be a “working” example but an example which shows the error you’re running into. And it should be minimal, don’t just copy paste your 200 line script.

---

<div class="post-metadata">

**Author:** ![ess3sq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ess3sq/32/26834_2.png) [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Post date:** [December 10, 2020, 8:30am UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/5 "2020-12-10T08:30:20Z")

</div>

Fair enough, I will update the question in a bit.

---

<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:** [December 10, 2020, 12:57pm UTC](https://discourse.julialang.org/t/differentialequations-jl-complex-function-results-in-inexact-error/51591/6 "2020-12-10T12:57:50Z")

</div>

Without seeing any code it’s hard to tell. But I would guess your initial condition was given as real numbers instead of complex numbers.
