I'm faced with a problem, which is the following: I want to represent a solution, in which (t0,η)
is given. Let's say, (t0,η) = (0,1)
. But, I would like to see the graph represented in the whole (-1,1)
domain.
As tspan
is intrinsically related with my t0
, how can I make the solver resolve my problem for the given t0
, differing the initial value in the interval in tspan
?
So, in the given example, I would like to observe the ODE in (-0.88, 0.88)
, but to solve the problem with condition (t0, y0) = (0,1)
.
using DifferentialEquations
using Plots
function example2!(dy, y, t, p)
c1 = p
dy[1] = c1 * y[1]^3
end
y0 = [1]
p = [1]
tspan = (0, 0.88)
prob2 = ODEProblem(example2!, y0, tspan, p)
sol2 = solve(prob2)
plot(sol2)
EDIT:
A discussion I had with the creator of the package, on the issue, on github,
The solver has no way of intelligently discriminate, locate, and work around divergences in a graph. So, this analysis must be done without the aid of computers as of now.
You need to call the solver twice, once for the time span from 0 to 1 and once for the time span from 0 to -1. Any competent solver will correctly translate the negative direction of the time interval into correspondingly negative step sizes.
Then combine the two partial solutions either using array operations or by drawing them with the same parameters in one plot.