I need to solve this equation in Mathematica:
d/dx v(x) = A . v(x)
here v is the column vector {v1(x),v2(x),v3(x),v4(x)} and
A is a 4 x 4 matrix.
I want to solve for the functions v1, v2, v3, v4 with any initial conditions.
The range of x is from 0 to 1000.
How do I write Mathematica code for this type of differential equation using NDSolve?
So, if you have some horrible matrix
which we make anti-symmetric (so the solution is oscillatory)
Define the vector of functions and their initial conditions
Then the
NDSolvecommand looks likeAnd the solutions can be plotted with
Note that that the above differential equation is a linear, first order equation with constant coefficients, so is simply solved using a matrix exponential.
However, if the matrix
Awas a function ofx, then analytic solutions become hard, but the numerical code stays the same.For example, try:
Which can produce solutions like