2
$\begingroup$

I've a matrix PDE which looks like, $$ \partial_r M(r,k) = M(r,k) \, A(k) \, M(r,k) \, + B(k) \quad, \quad \lim_{r \rightarrow 0} \, M(r,k) = C(k) $$ Here $M,A,B,C$ are all $4\times4$ matrices and functions of $r$ and/or $k$. One more thing is this equation has to be solved for a range of $k$ and in the end I want a plot of $\text{Tr} \,(\text{Im}\, M)$ vs $k$. I'm not sure how to solve a matrix equation and that to with a range of parameters.

Let me put this simple $2 \times 2$ example as reference (say for $k \in [-2,2]$ ): $$ A(k) = \begin{pmatrix} k & -1 \\ -1 & -k \end{pmatrix} \, , \, B(k) = \begin{pmatrix} k & 1 \\ 1 & -k \end{pmatrix} \, , \, C(k) = \begin{pmatrix} \sqrt{k} & 0 \\ 0 & -\sqrt{k} \end{pmatrix} \, . $$ (Please feel free to change the $A$, $B$, and $C$ matrices if needed, as I'm not sure of the existence of the solution for these choices.)

Thanks!

$\endgroup$
  • 2
    $\begingroup$ Use ParametricNDSolve and treat k as the parameter. $\endgroup$ – bbgodfrey Nov 6 '15 at 19:48
  • $\begingroup$ please post Mathematica code, not just TeX $\endgroup$ – Dr. belisarius Nov 6 '15 at 20:27
2
$\begingroup$

NB. I am not an expert in PDE's, but I would like to put an answer here in hopes that it would lead to better answers.

Since $k$ is a parameter, I have removed it from the arguments to $M$. Then, I specified the matrices directly in the differential equation and the inital value.

soln = ParametricNDSolve[
  {
   M'[r] == M[r]. {{k, -1}, {-1, k}} + {{k, 1}, {1, -k}},
   M[0] == {{Sqrt[k], 0}, {0, Sqrt[k]}}
   }
  , M, {r, 0, 1}, {k}]

M

The solution to $M$ at any $r$ (here, between 0 and 1) and parameter value $k$ can be determined with:

M[k][r] /. soln

Let's define $G(r,k)=\textrm{Tr}[\textrm{Im} M(r,k)]$. (I think the solutions to $M$ are real matrices for $k>0$.)

G[r_, k_] := Tr[Im[Evaluate[M[k][r] /. soln]]

Finally, the $G(r,k)$ can be plotted with a function like:

ContourPlot[
  G[r, k],
 {k, -5, 0}, {r, 0, 1},  FrameLabel -> {"k", "Tr[Im M]"}]

G

$\endgroup$
  • $\begingroup$ Thanks for your effort, this is precisely what I was looking for. I've made an edit to the question, $G$ is actually just $M$ (sorry for the typo). You may want to make an edit to your answer accordingly. $\endgroup$ – Skylar15 Nov 9 '15 at 7:08
  • 1
    $\begingroup$ You're welcome, this was fun. I've made a few changes to my answer since I had the arguments to the ParametricFunction reversed. $\endgroup$ – Eric Brown Nov 9 '15 at 12:16

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.