Make matrix inside equation fit the page width in LyX

I have a matrix that is a bit too wide to fit inside my page width.

After reading a lot of different answers on the Internet, none really related to LyX, I came up with these three different solutions, all of them involve inserting an ERT (raw LaTeX code, in this case all the lines before and after ). Here is the image:

I don't know if other possibilities also work and which are the advantages or disadvantages, from each method.

The LaTeX source for all this is:

\noindent\makebox[\textwidth]{%
\tiny%
\begin{minipage}[t]{1\columnwidth}%
$$Q=\begin{pmatrix}0.00301472 & -0.0961879 & -0.00897697 & 0.0389941 & -0.860642 & 0.0131329 & -4.73786 & -0.00552858\\ -0.028584 & 0.615003 & 0.111671 & -0.371008 & 4.94379 & -0.138279 & 20.3258 & 0.0512362\\ 0.0132728 & -0.345125 & -0.0701132 & 0.115389 & -3.11777 & 0.102871 & -16.9949 & -0.0408223\\ 2.91757 & 1.03545 & -5.16595 & 1.69976 & -22.1649 & 4.33453 & 120.513 & -1.35074\\ 0.867566 & 2.92363 & -1.14174 & 3.4356 & -2.96193 & 1.91413 & -113.348 & -0.684269 \end{pmatrix}$$
%
\end{minipage}}

\resizebox{\textwidth}{!}{%
\tiny%
\begin{minipage}[t]{1\columnwidth}%
$$Q_{ij}=\left(\begin{array}{cccccccc} 0.00301472 & -0.0961879 & -0.00897697 & 0.0389941 & -0.860642 & 0.0131329 & -4.73786 & -0.00552858\\ -0.028584 & 0.615003 & 0.111671 & -0.371008 & 4.94379 & -0.138279 & 20.3258 & 0.0512362\\ 0.0132728 & -0.345125 & -0.0701132 & 0.115389 & -3.11777 & 0.102871 & -16.9949 & -0.0408223\\ 2.91757 & 1.03545 & -5.16595 & 1.69976 & -22.1649 & 4.33453 & 120.513 & -1.35074\\ 0.867566 & 2.92363 & -1.14174 & 3.4356 & -2.96193 & 1.91413 & -113.348 & -0.684269 \end{array}\right)$$
%
\end{minipage}}

\noindent%
\begin{minipage}[t]{1\textwidth}%
\tiny
$$Q=\begin{pmatrix}0.00301472 & -0.0961879 & -0.00897697 & 0.0389941 & -0.860642 & 0.0131329 & -4.73786 & -0.00552858\\ -0.028584 & 0.615003 & 0.111671 & -0.371008 & 4.94379 & -0.138279 & 20.3258 & 0.0512362\\ 0.0132728 & -0.345125 & -0.0701132 & 0.115389 & -3.11777 & 0.102871 & -16.9949 & -0.0408223\\ 2.91757 & 1.03545 & -5.16595 & 1.69976 & -22.1649 & 4.33453 & 120.513 & -1.35074\\ 0.867566 & 2.92363 & -1.14174 & 3.4356 & -2.96193 & 1.91413 & -113.348 & -0.684269 \end{pmatrix}$$
%
\end{minipage}


Is there a simpler way of doing this in LyX, for example without using the \tiny command and inserting boxes inside boxes? Can't LaTeX simply determine when a matrix is too big and rescale it to fit the page?

This is how it looks like in the output: 2

-
Welcome to TeX-SX Santi. Please make sure that all images are uploaded using the official SX interface, i.e. the image icon on top of the text field (shortcut: CTRL+G). This ensures that all images are always accessible and do not expire. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. –  percusse Mar 23 '13 at 16:34
The simple answer is "no." In some way, you have to wrap the scaled content in something different (than just equation, say) to absorb the content, decide whether it'll fit, and then rescale/-size it. Why is using ERTs not cool? –  Werner Mar 23 '13 at 17:05
Actually it is nice to be able to use ERTs, I just wonder that for new users it might be a bit of a learning curve. I added now the pdf output link (it doesn't really look like that, I just pasted all the 3 matrices on an image) to be able to compare with the answer below of @Mico –  Santi Mar 23 '13 at 17:51

You may want to consider whether it's absolutely necessary to show up to 8 digits after the decimal point in order to convey the message you intend to send. If you can make do with, say, 4 digits after the decimal, you could use the siunitx package and its S column type to show the matrix in the form shown below. Note that it's not necessary to round and truncate the numbers by hand; siunitx will take of this job for you.

Incidentally, if the S column type is used, all numbers are aligned on the decimal points -- presumably a desirable thing, right? Note that with these modifications, it's not necessary at all to reduce the font size.

\documentclass{article}
\usepackage[margin=1in]{geometry} %
\usepackage{siunitx}
\sisetup{round-mode=places,    % enable rounding
round-precision=4,       % amounts of digits for rounding
table-format=2.4}  % default numeric format
\begin{document}
$$Q_{ij}=\left( \begin{array}{*{4}{S}S[table-format=3.4] S S[table-format=4.4] S} % non-default values for "table-format" for column 5 and 7 0.00301472 & -0.0961879 & -0.00897697 & 0.0389941 & -0.860642 & 0.0131329 & -4.73786 & -0.00552858\\ -0.028584 & 0.615003 & 0.111671 & -0.371008 & 4.94379 & -0.138279 & 20.3258 & 0.0512362\\ 0.0132728 & -0.345125 & -0.0701132 & 0.115389 & -3.11777 & 0.102871 & -16.9949 & -0.0408223\\ 2.91757 & 1.03545 & -5.16595 & 1.69976 & -22.1649 & 4.33453 & 120.513 & -1.35074\\ 0.867566 & 2.92363 & -1.14174 & 3.4356 & -2.96193 & 1.91413 & -113.348 & -0.684269 \end{array} \right)$$
\end{document}

-
This is a really nice solution, thanks for the info, I didn't know about the package. I will see if it is really necessary to have so many decimal digits, I have to compare several matrices and all the numbers are small. –  Santi Mar 23 '13 at 17:52
@Santi - If you have some columns that have really small numbers, which may make it necessary to show either 5 or 6 decimal places to display the numbers adequately, you can always override the overall default column specifications for those particular columns, by using a column specifier such as S[round-precision=6, table-format=2.6]. Note that in the MWE I gave, I overrode the default specification for S for two columns that featured larger numbers (with 2 or even 3 digits in front of the decimal). –  Mico Mar 23 '13 at 18:27
Yes, I noticed your detailed answer for column 5 and 7. Thanks a lot. Does it also work with numbers in scientific notation? –  Santi Mar 23 '13 at 23:29
@Santi - there are indeed quite a few options related to scientific notation display. The package's user guide is very detailed and well written. –  Mico Mar 23 '13 at 23:53