Python Sympy Pretty Output Matrix

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 large to print on the console. I had the same problem with numpy. I could fix it there np.set_printoptions(suppress=True,linewidth=10000) . How can I fix this with sympy?

+6
source share
1 answer

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 the docs ( http://docs.sympy.org/latest/tutorial/printing.html ):

If all you want is the most beautiful print, use the init_printing() function. This will automatically turn on the best printer available in your environment.
If you plan to work in an interactive calculator session, the init_session() function automatically imports everything into SymPy, create some common symbols, set up a schedule and run init_printing() .

enter image description here

+6
source

Source: https://habr.com/ru/post/982710/


All Articles