# Solving two coupled first order differential equations

I have the following system of coupled differential equations:

$\frac{d x(t)}{dt} = c_1 x(t) - c_2 y(t) + \gamma_1(t)$ and $\frac{d y(t)}{dt} = c_2 x(t) - c_1 y(t) + \gamma_2(t)$

eqns :=
{x'[t] == c1 x[t] - c2 y[t] + gamma1[t],
y'[t] == c2 x[t] - c1 y[t] + gamma2[t]}
initialvalues := {x == x0, y == y0}


Here, $c_1$ and $c_2$ are constants, while as $\gamma_1$ and $\gamma_2$ are unknown functions of $t$. Given the initial conditions $x(0)=x_0$ and $y(0)=y_0$, how can I obtain a solutions $x(t)$ and $y(t)$?

• General Mathematica hint: the quantities eqns and initial values, being simple labels for their righthand sides, are better assigned with Set ( = ) than with SetDelayed ( := ). – m_goldberg Jul 29 '18 at 22:22

## 1 Answer

DSolve is able to give the general solution to this set of equations, for unknown $c_1$ and $c_2$, provided that you don't include the initial conditions. If you know $c_1$ and $c_2$, then you can also apply the initial conditions:

c1 = 1; c2 = 2;
eqns = {x'[t] == c1 x[t] - c2 y[t] + γ1[t],
y'[t] == c2 x[t] - c1 y[t] + γ2[t]}
initialvalues = {x == x0, y == y0}

DSolve[{eqns, initialvalues}, {x, y}, t] // Simplify


Which gives a longish expression in terms of integrals of $\gamma_1(t)$ and $\gamma_2(t)$.

• Thanks, @KraZug. But I wonder why is Mathematica showing the integrals with two variables K and K. – H. Kenan Jul 30 '18 at 11:45
• K is used to denote an arbitrary variable of integration. The solutions involve the integrals of $\gamma_1(t)$ up to the value of $t$, which would often be written e.g. $\int_0^t \gamma_1(s) ds$ – SPPearce Jul 30 '18 at 12:37