# DifferentialEquations.jl: ODE returns "retcode: success" but interpolation gives "NaN"

**URL:** <https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942>\
**Category:** New to Julia\
**Tags:** question, diffeq, ode, nan\
**Created:** [January 6, 2021, 3:12pm UTC](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942 "2021-01-06T15:12:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paio/32/7627_2.png) [@Paio](https://discourse.julialang.org/u/Paio)\
**Post date:** [January 6, 2021, 3:12pm UTC](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942/1 "2021-01-06T15:12:02Z")

</div>

Hello Julia community,

I am currently going through a toy-problem trying to solve the heat PDE using the FFT (I’m following this series by Steve Brunton [Solving PDEs with the FFT [Matlab] - YouTube](https://youtu.be/BkA7ncY0b7I)). This is the code I came up with based on the video

```julia
using FFTW, DifferentialEquations
##
#variables
a=1 #thermal diffusivity constant
L=100 #length of domain
N=1000 #number of discrete points
dx=L/N
x=collect(-L/2:dx:L/2) #x domain
##
#define discrete wavenumbers
kappa=2π/L*collect(-N/2:N/2)
kappa=fftshift(kappa)
#parameters tuple
parameters=(kappa,a)
#initial conditions
u0=zeros(Float64,length(x))
u0[Int((L/2-L/10)/dx):Int((L/2+L/10)/dx)].=1
##
#define ODEs problem
t=(0.0,20.0)
function heatfft!(du,uhat,params,t)
    du=-params[2]^2*(params[1].^2).*uhat;
end
problem=ODEProblem(heatfft!,fft(u0),t,parameters)
##
#solve
solution=solve(problem)
##inverse transform
timeee=0.0:0.1:20.0
uhat=real.(ifft.(solution(timeee)));

```

While the solution returns “retcode: success” and gives 8 points of the solutions that look allright, when I call the interpolation `solution(timeee)` the resulting array of arrays is full of NaNs.  
Am I missing something or did something incorrect ?

My Julia is at version 1.5.3 and all the packages used should be updated.

---

<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:** [January 6, 2021, 3:39pm UTC](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942/2 "2021-01-06T15:39:31Z")

</div>

You used the in-place form but created a new array instead of mutating.

```julia
function heatfft!(du,uhat,params,t)
    du .= -params[2]^2*(params[1].^2).*uhat;
end

```

---

<div class="post-metadata">

**Author:** ![Paio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paio/32/7627_2.png) [@Paio](https://discourse.julialang.org/u/Paio)\
**Post date:** [January 6, 2021, 3:55pm UTC](https://discourse.julialang.org/t/differentialequations-jl-ode-returns-retcode-success-but-interpolation-gives-nan/52942/3 "2021-01-06T15:55:47Z")

</div>

Thank you Chris for the speedy reply and your awesome work!  
For posterity here is the documentation link for in-place vs out-of-place [Problem Interface · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/basics/problem/#In-place-vs-Out-of-Place-Function-Definition-Forms) .
