I have seen issues 1019 and 1052 on how to handle printing of sig. digits but haven't seen a solution. I am running the attached script and getting things like pH = [ 950000.000000000] [-400000.000000000] [ 600000.000000000]
I preprocessing this script with another python script and inserting the values returned from latex() into a latex document, and some of the equations are running off the page. How do I set the global printing precision to make things look nicer? Thanks, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
from sympy import * #section{Problem 1} var('H partH alpha omega omegax omegay omegaz alphax alphay alphaz Ixx Iyy Izz Ixy Ixz Iyz') def S(H,partH,alpha,omega): return 1.0/2*alpha.dot(partH)+alpha.dot(omega.cross(H)) def HA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,omegax,omegay,omegaz): H = [(Ixx*omegax-Ixy*omegay-Ixz*omegaz),\ (Iyy*omegay-Ixy*omegax-Iyz*omegaz),\ (Izz*omegaz-Ixz*omegax-Iyz*omegay)] return Matrix(H) def partHA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,alphax,alphay,alphaz): pH = [(Ixx*alphax-Ixy*alphay-Ixz*alphaz),\ (Iyy*alphay-Ixy*alphax-Iyz*alphaz),\ (Izz*alphaz-Ixz*alphax-Iyz*alphay)] return Matrix(pH) H = HA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,omegax,omegay,omegaz) pH = partHA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,alphax,alphay,alphaz) omega = Matrix([omegax,omegay,omegaz]) alpha = Matrix([alphax,alphay,alphaz]) S1 = S(H,pH,alpha,omega) print 'H = ' pprint(H) print 'pH = ' pprint(pH) print 'S = ' pprint(S1) omegax = -50.0 omegay = 0 omegaz = -20.0 alphax = 1500.0 alphay = -500.0 alphaz = 1000.0 Ixx = 500.0 Iyy = 800.0 Izz = 300.0 Ixz = -200.0 Ixy = 0 Iyz = 0 alpha = Matrix([alphax,alphay,alphaz]) omega = Matrix([alphax,alphay,alphaz]) H = HA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,omegax,omegay,omegaz) pH = partHA(Ixx,Iyy,Izz,Ixy,Ixz,Iyz,alphax,alphay,alphaz) omega = Matrix([omegax,omegay,omegaz]) alpha = Matrix([alphax,alphay,alphaz]) S = S(H,pH,alpha,omega) print 'H = ' pprint(H) print 'pH =' pprint(pH) print 'S = ' print(S)