on-internet
← Community

Treating vectors as entire symbolic objects using SymPy

Stack Overflow ·

I'm using Sympy to verify some physics calculations I'm doing. The way Sympy handles vectors (entirely as sums of basis vectors) is aesthetically annoying to me and makes my results harder to parse. Simplified example of what I'm doing: import sympy as sp from sympy.vector import CoordSys3D # set up vectors R3 = CoordSys3D('R3') Ex, Ey, Ez = sp.symbols("E_x E_y E_z") E = Ex * R3.i + Ey * R3.j + Ez * R3.k Hx, Hy, Hz = sp.symbols("H_x H_y H_z") H = Hx * R3.i + Hy * R3.j + Hz * R3.k nx, ny, nz = sp.symbols("n_x n_y n_z") n = nx * R3.i + ny * R3.j + nz * R3.k # do my calculations n.cross(E) + E Th

Comments

Sign in or sign up to comment and upvote.

No comments yet.