If you are only interested in a numerical solution, you are better off
using nsolve(). solve() only tries to find a closed-form symbolic
solution, and the solution to this system might not even exist in
closed-form.

For example:

>>> nsolve([eq1,eq2,eq3], [x, y, z], [1j, 1j, 1j])
Matrix([
[0.785398163397448 - 7.44899462227771e-31*I],
[  0.0356339138701676 + 0.615283513362025*I],
[-6.32074851537401e-24 + 1.23056702672405*I]])

Small values can be trimmed to 0 with chop:

>>> _.evalf(chop=True)
Matrix([
[                       0.785398163397448],
[0.0356339138701676 + 0.615283513362025*I],
[                      1.23056702672405*I]])

Here I used a complex starting point since the solution is complex,
and nsolve() typically won't find complex solutions unless the
starting point is complex.

Aaron Meurer

On Thu, Sep 22, 2022 at 10:59 AM Jean Marc Roberge
<[email protected]> wrote:
>
> I am trying to solve 3 trigonometric equation using the solve operation in 
> simply but program never exits loop. per the code below I first calculate the 
> result of the equation using known values (x1,y1,z1) and then use the result 
> of that to as the answer in the equation to solve. the answer should be the 
> x1,z1,z1 values initially used but the loop never ends and provides no result.
> What as I doing incorrectly ?
>
> code used
> import sympy as sym
> from sympy import solve, Eq
> from sympy import sin,cos
> rad=.01745329
> x1=30*rad
> y1=15*rad
> z1=25*rad
> l1=50.00
> l2=50.00
> l3=50.00
> x,y,z= sym.symbols("x,y,z")
>
> print((l2*cos(y1)+l3*cos(z1-y1))*cos(x1))
> print((l2*cos(y1)+l3*cos(z1-y1))*sin(x1))
> print(l1+(l2*sin(y1)-l3*sin(z1-y1)))
>
> eq1 = Eq((l2*cos(y)+l3*cos(z-y))*cos(x),84.4692460844174)
> eq2 = Eq((l2*cos(y)+l3*cos(z-y))*sin(x),84.4692460844174)
> eq3 = Eq((l1+(l2*sin(y)-l3*sin(z-y))),54.2585427870506)
>
> result = solve([eq1,eq2,eq3],[x,y,z])
> print(result)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/9fbad812-2f33-43d5-a33c-b109a97a3d27n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6KHA4Qboi4icC-yYT9S8Xb9RF8QQAEzeFAJ-9q09RV_Sw%40mail.gmail.com.

Reply via email to