Quantcast
Channel: Turn vector equation into matrix multiplication - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 2

Turn vector equation into matrix multiplication

$
0
0

I have physical equations of motion that describe the dependence of one vector field on the components of another vector field. Without getting too much into detail, my differential equations involve a double curl that mixes the vector components on one side of the equation. Furthermore, I would like to discretize the space on which these equations are defined. So far I was able to set up the discretized equations:

$$\frac{d}{dt}\ \begin{pmatrix}\vdots\\P_x(i)\\P_y(i)\\P_z(i)\\\vdots\end{pmatrix} = \begin{pmatrix}\vdots\\A_y(i)-A_y(i+1)\\-A_x(i)+A_x(i+1)-a*A_z(i)\\b*A_y(i)\\\vdots\end{pmatrix}\tag{1}$$where a and b are some arbitrary constants and $\vec{A}$ and $\vec{P}$ are the two vector fields whose relation I want to determine. The lattice coordinates in one dimension are written as i (e.g. $\frac{d}{dt} P_x(7) = A_y(7)-A_y(8)$).

Is there any way to automatically turn this into a matrix multiplication? I would want the result to look something like

$$\frac{d}{dt}\ \begin{pmatrix}\vdots\\P_x(i)\\P_y(i)\\P_z(i)\\P_x(i+1)\\P_y(i+1)\\P_z(i+1)\\\vdots\end{pmatrix} = \begin{pmatrix}\ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots \\\ddots & 0 & 1 & 0 & 0 & -1 & 0 & \ddots\\\ddots & -1 & 0 & -a & 1 & 0 & 0 & \ddots\\\ddots & 0 & b & 0 & 0 & 0 & 0 & \ddots\\\ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots\\\ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots\\\ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots\\\ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots\\\end{pmatrix}\begin{pmatrix}\vdots\\A_x(i)\\A_y(i)\\A_z(i)\\A_x(i+1)\\A_y(i+1)\\A_z(i+1)\\\vdots\end{pmatrix} \tag{2}$$

You can already see from this example that there is some regularity as P(i+1), P(i+2), etc. will have the same entries in the matrix as the ones for P(i), only that the entries within the matrix will be at different positions.

So the question is: If I gave you the vector on the right-hand side of equation (1), could you give me the matrix on the right-hand side of equation (2)?


Viewing all articles
Browse latest Browse all 2

Trending Articles



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