Ask Your Question

vector equation solve

asked 2019-10-28 10:39:17 +0200

dimonbavly gravatar image

updated 2019-10-28 18:08:41 +0200

How to solve this?:

F = vector([cos(alpha),sin(alpha),z])
G = vector([z,cos(alpha),sin(alpha)])
A = vector([0,0,0])  
solve(F-G == A)

Answer must be:

edit retag flag offensive close merge delete


Homework ?

Hint: your system is redundant...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-28 22:51:11 +0200 )edit

This is my job and hobby. ...Yes.Simplify the 'y' :

sin(asin(cos(alpha))) == cos(alpha)
dimonbavly gravatar imagedimonbavly ( 2019-10-29 08:00:41 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-29 14:59:46 +0200

Emmanuel Charpentier gravatar image

Okay. On your head be it...

var("alpha, z")
F = vector([cos(alpha),sin(alpha),z])
G = vector([z,cos(alpha),sin(alpha)])
A = vector([0,0,0])
## Replace u==v by u-v (implicitlt ==0).

The system is redundant: the second equation is the sum of the first and the third, or, more swiftly,

sage: L
[-z + cos(alpha), -cos(alpha) + sin(alpha), z - sin(alpha)]

sympy offers some solutions:

sage: SS=solve(L,[z, alpha], algorithm="sympy"); SS
[{alpha: -3/4*pi, z: -1/2*sqrt(2)}, {alpha: 1/4*pi, z: 1/2*sqrt(2)}]

Easy check:

sage: [[e.subs(s) for e in L] for s in SS]
[[0, 0, 0], [0, 0, 0]]

But, are these solutions THE solution ?

Since the system is redundant, Sage's default solver (i. e. Maxima's) will choke (check it yourself). So let's try solve the second equation first:

sage: S1=L[1].solve(alpha); S1
[sin(alpha) == cos(alpha)]

Really ? One can do better (see the docs...)

sage: S1=L[1].solve(alpha, to_poly_solve=True); S1
[alpha == 1/4*pi + pi*z1]

Aha ! We have an infinity of solutions for alpha. What does it gives us for z ?

## Declare z1 as an integer (neither Sage nor Maxima will do that for you : minor pain in the a$$..)
sage: var("z1", domain="integer")
## Solve the first equation for `z`
sage: S0 = L[0].subs(S1).solve(z) ; S0
[z == 1/2*sqrt(2)*(-1)^z1]

We have two possible solutions for z. Check that this gives us valid solutions for the third equation:

sage: L[2].subs(S1).subs(S0)
1/2*sqrt(2)*(-1)^z1 - sin(1/4*pi + pi*z1)

Huh ? Here, it pays to have declared z1 as integer:

sage: L[2].subs(S1).subs(S0).simplify_trig()

Left to the reader as an exercise: alpha and z are bound by z1. Tabulate the results...

More advanced (requires a bit of familiarity with Sage's and Python's modules) : take a result given by Maxima's solver, and retrieve and declare (correctly) the variables created by the solver (useful also for the differential equations solve, etc...)

Brief conclusion of this short story : using a computer to compute solutions does not relieve you of the obligation to think about your problem and its solutions.


edit flag offensive delete link more


Superficially understood. Thank.

dimonbavly gravatar imagedimonbavly ( 2019-11-01 06:25:07 +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: 2019-10-28 10:39:17 +0200

Seen: 1,160 times

Last updated: Oct 29 '19