Ask Your Question
0

Solving linear matrix equations

asked 10 years ago

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi everybody, I'm new to Sage and I'm pretty confused with the solving of matrix equations, I didn't fully understand the guide.

I've got these vectors:

V_fa = vector([V_f*cos(phi), V_f*sin(phi), 0])

V_ra = vector([V, 0, 0])

omega = vector([0, 0, L*psi_d])

P = vector([0, L*psi_d, 0])

And i want to implement the equation:

V_fa=V_ra+omega.cross_product(P)

to isolate and obtain the value of psi_d.

How can I do that?

Thank you very much

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

calc314 gravatar image

I think you are asking for a system from this vector equation that you can then get Sage to solve. To create such a system, try:

ans1=V_ra+omega.cross_product(P)
sys=[ans1[i]==V_fa[i] for i in range(0,3)]

Then, you get the result:

[-L^2*psi_d^2 + V == V_f*cos(phi), 0 == V_f*sin(phi), 0 == 0]

Solving the first equation for psi_d can be done by:

solve(sys[0],psi_d)

and gives:

[psi_d == -sqrt(-V_f*cos(phi) + V)/L, psi_d == sqrt(-V_f*cos(phi) + V)/L]

Sage does not seem to like the idea of solving all three equations at once. You might be able to avoid this by specifying more information about phi.

Preview: (hide)
link

Comments

Thank you for your reply! What kind of information do i need to specify? It's an angle, so do i have to declare it as a real?

Also, when i do solve(sys[0],psi_d)

it gives : TypeError: 'module' object has no attribute '__getitem__' what does it mean?

Silvia gravatar imageSilvia ( 10 years ago )

I'm not sure about that error. I'm assuming you did something like var('V_f, phi, V, L, psi_d') at the beginning of your work.

calc314 gravatar imagecalc314 ( 10 years ago )

I've not been successful with getting the solving to work when the two nontrivial equations are both involved. Sage (actually Maxima) seems to be having some sort of issue with this case. It's got me baffled.

calc314 gravatar imagecalc314 ( 10 years ago )

I think the problem is in sys[0], actually if i do show(sys[0]) it gives the same errore message. i tried writing

for i in range (0,3):

sys[i]=[ans1[i]==rV_fa[i]]

but it says TypeError: 'module' object does not support item assignment. What does it means?

How can I fix it? It seems a very simple operation to me but i can't understand what it is that I'm doing wrong.

Silvia gravatar imageSilvia ( 10 years ago )

I think you might have imported the python module sys at some point in your worksheet. In that case, you cannot use sys as a variable name. Try changing that variable name to something else and see if that resolves the error.

In addition, the code you suggested above will not assign things to sys[i] unless you initialize the sys variable as a list with 3 objects. This is the reason you are getting the error in this case.

calc314 gravatar imagecalc314 ( 10 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 10 years ago

Seen: 1,476 times

Last updated: Nov 30 '14