Hello!

I’ve been introduced to Julia very recently, and I’ve been trying to adapt my already tested system of equations, with additive noise, based on a Takens-Bogdanov bifurcation.

I’ve got this far trying to improve performance as much as possible, but I need help, I think it’s still lacking.

The original code I coded in Matlab performs an EM integration with dt=0.01, and does it in ~0.7 secs (same conditions as below)

Originally I was hoping to get at least 1 order of magnitude of improvement, I was surprised that I wasn’t achieving that.

I attach the code, but since the SC matrix is sensible information, I’ve attached a random matrix that yields same performance time.

```
using Plots
using DelimitedFiles
using DifferentialEquations
using BenchmarkTools
using StaticArrays
using LinearAlgebra
#generate artificial coupling matrix
SC=abs.(randn(90,90))
SC=0.2*SC./maximum(SC)
#initial condition
u0=0.1*ones(90,2);
#initial-final time
t0=0.0;
tend=1200.0;
#define parameters
p0=[-1.5 , 2]
p=p0'.*ones(90,2);
SC=SC;
p=[p SC]
p=[p sum(SC,dims=2)]
#col 1 :alfa
#col 2 : beta
#col 3-93 : SC
#col 94: sumSC
function stakens!(du,u,p,t)
#A = similar(u)
@views(A = p[:, 3:end-1] * u[:,1])
#LinearAlgebra.mul!(A, @view(p[:, 3:end-1]), u) # in-place matrix product
for i in axes(u, 1)
du[i,1] = u[i,2] + (0.5 * p[i, end] * u[i, 1]) + (0.5 * A[i,1])
du[i,2] = 100.0 * p[i,1] - 100.0 * p[i,2] * u[i,1] + 100.0 * u[i,1] ^2 - 10.0 * u[i,1] * u[i,2] - 100.0 * u[i,1] ^3 -
10.0 * u[i,1] ^2 * u[ i , 2]
end
end
function σ_STakens(du,u,p,t)
du[1:90, 1] .= 0.04
du[1:90, 2] .= 0.0
end
prob_sde_stakens = SDEProblem(stakens!,σ_STakens,u0,(t0,tend),p)
@benchmark solve(prob_sde_stakens,EM(),dt=0.01,save_every_step=false)
```

## BenchmarkTools.Trial:

memory estimate: 307.65 MiB

allocs estimate: 720115

## minimum time: 401.633 ms (0.00% GC)

median time: 456.275 ms (11.87% GC)

mean time: 444.711 ms (9.64% GC)

maximum time: 480.100 ms (17.26% GC)

samples: 12

evals/sample: 1