I’ve written two scripts: one in Julia and one in Matlab. Both are supposed to do the same thing: solve a system of ODEs

One way to do a “sanity” check, in this case, for the numerical solutions is to check if the L2 norm of my solution are conserved. In Julia this corresponds to writing something like `norm(sol[i], 2)`

and never seeing a change in value. Plotting this, one would see a flat line for all time. In Matlab it is just about the same syntax.

What **is different** are the ODE solvers. In Julia, `ODEProblem`

defaults to `Tsit5()`

whereas in Matlab we default to use `ode45`

.

**Question:** Why is the L2-norm conserved in my Julia implementation, but not the Matlab implementation?

**Attempt:** I have done my best at copying my Julia code into Matlab so I think I am solving the same ODE system as in my Julia implementation. In both implementations I have examined the values of the solution at each time step and see there are very small differences. In Matlab, I see the norm is decreasing and oscilating (?!). I have no explaination for this.

**Guess:** My only idea, after auditing the codes, is that Tsit5 does a “better job” at a numerical approximation of the code. But I do not know how to verify this as I do not have an exact solution to compare to.

**Julia code:** fDNLS_Direct.jl (5.8 KB)

**Matlab code:** There are three files: 1) https://paste.ofcode.org/vAySi4DUAzahPdmBFJ3TNY,

2) https://paste.ofcode.org/KAhexkWif2LcnxBvNnXCAP,

3) https://paste.ofcode.org/TnLgPjbbRvULh2cMUWL2pr