3
$\begingroup$

DSolve can't solve this system of differential equation by DSolve. But the basis solution is known. How I can help DSolve to use this basis solution?


WM code:

DSolve[{
x1'[t] == x2[t], 
x2'[t] == 2Cos[t]/(3+2Sin[t])x1[t]-x2[t](3-2Cos[t]+2Sin[t])/(3+2 Sin[t])},
{x1[t], x2[t]},t]

System of equations:

$x_1'(t)=x_2(t)$

$x_2'(t)=\frac{2cos(t)}{3+2sin(t)}x_1(t)-x_2(t)\frac{3-2cos(t)+2sin(t)} {3+2sin(t)}$

Basis solution:

$e^{-t}\{-1,1\}\ and\ \{3-cos(t)+sin(t),sin(t)+cos(t)\}$

$\endgroup$
  • 3
    $\begingroup$ I'm not sure I understand the question. If you already know the solution space, what do you want to use DSolve for? The problem is solved; what else is there to do? $\endgroup$ – AccidentalFourierTransform Apr 27 '18 at 14:20
  • $\begingroup$ {x1[t] -> -Exp[-t] (3 - Cos[t] + Sin[t]) , x2[t] -> Exp[-t] ( Cos[t] + Sin[t] )} don't solve your differential equations $\endgroup$ – Ulrich Neumann Apr 27 '18 at 14:47
  • $\begingroup$ @UlrichNeumann Use {x1 -> (-Exp[-#] &), x2 -> (Exp[-#] &)} and {x1 -> (3 - Cos[#] + Sin[#] &), x2 -> (Sin[#] + Cos[#] &)} $\endgroup$ – AccidentalFourierTransform Apr 27 '18 at 15:08
  • $\begingroup$ @AccidentalFourierTransform The main question is how to solve this type of equations when only basis solution is known. Is there any way to introduce assumption about basis solution in DSolve? It is necessary when author by own construct a differential equations. $\endgroup$ – Андрей Кротких Apr 27 '18 at 15:44
  • 1
    $\begingroup$ @АндрейКротких I still don't understand the question. If the basis solution is known, the equation is solved. $\endgroup$ – AccidentalFourierTransform Apr 27 '18 at 15:54
3
$\begingroup$

Here's a way to automate the solution of a system that, like the OP's, is a linear system whose coefficient matrix happens to have a constant eigenvector (constant in that it is independent of $t$). If $\dot x = Ax$ and $A$ is an $n \times n$ matrix that has some constant eigenvectors $v_1,v_2,\dots,v_k$, then completing them to a basis $v_1,v_2,\dots,v_k,v_{k+1},\dots,v_n$, we can form the transition matrix $$P = \left( v1 \mid v_2 \mid \cdots \mid v_n \right) \,.$$ Then with $x = Pu$, we get the transformed ODE $\dot u = P^{-1}AP\,u$, which hopefully DSolve can deal with. It should be able to find the first $k$ solutions, but it might fail to find the last $n-k$.

vars = {x1, x2};
ode = {x1'[t] == x2[t], 
   x2'[t] == 2 Cos[t]/(3 + 2 Sin[t]) x1[t] - 
     x2[t] (3 - 2 Cos[t] + 2 Sin[t])/(3 + 2 Sin[t])};
rhs = D[Through[vars[t]], t] /. First@Solve[ode, D[Through[vars[t]], t]];
If[AllTrue[rhs, Internal`LinearQ[#, Through[vars[t]]] &],   (* check linearity *)
 rhsA = CoefficientArrays[rhs, Through[vars[t]]][[2]],
 rhsA = Failure["nonlinear", <||>]
 ]
(*  SparseArray[<<4>>]    < check: was linear > *)

ev = Cases[Eigenvectors[rhsA], v_ /; FreeQ[v, t]]
If[Length[ev] < 1, Print["Bummer. No constant eigenvectors."]]
(*  {{-1, 1}}    < check: got a constant eigenvector > *)

pp = Transpose@Join[ev, NullSpace[ev]];  (* transition matrix *)
aa = Inverse[pp].rhsA.pp // Simplify;    (* transform coefficient matrix *)
dsol = DSolve[{u'[t], v'[t]} == aa.{u[t], v[t]}, {u, v}, t]  (* check DSolve works *)
(*  check: DSolve found a solution
  {{u -> Function[{t}, E^-t C[2] + C[1] (-3 + 2 Cos[t])], 
    v -> Function[{t}, C[1] (3 + 2 Sin[t])]}}
*)

pp.{u[t], v[t]} /. First[dsol] // Simplify;  (* pp.{u, v} yields {x1, x2} *)
xsol = Thread[vars -> (Function @@ {t, #} & /@ %)]
(*
  {x1 -> Function[t, 6 C[1] - E^-t C[2] - 2 C[1] Cos[t] + 2 C[1] Sin[t]], 
   x2 -> Function[t, E^-t C[2] + 2 C[1] Cos[t] + 2 C[1] Sin[t]]}
*)

ode /. xsol // Simplify    (* check solution *)    
(*  {True, True}  *)
$\endgroup$
  • $\begingroup$ Very nice solution of general interest (+1). Perhaps, you should post it as its own Q/A, so that it will get some visibility. You might also suggest to Wolfram, Inc. that it include this method in its next release of DSolve. $\endgroup$ – bbgodfrey Apr 29 '18 at 13:03
  • $\begingroup$ @bbgodfrey Thanks. When I get some time I will check its actual generality. I fear DSolve might automatically balk at high order/dimension systems. It might be better to reduce the order before feeding it back to DSolve in that case. But I think it’ll work on 2D systems. $\endgroup$ – Michael E2 Apr 29 '18 at 13:42
5
$\begingroup$

An alternative approach is to solve the system of ODEs with DSolve without knowing a particular solution. As a first try, eliminate x2 to obtain and attempt to solve the resulting single ODE.

DSolve[x1''[t] == x1[t] 2 Cos[t]/(3 + 2 Sin[t]) - 
    x1'[t] (3 - 2 Cos[t] + 2 Sin[t])/(3 + 2 Sin[t]), x1[t], t]

Unfortunately, it returns unevaluated. Next, reorder terms in the ODE and again attempt to solve it.

DSolve[x1''[t] + x1'[t])/(x1'[t] + x1[t]) == (2 Cos[t])/(3 + 2 Sin[t]), x1[t], t]

It, too, returns unevaluated, even though the ODE has a now obvious first integral, x1'[t] + x1[t] == C[1] (3 + 2 Sin[t]). Only when the auxiliary variable, v[t], is introduced can DSolve obtain a solution.

DSolve[{v'[t]/v[t] == (2 Cos[t])/(3 + 2 Sin[t]), 
    x1'[t] + x1[t] == v[t]}, {x1[t], v[t]}, t]
(* {{v[t] -> C[1] (3 + 2 Sin[t]), 
     x1[t] -> E^-t C[2] + C[1] (3 - Cos[t] + Sin[t])}} *)

and x2[t] follows immediately from x2[t] == x1'[t]. Incidentally, introducing v[t] directly into the original ODEs also yields this result.

Simplify[{x1'[t] == x2[t], x2'[t] == 2 Cos[t]/(3 + 2 Sin[t]) x1[t] - 
  x2[t] (3 - 2 Cos[t] + 2 Sin[t])/(3 + 2 Sin[t])} /. x2 -> Function[t, -x1[t] + v[t]]]
(* {v[t] == x1[t] + x1'[t], ((-3 + 2 Cos[t] - 2 Sin[t]) v[t])/
    (3 + 2 Sin[t]) + x1[t] + x1'[t] == v'[t]} *)
DSolve[%, {x1[t], v[t]}, t]
$\endgroup$
4
$\begingroup$

I am also not fully understanding the question. Since you already know the basis solutions. But May be you are looking for reduction of order method?

If one basis solution is known, a second one can be found using reduction of order. For example, let $x_1=-e^{-t}$ be one basis solution. The second one can be found by assuming the solution of the ODE has the form $x_2(t)= x_1(t) v(t)$ and substituting this back into the ODE and solving for $v(t)$.

ClearAll[u,x1,x2,v,x,t]

(*this is the orginal ODE. Assume we know only one solution for it *)
ode =x''[t]==2*(Cos[t]/(3+2*Sin[t]))*x[t]-x'[t]*((3-2*Cos[t]+2*Sin[t])/(3+2*Sin[t])); 

Mathematica graphics

x1[t_]:=-Exp[-t]; (*this is one solution we know *)
u[t_]:=x1[t]*v[t];
newODE=ode/.{x[t]->u[t],x'[t]->u'[t],x''[t]->u''[t]}//Simplify

Mathematica graphics

Now find v[t]

sol = v[t]/.First@DSolve[newODE,v[t],t]

Mathematica graphics

Therefore the second solution is

   x2[t_] = sol*x1[t]

Mathematica graphics

Verify

 ode/.{x''[t]->x2''[t],x'[t]->x2'[t],x[t]->x2[t]}//Simplify

Mathematica graphics

This way, you now have both solutions. so you kinda helped Mathematica, since it could not find both solutions before, but it can find one solution, given the other.

If this is not what you want, then I will delete this.

$\endgroup$

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.