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[0] == x0, y[0] == 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)$?

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

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[0] == x0, y[0] == 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)$.

  • $\begingroup$ Thanks, @KraZug. But I wonder why is Mathematica showing the integrals with two variables K[1] and K[2]. $\endgroup$ – H. Kenan Jul 30 '18 at 11:45
  • $\begingroup$ 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$ $\endgroup$ – SPPearce Jul 30 '18 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.