1

i have a large matrix that goes of the pdf when compliled. a suggestion to use \resizebox{0.94\textwidth}{!}{%$...$} which i followed but this causes my remaining work to have large vertical spaces in between. The Matrix cannot be changed and must appear as it is. If you have a suggestion that wouldn't require

\resizebox, it will be greatly appreciated but all the elements of it must appear as it is.

\documentclass[fleqn]{book}

%%CreatedwithwxMaxima22.04.0

\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{iftex}
\ifPDFTeX
%PDFLaTeXorLaTeX
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\DeclareUnicodeCharacter{00B5}{\ensuremath{\mu}}
\else
%XeLaTeXorLuaLaTeX
\usepackage{fontspec}
\fi
\usepackage{graphicx}
\usepackage{color}
\usepackage{amsmath,amssymb,mathtools}
\usepackage{grffile}
\usepackage{ifthen}
\newsavebox{\picturebox}
\newlength{\pictureboxwidth}
\newlength{\pictureboxheight}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\newcommand{\includeimage}[1]{
\savebox{\picturebox}{\includegraphics{#1}}
\settoheight{\pictureboxheight}{\usebox{\picturebox}}
\settowidth{\pictureboxwidth}{\usebox{\picturebox}}
\ifthenelse{\lengthtest{\pictureboxwidth>.95\linewidth}}
{
\includegraphics[width=.95\linewidth,height=.80\textheight,keepaspectratio]{#1}
}
{
\ifthenelse{\lengthtest{\pictureboxheight>.80\textheight}}
{
\includegraphics[width=.95\linewidth,height=.80\textheight,keepaspectratio]{#1}

}
{
\includegraphics{#1}
}
}
}
\newlength{\thislabelwidth}
\DeclareMathOperator{\abs}{abs}

\definecolor{labelcolor}{RGB}{100,0,0}
\begin{document}


{\begin{equation}\label{mat}
\hspace*{-0.5cm}
\renewcommand\arraystretch{2.25}
\medmuskip=0mu
\setlength\arraycolsep{2.5pt} % default: 5pt
\resizebox{1.35\textwidth}{!}{%
$D=\begin{bmatrix}
1 &{x_{n+1}-h} & {\bigg(x_{n+1}-h\bigg)^2} & {\bigg(x_{n+1}-h\bigg)^3} & {\bigg(x_{n+1}-h\bigg)^4} & {\bigg(x_{n+1}-h\bigg)^5} & {\bigg(x_{n+1}-h\bigg)^6} & {\bigg(x_{n+1}-h\bigg)^7} & {\bigg(x_{n+1}-h\bigg)^8} & {\bigg(x_{n+1}-h\bigg)^9}\\
0 & 1 & 2 {\bigg(x_{n+1}-h\bigg)}  & 3 {\bigg(x_{n+1} -h\bigg)^2} & 4 {\bigg(x_{n+1} -h\bigg)^3} & 5 {\bigg(x_{n+1} -h\bigg)^4} & 6 {\bigg(x_{n+1} -h\bigg)^5} & 7 {\bigg(x_{n+1} -h\bigg)^6} & 8 {\bigg(x_{n+1} -h\bigg)^7} & 9 {\bigg(x_{n+1} -h\bigg)^8}\\
0 & 1 & 2 {x_{n+1}}  & 3 {x_{n+1}^2} & 4 {x_{n+1}^3} & 5 {x_{n+1}^4} & 6 {x_{n+1}^5} & 7 {x_{n+1}^6} & 8 {x_{n+1}^7} & 9 {x_{n+1}^8}\\
0 & 1 & 2{\bigg(x_{n+1}+ \frac{1}{2}h\bigg)}  & 3{\bigg(x_{n+1}+ \frac{1}{2}h\bigg)^2} & 4{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^3} & 5{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^4} & 6{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^5} & 7{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^6} & 8{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^7} & 9{\bigg(x _{n+1}+ \frac{1}{2}h\bigg)^8}\\
0 & 1 & 2 {\bigg(x_{n+1}+h\bigg)}  & 3 {\bigg(x_{n+1} +h\bigg)^2} & 4 {\bigg(x_{n+1} +h\bigg)^3} & 5 {\bigg(x_{n+1} +h\bigg)^4} & 6 {\bigg(x_{n+1} +h\bigg)^5} & 7 {\bigg(x_{n+1} +h\bigg)^6} & 8 {\bigg(x_{n+1} +h\bigg)^7} & 9 {\bigg(x_{n+1} +h\bigg)^8}\\
0 & 1 & 2 {\bigg(x _{n+1}+ \frac{3}{2}h\bigg)}  & 3{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^2} & 4{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^3} & 5{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^4} & 6{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^5} & 7{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^6} & 8{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^7} & 9{\bigg(x _{n+1}+ \frac{3}{2}h\bigg)^8}\\
0 & 1 & 2 {\bigg(x_{n+1} +2 h\bigg)}  & 3 {\bigg(x_{n+1} +2 h\bigg)^2} & 4 {\bigg(x_{n+1} +2 h\bigg)^3} & 5 {\bigg(x_{n+1} +2 h\bigg)^4} & 6 {\bigg(x_{n+1} +2 h\bigg)^5} & 7 {\bigg(x_{n+1} +2 h\bigg)^6} & 8 {\bigg(x_{n+1} +2 h\bigg)^7} & 9 {\bigg(x_{n+1} +2 h\bigg)^8}\\
0 & 1 & 2{\bigg(x_{n+1}+\frac{5}{2}h\bigg)}  & 3{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^2} & 4{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^3} & 5{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^4} & 6{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^5} & 7{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^6} & 8{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^7} & 9{\bigg(x _{n+1}+ \frac{5}{2}h\bigg)^8}\\
0 & 1 & 2 {\bigg(x_{n+1}+3h\bigg)}  & 3 {\bigg(x_{n+1}+3h\bigg)^2} & 4 {\bigg(x_{n+1}+3h\bigg)^3} & 5 {\bigg(x_{n+1}+3h\bigg)^4} & 6 {\bigg(x_{n+1}+3h\bigg)^5} & 7 {\bigg(x_{n+1}+3h\bigg)^6} & 8 {\bigg(x_{n+1}+3h\bigg)^7} & 9 {\bigg(x_{n+1}+3h\bigg)^8}\\
0 & 1 & 2 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)}  & 3{\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^2} & 4{\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^3} & 5 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^4} & 6 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^5} & 7 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^6} & 8 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^7} & 9 {\bigg(x _{n+1}+ \frac{7}{2}h\bigg)^8}
\end{bmatrix}$}
\end{equation}
\par}
The determinant of the new $D$ matrix is:
\begin{equation}det (B) =\frac{15380234690625 h}{64}h^{36}\end{equation}
The inverse of {\eqref{mat}} is the $C$ matrix, which is calculated using \textbf{wxMaxima} codes as shown in the \textbf{Appendix}. 
Our sole interest in the $C$ matrix is its first row and the elements are:

