# Formatting of long equation containing a matrix?

I've a problem formatting this equation. It's containing a 5x1 matrix and the content of a cell in a matrix is pretty long. All in all it does not fit on the page. Should I use split() or is there another option?

$$\varphi_{i,j,k}^{n+1} = \varphi_{i,j,k}^{n} + \delta t \frac{1}{|x^3|} \begin{smallmatrix} \frac{1}{2}((\rho v_1)_{i,j+1,k}-(\rho v1)_{i,j-1,k})\delta x + \frac{1}{2}((\rho v_2)_{i+1,j,k}-(\rho v_2)_{i-1,j,k})\delta y + \frac{1}{2}((\rho v_3)_{i,j,k+1}-(\rho v_3)_{i,j,k-1})\delta z\\ \frac{1}{2}((\rho v_1^2+p)_{i,j+1,k}-(\rho v_1^2+p)_{i,j-1,k})\delta x + \frac{1}{2}((\rho v_1 v_2)_{i+1,j,k}-(\rho v_1 v_2)_{i-1,j,k})\delta y + \frac{1}{2}((\rho v_1 v_3)_{i,j,k+1}-(\rho v_1 v_3)_{i,j,k-1})\delta z\\ \frac{1}{2}((\rho v_2 v_1)_{i,j+1,k}-(\rho v_2 v_1)_{i,j-1,k})\delta x + \frac{1}{2}((\rho v_2^2+p)_{i+1,j,k}-(\rho v_2^2+p)_{i-1,j,k})\delta y + \frac{1}{2}((\rho v_2 v_3)_{i,j,k+1}-(\rho v_2 v_3)_{i,j,k-1})\delta z\\ \frac{1}{2}((\rho v_3 v_1)_{i,j+1,k}-(\rho v_3 v_1)_{i,j-1,k})\delta x + \frac{1}{2}((\rho v_3 v_2)_{i+1,j,k}-(\rho v_3 v_2)_{i-1,j,k})\delta y + \frac{1}{2}((\rho v_3^2+p)_{i,j,k+1}-(\rho v_3^2+p)_{i,j,k-1})\delta z\\ \frac{1}{2}(((\rho E+p)v_1)_{i,j+1,k}-((\rho E+p)v_1)_{i,j-1,k})\delta x + \frac{1}{2}(((\rho E+p)v_2)_{i+1,j,k}-((\rho E+p)v_2)_{i-1,j,k})\delta y + \frac{1}{2}(((\rho E+p)v_3)_{i,j,k+1}-((\rho E+p)v_3)_{i,j,k-1})\delta z\\ \end{smallmatrix}$$

-
When things look that bad, I usually try to rethink my notation! – Ian Thompson Jun 10 '14 at 11:53
Yeah well, I agree you, but to rethink the notation of a equation is pretty hard. Since you cannot change an equation that much – Thomas Jun 10 '14 at 12:00
I agree with Ian. This is hardly readable as it is. What does the expression inside the smallmatrix even mean. – daleif Jun 10 '14 at 12:00
It's the result of an finite volume method of the euler equations – Thomas Jun 10 '14 at 12:05
factorize as much as you can. Get \frac{1}{2} out of there, do a scalar product with the vector (dx, dy, dz) (just examples) and then start introducing variables for each matrix cell. \begin{smallmatrix}A\\BC\\D\\E\end{smallmatrix} where A=((\rho v_1)_{i,j+1,k}-(\rho v1)_{i,j-1,k})... – LaRiFaRi Jun 10 '14 at 12:08

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$$\varphi_{i,j,k}^{n+1} = \varphi_{i,j,k}^{n} + \delta t \frac{1}{|x^3|}\mathbf{A}$$
where
$$\mathbf{A}=\frac{1}{2} \mathbf{B} \begin{pmatrix} \partial x\\\partial y\\\partial z \end{pmatrix}$$
where
$$\mathbf{B}= \begin{pmatrix} a & b & c\\ d & e & f\\ g & h & i \end{pmatrix}$$
where
\begin{align*}
a &= (\rho v_1)_{i,j+1,k}-(\rho v_1)_{i,j-1,k}\\
b &= (\rho v_2)_{i+1,j,k}-(\rho v_2)_{i-1,j,k}\\
&\mathrel{\phantom{=}}\dots
\end{align*}
\end{document}


-
haven't checked the math on that... But you get the idea. – LaRiFaRi Jun 10 '14 at 12:28
The math is correct. – Thomas Jun 10 '14 at 12:29
Thanks for your great help – Thomas Jun 10 '14 at 12:29
You're welcome. Note that I put one underline to the first v_1. A typo you should get rid of before book release. Happy TeXing! – LaRiFaRi Jun 10 '14 at 12:30
Nice refactoring. I'd consider inserting B from (3) into (2), or even folding (2) and (3) into (1), keeping just the definitions of a, b, ... separate. OP's choice. – Ethan Bolker Jun 10 '14 at 12:31