I have this code in latex (overleaf to be precise) and it displays the image below. I used \footnotesize to decrease the size so it would fit on the width of the page however, it did not decrease enough. How can I reduce the size of the matrix more? Thanks!
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\title{example stackoverflow}
\author{cristian cotovanu}
\date{November 2022}
\begin{document}
\maketitle
\section{Introduction}
\subsubsection*{3)}
$\frac{1}{h_x^2} = 0.16$, $\frac{2}{h_x^2} = 0.32$, $\frac{1}{h_y^2} = 0.64$, $\frac{2}{h_y^2} = 1.28$. These values will be substitute in the matrix for more clarity.
\begin{equation}
\footnotesize
\begin{bmatrix}
0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0 & 0 & 0 & 0\\
-0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0 & 0 & 0\\
0 & -0.16 & 0.32 + 1.28 & 0 & 0 & -0.64 & 0 & 0 & 0\\
-0.64 & 0 & 0 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0\\
0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0\\
0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64\\
0 & 0 & 0 & -0.64 & 0 & 0 & 0.32 + 1.28 & -0.16 & 0\\
0 & 0 & 0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16\\
0 & 0 & 0 & 0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28\\
\end{bmatrix}
\\
\begin{bmatrix}
u_{1, 1}\\
u_{2, 1}\\
u_{3, 1}\\
u_{1, 2}\\
u_{2, 2}\\
u_{3, 2}\\
u_{1, 3}\\
u_{2, 3}\\
u_{3, 3}\\
\end{bmatrix}
=
\begin{bmatrix}
f_{1, 1}\\
f_{2, 1}\\
f_{3, 1}\\
f_{1, 2}\\
f_{2, 2}\\
f_{3, 2}\\
f_{1, 3}\\
f_{2, 3}\\
f_{3, 3}\\
\end{bmatrix}
\end{equation}
\end{document}
One possibility would be to use an even smaller font size like \tiny
.
However in this particular case, in which only the long entries on the diagonal force the columns to be rather broad, one might get away with a negative colsep:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\title{example stackoverflow}
\author{cristian cotovanu}
\date{November 2022}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}
\maketitle
\section{Introduction}
\subsubsection*{3)}
$\frac{1}{h_x^2} = 0.16$, $\frac{2}{h_x^2} = 0.32$, $\frac{1}{h_y^2} = 0.64$, $\frac{2}{h_y^2} = 1.28$. These values will be substitute in the matrix for more clarity.
{
\footnotesize
\begin{equation}
\begin{+bmatrix}[
colspec={@{~}ccccccccc@{~}},
colsep=-2pt
]
0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0 & 0 & 0 & 0\\
-0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0 & 0 & 0\\
0 & -0.16 & 0.32 + 1.28 & 0 & 0 & -0.64 & 0 & 0 & 0\\
-0.64 & 0 & 0 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0 & 0\\
0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64 & 0\\
0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16 & 0 & -0.64\\
0 & 0 & 0 & -0.64 & 0 & 0 & 0.32 + 1.28 & -0.16 & 0\\
0 & 0 & 0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28 & -0.16\\
0 & 0 & 0 & 0 & 0 & -0.64 & 0 & -0.16 & 0.32 + 1.28\\
\end{+bmatrix}
\begin{+bmatrix}
u_{1, 1}\\
u_{2, 1}\\
u_{3, 1}\\
u_{1, 2}\\
u_{2, 2}\\
u_{3, 2}\\
u_{1, 3}\\
u_{2, 3}\\
u_{3, 3}\\
\end{+bmatrix}
=
\begin{+bmatrix}
f_{1, 1}\\
f_{2, 1}\\
f_{3, 1}\\
f_{1, 2}\\
f_{2, 2}\\
f_{3, 2}\\
f_{1, 3}\\
f_{2, 3}\\
f_{3, 3}\\
\end{+bmatrix}
\end{equation}
\end{document}