Re: [sympy] solving simultaneous equations involving sine and cosine functions

2019-09-13 Thread Ashith Shyam
Thanks Oscar. Opened a new issue in github.

Ash

On Fri, Sep 13, 2019 at 11:17 AM Oscar Benjamin 
wrote:

> 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
>
> On Fri, 13 Sep 2019 at 11:00, Ash  wrote:
> >
> > 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
> >
> > --
> > 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+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/f1cbbc4f-ff1c-4410-bea1-7a3b3cb9676e%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 sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAHVvXxSFwRVgw9rtRiHjiJa%3DgykyeGz0jiQwtwsspGNJBmbyXg%40mail.gmail.com
> .
>


-- 
R.B. Ashith Shyam 
+44 7459909812

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAGassLCX%2Bye_mGSta6%3DMpLK5DNJmGJfW7ZaGfJyA_hCP5YBebw%40mail.gmail.com.


Re: [sympy] solving simultaneous equations involving sine and cosine functions

2019-09-13 Thread Oscar Benjamin
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

On Fri, 13 Sep 2019 at 11:00, Ash  wrote:
>
> 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
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/f1cbbc4f-ff1c-4410-bea1-7a3b3cb9676e%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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxSFwRVgw9rtRiHjiJa%3DgykyeGz0jiQwtwsspGNJBmbyXg%40mail.gmail.com.


[sympy] solving simultaneous equations involving sine and cosine functions

2019-09-13 Thread Ash
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

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