# Solving System of Ordinary Differential Equations (ODEs)

When I input the following code to solve this system of equations (I specifically want to look at 0<d<1, 0<q<1, 0<t), I get the error:

'DSolve: The function y[t] was specified without dependence on all the independent variables. Each function must depend on all the independent variables.'

Here is my code:

  DSolve[{y'[t] == 1 - q x[t] - (3 + 2 d) y[t], x'[t] == 1 - d y[t] - (3 + 2 q) x[t], x[0] + y[0] == 1}, y[t], x[t], t]


What is the appropriate way to go about solving these differential equations?

You need to write it this way

ClearAll[x, y, t, q, d];
ode1 = y'[t] == 1 - q x[t] - (3 + 2 d) y[t];
ode2 = x'[t] == 1 - d y[t] - (3 + 2 q) x[t];
ic   = x[0] + y[0] == 1;
DSolve[{ode1, ode2, ic}, {y[t], x[t]}, t]


What would I do if I now want to look at when y=0 and x'>0

May be this is something to get you started on this. You'd need numerical value for $$q,d$$. Since you have 2 ODE's and one IC. So even if you plug in numbers for q,d, there is still one unknown c1. But you can always plug in a number for this constant also

Here is an example

ClearAll[x,y,t,q,d];
q    = 1/2;
d    = 1/3;
ode1 = y'[t]==1-q x[t]-(3+2 d) y[t];
ode2 = x'[t]==1-d y[t]-(3+2 q) x[t];
ic   = x[0]+y[0] == 1;

sol = First@DSolve[{ode1,ode2,ic},{y[t],x[t]},t];
sol = sol/.C[1]->1 %plug in some value for last constant of integration


Now

Plot[{Evaluate[y[t] /. sol], Evaluate[D[(x[t] /. sol), t]]}, {t, 0,
2}, PlotLegends -> {"y(t)", "x'(t)"}]


The above shows $$y(t),x'(t)$$ are both >= 0 when $$t=2$$. it looks like x'(t) does not go over zero actually. To get exact answer, you'd need to solve the equations which I am not sure they can be solved analytically, a numerical method would be needed. When you change $$c_1$$ you do the same again.

• What would I do if I now want to look at when y=0 and x'>0 or when x'=0 and y=0 or when x'=0 and y>0 for example? Commented Jul 24, 2019 at 11:18
• @RyanSchiller do you have numerical values for all the parameters d,q else will be hard to solve analytically. Once you have the solution, you can do D[x[t],t] to get x'[t] and then you need to solve for t when y=0, x'[t]>0 but this will be hard to do as is since solutions are complicated, and also there is a constant of integration which is not defined. So you need initial conditions also. Commented Jul 24, 2019 at 11:24
• All I know is 0<q<1, 0<d<1, x(0) + y(0) = 1, 0<=x<=1, 0<=y<=1, 0=<t. Is this not enough to solve analytically? Commented Jul 24, 2019 at 11:34
• @RyanSchiller you have essentially one IC in x(0) + y(0) = 1 If you look at the solution, you'll see $c_1$ in there. Since you have 2 ODE's and one IC. So even if you plug in numbers for q,d, there is still one unknown $c_1$. But you can always plug in a number for this constant also. I'll show an example. Commented Jul 24, 2019 at 11:40
• Ah that makes sense. Looking forward to seeing your example anyway so I can learn a bit more about the syntax of this language. Commented Jul 24, 2019 at 11:46

You have to group {x[t],y[t]}in a list

DSolve[{y'[t] == 1 - q x[t] - (3 + 2 d) y[t], x'[t] == 1 - d y[t] - (3 + 2 q) x[t], x[0] + y[0] == 1}, {y[t],x[t]}, t]