I am currently having a problem with multiplying matrices over a number of lines, my code is as follows:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{bm}
\usepackage{amsmath}
\begin{document}
\begin{align}
= \min tr \left { \begin{bmatrix}
d_1 & 0 & \cdots & 0\
0 & d_2 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & d_p\
0 & 0 & \cdots & 0
\end{bmatrix} \left (\begin{bmatrix}
1 & 0 & \cdots & 0\
0 & 1 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & 1\
0 & 0 & \cdots & 0
\end{bmatrix} - \begin{bmatrix}
1 & 0 & \cdots & 0\
0 & 1 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & 0\
0 & 0 & \cdots & 0
\end{bmatrix} \right ) \
\begin{bmatrix}
d_1 & 0 & \cdots & 0\
0 & d_2 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & d_p\
0 & 0 & \cdots & 0
\end{bmatrix}
\left(\begin{bmatrix}
1 & 0 & \cdots & 0\
0 & 1 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & 1\
0 & 0 & \cdots & 0
\end{bmatrix} - \begin{bmatrix}
1 & 0 & \cdots & 0\
0 & 1 & \cdots & 0\
\vdots & \vdots & \ddots & \vdots\
0 & 0 & 0 & 0\
0 & 0 & \cdots & 0
\end{bmatrix} \right) \right }
\end{align}
\end{document}
Ideally I would want all of them in the same line, but since they are too long, I have to use multiple lines.
It seems like the problem might be with the curly bracket at the end.
I have tried to implement what is suggested here and have also tried using multiline, but have not been successful.
I am fairly new to latex, so apologies if this question has a very simple answer.
Thank you!
