solving simultaneous equations involving sine and cosine functions

14 views
Skip to first unread message

Ash

unread,
Sep 13, 2019, 6:00:51 AM9/13/19
to sympy
Hello,
I have the following minimal working example for solving a system of simultaneous non-linear equations. Angles, ang_xs, ang_ys, and ang_zs are dynamic in nature but for this particular instant, I am trying to solve A = [0, 0, 0]^T. This returns an error "can't convert oo to int". Could anyone suggest a solution please? Also, is there a way to set anything less than 1e-6 to be zero?

from sympy import *
from sympy.physics.mechanics import *


ang_xs, ang_ys, ang_zs = dynamicsymbols("ang_xs ang_ys ang_zs ")
A = Matrix( [
                 [1.005e-14*sin(ang_zs + pi/4)*cos(ang_ys)],
                 [1.005e-14*sin(ang_zs + pi/4)*sin(ang_xs)*sin(ang_ys) - 1.005e-14*cos(ang_zs + pi/4)*cos(ang_xs)],
                 [-1.005e-14*sin(ang_zs + pi/4)*sin(ang_ys)*cos(ang_xs) - 1.005e-14*sin(ang_xs)*cos(ang_zs + pi/4)]
                 ])
p = (ang_xs, ang_ys, ang_zs)
eq1, eq2, eq3 = Eq(A[0]), Eq(A[1]), Eq(A[2])
ang_xs, ang_ys, ang_zs = solve([eq1, eq2, eq3], p)


Thanks
Ash

Oscar Benjamin

unread,
Sep 13, 2019, 6:17:33 AM9/13/19
to sympy
This is a bug. Can you open an issue on github please?
https://github.com/sympy/sympy/issues

The error comes from:

In [2]: factor_terms(pi/4+oo*I)
---------------------------------------------------------------------------
TypeError: can't convert oo to int

Probably another error has left to that in the first place though.

I removed the floats from your problem since they aren't needed and
used check=False, simplify=False with solve to avoid calling simplify
(which is ultimately calling factor_terms). Then I get an answer
(using master):


⎛ ⎛ ⎛ang_zs(t) π⎞ ⎞

⎜ ⎜tan⎜───────── + ─⎟ + 1⎟
⎢⎛π -π ⎞ ⎛π 3⋅π⎞ ⎛3⋅π -π ⎞ ⎛3⋅π
3⋅π⎞ ⎜ ⎜ ⎝ 2 8⎠ ⎟ π
⎢⎜─, ang_ys(t), ───⎟, ⎜─, ang_ys(t), ───⎟, ⎜───, ang_ys(t), ───⎟,
⎜───, ang_ys(t), ───⎟, ⎜2⋅atan⎜──────────────────────⎟, ─, ang
⎢⎝2 4 ⎠ ⎝2 4 ⎠ ⎝ 2 4 ⎠ ⎝ 2
4 ⎠ ⎜ ⎜ ⎛ang_zs(t) π⎞ ⎟ 2

⎜ ⎜tan⎜───────── + ─⎟ - 1⎟

⎝ ⎝ ⎝ 2 8⎠ ⎠

⎞ ⎛ ⎛ ⎛ang_zs(t) π⎞ ⎞ ⎞⎤
⎟ ⎜ ⎜tan⎜───────── + ─⎟ - 1⎟ ⎟⎥
⎟ ⎜ ⎜ ⎝ 2 8⎠ ⎟ π ⎟⎥
_zs(t)⎟, ⎜-2⋅atan⎜──────────────────────⎟, ─, ang_zs(t)⎟⎥
⎟ ⎜ ⎜ ⎛ang_zs(t) π⎞ ⎟ 2 ⎟⎥
⎟ ⎜ ⎜tan⎜───────── + ─⎟ + 1⎟ ⎟⎥
⎠ ⎝ ⎝ ⎝ 2 8⎠ ⎠ ⎠⎦


Oscar
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/f1cbbc4f-ff1c-4410-bea1-7a3b3cb9676e%40googlegroups.com.

Ashith Shyam

unread,
Sep 13, 2019, 6:30:11 AM9/13/19
to sy...@googlegroups.com
Thanks Oscar. Opened a new issue in github.

Ash



--
Reply all
Reply to author
Forward
0 new messages