Due to DSolve syntax, systems of differential equations have to be given as lists of equations and not as a vector equation (Unlike Solve, which accepts both). So my simple question is how to convert a vector equation such as:
{f'[t],g'[t]}=={{a,b},{c,d}}.{f[t],g[t]}
To list of equations:
{f'[t]==a*f[t]+b*g[t],g'[t]==c*f[t]+d*g[t]}
I think I knew once the answer, but I can't find it now and I think it could benefit others as well.
The normal form of the equation of a line l in R2 is n · (x - p)=0, or n · x = n · p where p is a specific point on l and n = 0 is a normal vector for l. The general form of the equation of l is ax + by = c where n = [a b ] is a normal vector for l. Example 0.5. Let us find the vector form of the previous example.
DSolve[eqn,u[x,y],{x,y}] solve a partial differential equation for. Finding symbolic solutions to partial differential equations. While general solutions to ordinary differential equations involve arbitrary constants, general solutions to partial differential equations involve arbitrary functions.
Lists are very general objects that represent collections of expressions. Functions with attribute Listable are automatically "threaded" over lists, so that they act separately on each list element. Most built‐in mathematical functions are Listable.
Try using Thread:
Thread[{f'[t], g'[t]} == {{a, b}, {c, d}}.{f[t], g[t]}]
(* {f'[t] == a f[t] + b g[t], g'[t] == c f[t] + d g[t] *)
It takes the equality operator ==
and applies it to each item within a list with the same Head
.
The standard answer to this question is that which Brett presented,
i.e., using Thread
.
However, I find that for use in DSolve
, NDSolve
, etc... the command LogicalExpand
is better.
eqn = {f'[t], g'[t]} == {{a, b}, {c, d}}.{f[t], g[t]};
LogicalExpand[eqn]
(* f'[t] == a f[t] + b g[t] && g'[t] == c f[t] + d g[t] *)
It doesn't convert a vector equation to a list, but it is more useful since it automatically flattens out matrix/tensor equations and combinations of vector equations. For example, if you wanted to add initial conditions to the above differential equation, you'd use
init = {f[0], g[0]} == {f0, g0};
LogicalExpand[eqn && init]
(* f[0] == f0 && g[0] == g0 &&
f'[t] == a f[t] + b g[t] && g'[t] == c f[t] + d g[t] *)
An example of a matrix equation is
mEqn = Array[a, {2, 2}] == Partition[Range[4], 2];
Using Thread
here is awkward, you need to apply it multiple times and Flatten
the result. Using LogicalExpand
is easy
LogicalExpand[mEqn]
(* a[1, 1] == 1 && a[1, 2] == 2 && a[2, 1] == 3 && a[2, 2] == 4 *)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With