如何格式化长多项式

如何格式化长多项式

我有一个长多项式:

\documentclass{article}
%\usepackage{amsmath}% Loaded by mathtools
\usepackage{mathtools}
\begin{document}
$ f(z)=\frac{1}{382112640}(-306772802511648469920\eta^4z^4+762453974480763801600\eta^5z^4-1678626210368271790080\eta^5z^3-28510918043555533736160\eta^4z^3+11443138641451067779872\eta^3z^3-52164076923190540413504\eta^2z^2-78145258181161076156160\eta^5z^2-211306163712129371808450\eta^4z^2+228927087397104405937944\eta^3z^2+999881065017543109136462\eta^3z-317254092617698017425280\eta^5z-443761561344388063474665\eta^4z+82327155732241730770824\eta z-514623285385260545505123\eta^2z-1010535343560043404912120\eta^2-357788302700438191196160\eta^5-43808044579418934376632-214023244873618345872240\eta^4+11818373349781028\\
079\eta^3+347370177721463765064153\eta)/((417420z^2-4169121z-15571312)(1546z+3537)(3092z+17001))$
\end{document}

我该如何正确格式化这么长的多项式?

答案1

我会用这样的东西

\documentclass{article}
%\usepackage{amsmath}% Loaded by mathtools
\usepackage{mathtools}
\begin{document}
Blah blah
\[f(z)=\frac{1}{382112640}\cdot\frac{A}{B}\]
where
\begin{align*}
    A=&\,-306772802511648469920\eta^4z^4+762453974480763801600\eta^5z^4\\
    &\,-1678626210368271790080\eta^5z^3-28510918043555533736160\eta^4z^3\\
    &\,+11443138641451067779872\eta^3z^3-52164076923190540413504\eta^2z^2\\
    &\,-78145258181161076156160\eta^5z^2-211306163712129371808450\eta^4z^2\\
    &\,+228927087397104405937944\eta^3z^2+999881065017543109136462\eta^3z\\
    &\,-317254092617698017425280\eta^5z-443761561344388063474665\eta^4z\\
    &\,+82327155732241730770824\eta z-514623285385260545505123\eta^2z\\
    &\,-1010535343560043404912120\eta^2-357788302700438191196160\eta^5\\
    &\,-43808044579418934376632-214023244873618345872240\eta^4\\
    &\,+11818373349781028079\eta^3+347370177721463765064153\eta
\end{align*}
and
\[B=(417420z^2-4169121z-15571312)(1546z+3537)(3092z+17001)\]
\end{document}

在此处输入图片描述

答案2

我建议按照下面的方法排列,这样可以减少宽泛的术语。

\documentclass{article}
%\usepackage{amsmath}% Loaded by mathtools
\usepackage{mathtools}

\begin{document}

\begin{gather*}
\begin{align*}
g(\eta,z)&=
\parbox[t]{0.85\displaywidth}{\raggedright
$-306772802511648469920\eta^4z^4+
762453974480763801600\eta^5z^4-
1678626210368271790080\eta^5z^3-
28510918043555533736160\eta^4z^3+
11443138641451067779872\eta^3z^3-
52164076923190540413504\eta^2z^2-
78145258181161076156160\eta^5z^2-
211306163712129371808450\eta^4z^2+
228927087397104405937944\eta^3z^2+
999881065017543109136462\eta^3z-
317254092617698017425280\eta^5z-
443761561344388063474665\eta^4z+
82327155732241730770824\eta z-
514623285385260545505123\eta^2z-
1010535343560043404912120\eta^2-
357788302700438191196160\eta^5-
43808044579418934376632-
214023244873618345872240\eta^4+
11818373349781028079\eta^3+
347370177721463765064153\eta$
}
\\[2ex]
h(z)&=(417420z^2-4169121z-15571312)(1546z+3537)(3092z+17001)
\end{align*}
\\[2ex]
f(z)=\frac{1}{382112640}\frac{g(\eta,z)}{h(z)}
\end{gather*}

\end{document}

在此处输入图片描述

答案3

考虑到运算的性质,您可以使用矩阵乘法符号以整洁的方式表达这一点,例如:

在哪里:

代码:

$$ f(z)=\frac{1}{382,112,640} \; \frac{g(\eta, z)}{u(z) \, v(z) \, w(z) } $$

where

$$
\begin{array}{ll}
  g(\eta, z) = 
  \begin{bmatrix} 
    \begin{array}{r @{\hspace{0em}} r}
      - & 306,772,802,511,648,469,920 \\
        & 762,453,974,480,763,801,600 \\
      - & 1,678,626,210,368,271,790,080 \\
      - & 28,510,918,043,555,533,736,160 \\
       & 11,443,138,641,451,067,779,872 \\
      - & 52,164,076,923,190,540,413,504 \\
      - & 78,145,258,181,161,076,156,160 \\
      - & 211,306,163,712,129,371,808,450 \\
       & 228,927,087,397,104,405,937,944 \\
       & 999,881,065,017,543,109,136,462 \\
      - & 317,254,092,617,698,017,425,280 \\
      - & 443,761,561,344,388,063,474,665 \\
       & 82,327,155,732,241,730,770,824 \\
      - & 514,623,285,385,260,545,505,123 \\
      - & 1,010,535,343,560,043,404,912,120 \\
      - & 357,788,302,700,438,191,196,160 \\
      - & 43,808,044,579,418,934,376,632 \\
      - & 214,023,244,873,618,345,872,240 \\
       & 11,818,373,349,781,028,079 \\
       & 347,370,177,721,463,765,064,153
    \end{array}
  \end{bmatrix}^T
  \begin{bmatrix}
    \begin{array}{l}
      \eta^4z^4 \\
      \eta^5z^4 \\
      \eta^5z^3 \\
      \eta^4z^3 \\
      \eta^3z^3 \\
      \eta^2z^2 \\
      \eta^5z^2 \\
      \eta^4z^2 \\
      \eta^3z^2 \\
      \eta^3z \\
      \eta^5z \\
      \eta^4z \\
      \eta z \\
      \eta^2z \\
      \eta^2 \\
      \eta^5 \\
      1 \\
      \eta^4 \\
      \eta^3 \\
      \eta
    \end{array}
  \end{bmatrix}
  & 
  \begin{array}{l}
    u(z) = \begin{bmatrix} \begin{array}{r @{\hspace{0em}} r} & 417,420 \\ - & 4,169,121 \\ - & 15,571,312 \end{array}\end{bmatrix}^T \begin{bmatrix} \begin{array}{l} z^2 \\ z \\ 1 \end{array}\end{bmatrix}\\[3em]
    v(z) = \begin{bmatrix} \begin{array}{r @{\hspace{0em}} r}  & 1,546 \\ & 3,537 \end{array}\end{bmatrix}^T \begin{bmatrix}\begin{array}{l} z \\ 1 \end{array}\end{bmatrix}\\[3em]
    w(z) = \begin{bmatrix}\begin{array}{r @{\hspace{0em}} r}  & 3,092 \\ & 17,001 \end{array}\end{bmatrix}^T \begin{bmatrix}\begin{array}{l} z \\ 1 \end{array}\end{bmatrix} \\[3em]
  \end{array}
\end{array}
$$

PS. 话虽如此,考虑到所涉及数字的性质,我也会同意 Mefitico 在评论中的观点,即最好创建一个带有索引的变量并通过更清晰的表达式来表达,然后参考将这些索引映射到所涉及的实际数字的表格。

答案4

我建议对齐变量并添加某种形式的千位分隔符,这两种方法都可以提高可读性。我还建议(但这里没有这样做)按第一个变量的幂排序,然后按第二个变量的幂排序。这是对JuleV 的回答。

\documentclass{article}
%\usepackage{amsmath}% Loaded by mathtools
\usepackage{mathtools}
\begin{document}
Blah blah
\[f(z)=\frac{1}{382112640}\cdot\frac{A}{B}\]
where
\[
\arraycolsep=0.5pt
\begin{array}{rrllrll}
    A=&\,      -306\,772\,802\,511\,648\,469\,920 &\eta^4 &z^4 &      +762\,453\,974\,480\,763\,801\,600 &\eta^5 &z^4\\
    &\,     -1\,678\,626\,210\,368\,271\,790\,080 &\eta^5 &z^3 &  -2\,8510\,918\,043\,555\,533\,736\,160 &\eta^4 &z^3\\
    &\,    +11\,443\,138\,641\,451\,067\,779\,872 &\eta^3 &z^3 &  -5\,2164\,076\,923\,190\,540\,413\,504 &\eta^2 &z^2\\
    &\,    -78\,145\,258\,181\,161\,076\,156\,160 &\eta^5 &z^2 & -21\,1306\,163\,712\,129\,371\,808\,450 &\eta^4 &z^2\\
    &\,   +228\,927\,087\,397\,104\,405\,937\,944 &\eta^3 &z^2 & +99\,9881\,065\,017\,543\,109\,136\,462 &\eta^3 &z\\
    &\,   -317\,254\,092\,617\,698\,017\,425\,280 &\eta^5 &z   & -44\,3761\,561\,344\,388\,063\,474\,665 &\eta^4 &z\\
    &\,    +82\,327\,155\,732\,241\,730\,770\,824 &\eta   &z   & -51\,4623\,285\,385\,260\,545\,505\,123 &\eta^2 &z\\
    &\,-1\,010\,535\,343\,560\,043\,404\,912\,120 &\eta^2 &    & -35\,7788\,302\,700\,438\,191\,196\,160 &\eta^5 &\\
    &\,    -43\,808\,044\,579\,418\,934\,376\,632 &       &    & -21\,4023\,244\,873\,618\,345\,872\,240 &\eta^4 &\\
    &\,         +11\,818\,373\,349\,781\,028\,079 &\eta^3 &    & +34\,7370\,177\,721\,463\,765\,064\,153 &\eta   &
\end{array}
\]
and
\[B=(417\,420z^2-4\,169\,121z-15\,571\,312)(1\,546z+3\,537)(3\,092z+17\,001)\]
\end{document}

我确信也有一些自定义包可以为您做到这一点,但这只是使用您提供的包:

在此处输入图片描述

相关内容