Ask Your Question
0

vector equation solve

asked 2019-10-28 04:39:17 -0600

updated 2019-10-28 12:08:41 -0600

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:

[cos(asin(cos(alpha))),
sin(asin(cos(alpha))),
sin(alpha)]
edit retag flag offensive close merge delete

Comments

Homework ?

Hint: your system is redundant...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-28 16:51:11 -0600 )edit

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

sin(asin(cos(alpha))) == cos(alpha)
dimonbavly gravatar imagedimonbavly ( 2019-10-29 02:00:41 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-10-29 08:59:46 -0600

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).
L=list(F-G-A)

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)]
sum(L)
0

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")
z1
## 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()
0

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.

HTH,

edit flag offensive delete link more

Comments

Superficially understood. Thank.

dimonbavly gravatar imagedimonbavly ( 2019-11-01 00:25:07 -0600 )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

Stats

Asked: 2019-10-28 04:39:17 -0600

Seen: 47 times

Last updated: Oct 29