Hello, I have solved a system of ODE equation by using Jacobian Sparsity method. I am reading this link ODE Problems · DifferentialEquations.jl. It says that we can find df/du by using the command
J=jac(u,p,t). But, I have no idea how to use it. Where to write this command in the code to get df/du. Kindly let me know. I am writing it in a new line. But, it is giving error that “jac is not defined”.
My code is like:
du = u
du = -u - 0.1*u
u0 = [1.0, 0.0]
tspan = (0.0, 10.0)
p = 0
du0 = copy(u0)
jac_sparsity = Symbolics.jacobian_sparsity((du,u)->my_ode(du,u,p,0.0),du0,u0)
f = ODEFunction(my_ode;jac_prototype=float.(jac_sparsity))
prob_sparse = ODEProblem(f,u0,tspan,p)
alg = Tsit5()
sol = solve(prob_sparse,alg)
answer = jac(J,u,p,t)
Here I used very simple ODE, but actual ODE that I am solving is very complex and its jacobian and direcational derivatives cannot found easity. So, I need to find it by using jac command.