I have a system of equations:
This system satisfies a relation
where
is an initial condition.For
I plotted the relation
in two ways: First way by solving the system numerically using ode45 with RelTol 1e-12 and AbsTol 1e-15 and by having the solution for x I plotted y.
Second way by solving the equation
again with ode45 with Reltol 1e-9 and Abstol 1e-12 and then defining y=... and plotting it. However, the plots are very different and I don't understand the reason why:
Here is the plot by first method:
Here is the plot by second method:
Help is appreciated!
Codes:
function[Y] = S_with_I_defined(a,b,x0)
function dS = SIpS1_pR(t,y)
dS = -(a*y-b)*(1-y-((1-b)/a)*log(d/abs(a*y-b)));
options = odeset('Refine',6,'RelTol',1e-9,'AbsTol',1e-12);
[t,y] = ode45(@SIpS1_pR, [0 1500], x0, options);
function[X,Y] = RK_SI_pS_1_minus_pR7(a,b,x0,y0)
function dy = SIpS1_pR(t,y)
dy(1) = - a*y(1)*y(2)+b*y(2);
dy(2) = a*y(1)*y(2) -y(2);
options = odeset('Refine',1,'RelTol',1e-12,'AbsTol',1e-18);
[t,y] = ode45(@SIpS1_pR, [0 1500], [x0 y0], options);