I would generate a random vector and use the same random initial condition in Julia and MATLAB and then invoke the f call and see if the derivatives are the same. Your initial condition is very constant, so that’s probably not a good place to be checking the correctness of the derivative evaluation, since applying some of those operators might give be giving zeros due to the constant-ness. While your style of coding doesn’t have to change, I can’t say it’s the easiest style to debug since the indexing is a little… intense. If it’s stable with ode45, then it should be stable with Tsit5, DP5, etc.
Maybe is the style of coding that I have to change ? Maybe I have to use to stiff option of DifferentialEquations.jl ? Maybe my equations are simple unstable ? Maybe is my desktop ? I believe to be a bug of the debugger, but maybe this information is relevantĬPU: Intel(R) Core(TM) i7-4790K CPU 4.00GHz I could not displayed on debug mode, nether I could see it in workspace variables panel. Note: During the debugging (I cannot explain why), but in Julia version the matrix ZMM at line 100 sometimes were not created.
Matlab ode45 code#
Maybe is the style of coding that I have to change ? Maybe I have to use to stiff option of DifferentialEquations.jl? Maybe my equations are simple unstable ? Maybe is my desktop ?īecause the code is extensive to show in this post, you can download from here. My goal is to speed up the code using Julia + DifferentialEquations.jl.Īfter much debugging, I guarantee that the first initialization provides equal final results.
I have a code to my research with some coupled Differential Equations that in Matlab + ODE45, that are working as expected. However, I cannot figure out where/why/how is going wrong See Summary of ODE options in particular, odeget will display the options that are present by default.I’m sorry to interrupt your morning/afternoon/evenning, but I need some help to convert a code written in Matlab into Julia. Numerical packages, such as Matlab, allow the user to adjust the required tolerance for absolute or relative errors. (Roughly: if one computes the solution using a method of 4th order of accuracy, and then using a method of 5th order, then the difference of the results gives information about how far they are from the exact solution.) The algorithm adjusts the time steps as needed to maintain the accuracy. The algorithm ode45 already controls the accuracy of the solution, using sophisticated (albeit necessarily heuristic) error estimates. The stability of solution greatly depends on the ODE itself (and its initial condition) for example the ODE $y'=y^2$ with $y(0)=y_0$ has exact solution $y(t) = y_0/(1-y_0t)$ which blows up at the time $t=y_0^$, at which point any numeric solution will cease to be meaningful.ĭoes stopping the ode45 solver, changing an initial condition, and then resume running the solver make any sense? Just by rescaling (replacing $t$ by $1000t$ in the equation) we can change whatever "the maximum time" was by the factor of 1000. There cannot be a simple number like that. Is there a generally accepted max time, say, t_final = 30? As said in comments, ode45 implements a numerical method of the Runge-Kutta family.