Ask Your Question

Solving linear matrix equations

asked 2014-11-30 19:35:22 +0200

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:


to isolate and obtain the value of psi_d.

How can I do that?

Thank you very much

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-30 20:12:04 +0200

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:

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:


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.

edit flag offensive delete link more


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 ( 2014-11-30 20:44:55 +0200 )edit

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 ( 2014-12-01 04:24:28 +0200 )edit

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 ( 2014-12-01 04:25:28 +0200 )edit

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):


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 ( 2014-12-02 17:10:41 +0200 )edit

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 ( 2014-12-03 02:38:35 +0200 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2014-11-30 19:35:22 +0200

Seen: 1,012 times

Last updated: Nov 30 '14