Quantcast
Channel: How does NDSolve treat matrices? - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Michael E2 for How does NDSolve treat matrices?

$
0
0

An alternative to Indexed to deal with matrices is to prevent f from evaluating until a matrix value is substituted for rho[t]:

f[r_?MatrixQ, t_] := r Cos[5 t] + r[[1, 2]] - Tr[r] Exp[t];rho0 = {{1, 2}, {3, 4}};sol = NDSolve[{D[rho[t], t] == f[rho[t], t], rho[0] == rho0},    rho, {t, 0, 10}];

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>