# Optimization of function and solver DifferentialEquations.jl

How can i optimization this function and solver. I think I used all the optimizations I could from the documentation. I can not use dt or saveat. System have chaos and hyper chaos.

What does a profile say? My guess is that it’s either all in the sigma function or saving. If it’s the sigma function, `sigma_fast` in NNLib would be an improvement. If it’s all saving, consider saving less?

But there’s a deeper issue with the code mathematically. If it’s actually a chaotic system, then solving at “a high tolerance” doesn’t even make sense because after a few Lyopunov times will still have O(1) global error. That pretty much the definition of chaos. You only get a plot of a shadow trajectory, but also any sufficiently small error will give you a shadow trajectory, so working really hard for one is misguided. You might as well choose BS3 or Tsit5 at error of like 1e-3 and get the same global error, just a lot cheaper.

Thank you. I try use sigma_fast. Is it possible to trim the first 50,000 iterations in output the solver? System has a transient process.There is chaos in the system not at all parameters.

Without abtol and reltol, the trajectories in the phase space projection look strange. First image with abstol, reoltol and second without it.

Without abtol and reltol or with lower precision, less memory is used. This partially solves my problem, thank you. With abtol, reltoc = 1e-9 I have three times less points.

Yeah, you just make it as high as possible (that is still stable and sufficiently small time steps of course) since you know the macro behavior has O(1) error anyways (do to chaos), tweak it to the right spot, and that’s a nice optimization right there.

But also, change the saving. Are you sure you cannot compute whatever you’re trying to compute online in a `DiscreteCallback`?

I need to discard conditionally the first 10 per cent of all data. I think DiscreteCallback can not be use

You can have a callback that sets `integrator.save_on = true` at the 10% mark to cut out the first bit. So a DiscreteCallback can be a bit of use there. What do you need the data for?

The first 10 per cent of the data is rubbish and is not used in any way. The remaining 90 per cent of data is needed to detect extreme events. Also last dots i use how initial condition for next solve. Thank you, i try use integrator.save_on with DiscreteCallback.

I was able to find good method for my system AutoVern9(Rodas5) with abstol, reltol = 1e-8. With this method solve is faster.

Is there no online algorithm for this?

Extreme events can be detect after getting solve. For this in my system from data take local maximums. Then calculate mean of this local maximums and standard deviation. After this uses formula mean + 6 standard deviation.It is threshold for detect extreme events. For finaly find local maximums which >= threshold. Finded local maximums is extreme events. there is no specific algorithm as it depends on the system how they can be detected. For example this threshold worked only for positive extreme events. Also 6 is a coefficient that is usually difficult to pick and justify the choice. To calculate the mean and standard deviation correctly and you need a lot of data. For the same reason precision is required
if necessary I can share a notebok with the full code

there is currently no such algorithm in julia, but George Datseris decided to write a functionality to detect them. Extreme events functionality /ies · Issue #189 · JuliaDynamics/DynamicalSystems.jl · GitHub this discussion about it