Davide_sd
Davide_sd

Reputation: 13185

Define a symbolic unit vector in SymPy

Let say I want a n-component symbolic real unit vector, where n can be any integer number, let say n=3. That is:

Formula

So far I'm stacked at this very basic point: v = Matrix(symbols("v:3", real=True))

How can I code the normalization condition?

Upvotes: 1

Views: 2571

Answers (1)

user6655984
user6655984

Reputation:

Such assumptions (the sum of squares is 1) are not supported in SymPy. You'll just have to use the equation Eq(v.norm(), 1) in some way, at whatever step of computations requires using the information that v is a unit vector. It's probably easier for SymPy to use the equation in the form Eq(v.norm()**2, 1), without the square root. The details depend on what you want to compute with that vector.

Upvotes: 1

Related Questions