\end{document}

Also, can i use \hspace*{} or \hspace inside an equation enviroment and how can i use it for only a specific equation.

ps: i am very new at latex, please explanations should be toddler-level. thanks

4
  • 2
    A good start: Remove all 144 [!!] instances of \bigg. Anoter good idea: replace all 81 [!] instances of x_{n+1} with, say, y.
    – Mico
    May 9, 2023 at 18:55
  • 2
    \hspace is a text-mode command.
    – Mico
    May 9, 2023 at 18:55
  • Why is almost every single cellin the D matrix encased in curly braces?
    – Mico
    May 9, 2023 at 19:14
  • Your matrix is to huge, that it as it is can be fit on page. You have the following options: consider Mico comments and David Carlisle answer (defining new variables) or split matrices into two parts on similar way as is done in my answer on tex.stackexchange.com/questions/257313/… or rotate it for 90 degrees. What you prefer? I would stick with first options.
    – Zarko
    May 10, 2023 at 3:09

2 Answers 2

1

As I mentioned in my comment, your matrix as it is, even if you use `tiny font size for it, cannot be fit in page. Among mentioned option here I shoe a possible way when you:

  • allow to split matrix into two parts
  • enables that each part protrude outer text block border

enter image description here

(red lines indicate page layout)

\documentclass[fleqn]{book}
%\usepackage{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[strict]{changepage}

\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{iftex}
\ifPDFTeX
%PDFLaTeXorLaTeX
\usepackage[T1]{fontenc}
\DeclareUnicodeCharacter{00B5}{\ensuremath{\mu}}
\else
%XeLaTeXorLuaLaTeX
\usepackage{fontspec}
\fi
\usepackage{graphicx}
\usepackage{color}
\usepackage{nccmath, amssymb, mathtools}
\setlength\mathindent{0pt}

\begin{document}


\begin{adjustwidth*}{}{-\dimexpr\marginparsep+\marginparwidth}
\begin{multline}
% first part of matrix
D=\left[\begin{matrix*}[l]
1 &{x_{n+1}-h} & {\Bigl(x_{n+1}-h\Bigr)^2} & {\Bigl(x_{n+1}-h\Bigr)^3} & {\Bigl(x_{n+1}-h\Bigr)^4} & {\Bigl(x_{n+1}-h\Bigr)^5} \\
0 & 1 & 2 {\Bigl(x_{n+1}-h\Bigr)}  & 3 {\Bigl(x_{n+1} -h\Bigr)^2} & 4 {\Bigl(x_{n+1} -h\Bigr)^3} & 5 {\Bigl(x_{n+1} -h\Bigr)^4} \\
0 & 1 & 2 {x_{n+1}}  & 3 {x_{n+1}^2} & 4 {x_{n+1}^3} & 5 {x_{n+1}^4} \\
0 & 1 & 2{\Bigl(x_{n+1}+ \frac{1}{2}h\Bigr)}  & 3{\Bigl(x_{n+1}+ \frac{1}{2}h\Bigr)^2} & 4{\Bigl(x _{n+1}+ \frac{1}{2}h\Bigr)^3} & 5{\Bigl(x _{n+1}+ \frac{1}{2}h\Bigr)^4} \\
0 & 1 & 2 {\Bigl(x_{n+1}+h\Bigr)}  & 3 {\Bigl(x_{n+1} +h\Bigr)^2} & 4 {\Bigl(x_{n+1} +h\Bigr)^3} & 5 {\Bigl(x_{n+1} +h\Bigr)^4}  \\
0 & 1 & 2 {\Bigl(x _{n+1}+ \frac{3}{2}h\Bigr)}  & 3{\Bigl(x _{n+1}+ \frac{3}{2}h\Bigr)^2} & 4{\Bigl(x _{n+1}+ \frac{3}{2}h\Bigr)^3} & 5{\Bigl(x _{n+1}+ \frac{3}{2}h\Bigr)^4} \\
0 & 1 & 2 {\Bigl(x_{n+1} +2 h\Bigr)}  & 3 {\Bigl(x_{n+1} +2 h\Bigr)^2} & 4 {\Bigl(x_{n+1} +2 h\Bigr)^3} & 5 {\Bigl(x_{n+1} +2 h\Bigr)^4} & \\
0 & 1 & 2{\Bigl(x_{n+1}+\frac{5}{2}h\Bigr)}  & 3{\Bigl(x _{n+1}+ \frac{5}{2}h\Bigr)^2} & 4{\Bigl(x _{n+1}+ \frac{5}{2}h\Bigr)^3} & 5{\Bigl(x _{n+1}+ \frac{5}{2}h\Bigr)^4}  \\
0 & 1 & 2 {\Bigl(x_{n+1}+3h\Bigr)}  & 3 {\Bigl(x_{n+1}+3h\Bigr)^2} & 4 {\Bigl(x_{n+1}+3h\Bigr)^3} & 5 {\Bigl(x_{n+1}+3h\Bigr)^4}  \\
0 & 1 & 2 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)}  & 3{\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^2} & 4{\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^3} & 5 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^4} 
\end{matrix*}\right.\quad\dotsm   \\
% second part of matrix
\dotsm\quad\left.\begin{matrix*}[l]
    {\Bigl(x_{n+1}-h\Bigr)^5} & {\Bigl(x_{n+1}-h\Bigr)^6} & {\Bigl(x_{n+1}-h\Bigr)^7} & {\Bigl(x_{n+1}-h\Bigr)^8} & {\Bigl(x_{n+1}-h\Bigr)^9}\\
    5 {\Bigl(x_{n+1} -h\Bigr)^4} & 6 {\Bigl(x_{n+1} -h\Bigr)^5} & 7 {\Bigl(x_{n+1} -h\Bigr)^6} & 8 {\Bigl(x_{n+1}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r)^4} & 6 {\Bigl(x_{n+1}+3h\Bigr)^5} & 7 {\Bigl(x_{n+1}+3h\Bigr)^6} & 8 {\Bigl(x_{n+1}+3h\Bigr)^7} & 9 {\Bigl(x_{n+1}+3h\Bigr)^8}\\
    5 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^4} & 6 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^5} & 7 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^6} & 8 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^7} & 9 {\Bigl(x _{n+1}+ \frac{7}{2}h\Bigr)^8}
\end{matrix*}\right]
\end{multline}
    \end{adjustwidth*}\par
The determinant of the new $D$ matrix is:
\begin{equation}
\det (B) =\frac{15380234690625 h}{64}h^{36}
\end{equation}
The inverse of {\eqref{mat}} is the $C$ matrix, which is calculated using \textbf{wxMaxima} codes as shown in the \textbf{Appendix}.
Our sole interest in the $C$ matrix is its first row and the elements are:
\end{document}
1
  • Thank you so very much!
    – Megamind
    May 10, 2023 at 16:03
5

Your example reports

Overfull \hbox (106.53506pt too wide) detected at line 70

it is more readable if you avoid \resizebox and add some notation for sub terms

enter image description here

\documentclass[fleqn]{book}

%%CreatedwithwxMaxima22.04.0

% probably better to use parskip package
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\usepackage{iftex}
\ifPDFTeX
%PDFLaTeXorLaTeX
% no \usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\DeclareUnicodeCharacter{00B5}{\ensuremath{\mu}}
\else
%XeLaTeXorLuaLaTeX
% no need unless changing fonts \usepackage{fontspec}
\fi
\usepackage{graphicx}
\usepackage{color}
\usepackage{amsmath,amssymb,mathtools}
% no \usepackage{grffile}
\usepackage{ifthen}
\newsavebox{\picturebox}
\newlength{\pictureboxwidth}
\newlength{\pictureboxheight}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
% you  need %  where %%% marked
% there is no need for this as \includegraphics
% already measures the natural size
\newcommand{\includeimage}[1]{%%%
\savebox{\picturebox}{\includegraphics{#1}}
\settoheight{\pictureboxheight}{\usebox{\picturebox}}
\settowidth{\pictureboxwidth}{\usebox{\picturebox}}
\ifthenelse{\lengthtest{\pictureboxwidth>.95\linewidth}}
{%%%
\includegraphics[width=.95\linewidth,height=.80\textheight,keepaspectratio]{#1}%%%
}
{%%%
\ifthenelse{\lengthtest{\pictureboxheight>.80\textheight}}
{%%%
\includegraphics[width=.95\linewidth,height=.80\textheight,keepaspectratio]{#1}%%%
%%%
}
{%%%
\includegraphics{#1}%%%
}
}
}
\newlength{\thislabelwidth}
\DeclareMathOperator{\abs}{abs}

\definecolor{labelcolor}{RGB}{100,0,0}
\begin{document}

Let $y(i)=x_{n+1}+ih$
{\footnotesize
\setlength\arraycolsep{1.6pt} % default: 5pt
\begin{multline}\label{mat}
\hspace*{-0.5cm}
\renewcommand\arraystretch{2.25}
\medmuskip=0mu
D={}\\
\begin{bmatrix}
1 &y(-1) & \!y(-1)^2\! & y(-1)^3 & y(-1)^4 & y(-1)^5 & y(-1)^6 & y(-1)^7 & y(-1)^8 & y(-1)^9\\
0 & 1 & 2 y(-1))  & 3 y(-1)^2 & 4 y(-1)^3 & 5y(-1)^4 & 6 y(-1)^5 & 7 y(-1)^6 & 8 y(-1)^7 & 9 y(-1)^8\\
0 & 1 & 2 y(0)  & 3 y(0)^2 & 4 y(0)^3 & 5 y(0)^4 & 6 y(0)^5 & 7 y(0)^6 & 8 y(0)^7 & 9 y(0)^8\\
0 & 1 & 2y( \frac{1}{2})  & 3y( \frac{1}{2})^2 & 4y( \frac{1}{2})^3 & 5y( \frac{1}{2})^4 & 6y( \frac{1}{2})^5 & 7y( \frac{1}{2})^6 & 8y( \frac{1}{2})^7 & 9y( \frac{1}{2})^8\\
0 & 1 & 2 y(0)  & 3 y(0)^2 & 4 y(0)^3 & 5 y(0)^4 & 6 y(0)^5 & 7 y(0)^6 & 8 y(0)^7 & 9 y(0)^8\\
0 & 1 & 2 y( \frac{3}{2})  & 3y( \frac{3}{2})^2 & 4y( \frac{3}{2})^3 & 5y( \frac{3}{2})^4 & 6y( \frac{3}{2})^5 & 7y( \frac{3}{2})^6 & 8y( \frac{3}{2})^7 & 9y( \frac{3}{2})^8\\
0 & 1 & 2 y(2 )  & 3 y(2 )^2 & 4 y(2 )^3 & 5 y(2 )^4 & 6 y(2 )^5 & 7 y(2 )^6 & 8 y(2 )^7 & 9 y(2 )^8\\
0 & 1 & 2y(\frac{5}{2})  & 3y( \frac{5}{2})^2 & 4y( \frac{5}{2})^3 & 5y( \frac{5}{2})^4 & 6y( \frac{5}{2})^5 & 7y( \frac{5}{2})^6 & 8y( \frac{5}{2})^7 & 9y( \frac{5}{2})^8\\
0 & 1 & 2 y(3)  & 3 y(3)^2 & 4 y(3)^3 & 5 y(3)^4 & 6 y(3)^5 & 7 y(3)^6 & 8 y(3)^7 & 9 y(3)^8\\
0 & 1 & 2 y( \frac{7}{2})  & 3y( \frac{7}{2})^2 & 4y( \frac{7}{2})^3 & 5 y( \frac{7}{2})^4 & 6 y( \frac{7}{2})^5 & 7 y( \frac{7}{2})^6 & 8 y( \frac{7}{2})^7 & 9 y( \frac{7}{2})^8
\end{bmatrix}
\end{multline}

}

The determinant of the new $D$ matrix is:
\begin{equation}det (B) =\frac{15380234690625 h}{64}h^{36}\end{equation}
The inverse of {\eqref{mat}} is the $C$ matrix, which is calculated using \textbf{wxMaxima} codes as shown in the \textbf{Appendix}. 
Our sole interest in the $C$ matrix is its first row and the elements are:

\end{document}
3
  • 1
    det should be \det May 9, 2023 at 19:43
  • +1 for $y(i)=x_{n+1}+ih$.
    – Mico
    May 9, 2023 at 19:47
  • The matrix must appear as it is. Thanks for the suggestion though 😃
    – Megamind
    May 10, 2023 at 2:24

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .