Matrix([[607000, 907, 259, -2165, -1846, 185, -60, -1593, 1445, 1405], [-1000, -2, 0, -1, 0, 0, -1, 0, 0, -1], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-4000, -7, -3, 5, 4, 1, -1, 4, -4, -2], [-317000, -469, -128, 1173, 1001, -105, 35, 862, -772, -771], [-70000, -105, -32, 246, 209, -19, 7, 180, -166, -157], [8000, 14, 6, -10, -9, -1, -1, -8, 9, 4], [-540000, -807, -230, 1925, 1642, -166, 56, 1418, -1284, -1249], [-328000, -488, -137, 1189, 1017, -104, 36, 872, -785, -776], [-70000, -105, -31, 246, 208, -21, 6, 179, -166, -157]])

我认为矩阵太大,无法漂亮地打印到控制台。我也遇到了与numpy相同的问题。我可以用np.set_printoptions(suppress=True,linewidth=10000)在那里修复它。我该如何用sympy解决这个问题?

最佳答案

从sympy尝试pprint:

>>> from sympy import Integral, Matrix, pi, pprint
>>> from sympy.abc import x
>>> pprint(Integral(x**2, x))
  /
 |
 |  2
 | x  dx
 |
/

>>> pprint(Matrix([
...   [1/(4*pi), 1],
...   [1, f(x)]
... ]))
⎡ 1       ⎤
⎢───   1  ⎥
⎢4⋅π      ⎥
⎢         ⎥
⎣ 1   f(x)⎦

从docs(http://docs.sympy.org/latest/tutorial/printing.html):

关于Python Sympy矩阵的漂亮输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28594618/

10-12 18:22
查看更多