Python Sympy Pretty Output of Matrix
python, python-2.7, sympy
Solution
Try `pprint` from sympy:
>>> 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)⎦
From docs(http://docs.sympy.org/latest/tutorial/printing.html):
If all you want is the best pretty printing, use the `init_printing()` function. This will automatically enable the best printer available in your environment. If you plan to work in an interactive calculator-type session, the `init_session()` function will automatically import everything in SymPy, create some common Symbols, setup plotting, and run `init_printing()`.
Problem
``` 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]]) ``` I think the matrix is too big to be pretty printed to console. I had the same problem with numpy, too. I could fix it there with `np.set_printoptions(suppress=True,linewidth=10000)`. How can i fix this with sympy?