https://github.com/sympy/sympy/issues/25768

On Thursday, October 5, 2023 at 11:07:53 AM UTC-5 Oscar wrote:

> This is a bug. Can you open an issue with sympy on GitHub?
>
> The correct answer is given if you use exact rational numbers (S(1)/2
> or Rational(1, 2)) rather than the float 1/2:
>
> In [6]: solveset(Eq(sin(x), S(1)/2), x, Reals)
> Out[6]:
> ⎧ 5⋅π │ ⎫ ⎧ π │ ⎫
> ⎨2⋅n⋅π + ─── │ n ∊ ℤ⎬ ∪ ⎨2⋅n⋅π + ─ │ n ∊ ℤ⎬
> ⎩ 6 │ ⎭ ⎩ 6 │ ⎭
>
> The problem is that solveset solves this in an overly complicated way
> using complex numbers even if the domain is reals. Then a small
> rounding error makes it look like the solutions are not real.
>
> --
> Oscar
>
> On Thu, 5 Oct 2023 at 16:45, Kevin Moore <kevi...@gmail.com> wrote:
> >
> > Hello - I'm trying to use Sympy Live to debug an issue with a program 
> I'm writing. When I try to use solveset for sin(x)=1/2, I get no solutions. 
> Apparently it thinks there's a tiny complex portion to the solution.
> >
> > Why am I running into this? Ironically I'm not running into this problem 
> in my own script - maybe it's a version issue?
> >
> > Kevin
> >
> >
> >
> > solveset(Eq(sin(x),1/2),x,S.Reals)
> > ∅
> >
> > solveset(Eq(sin(x),1/2),x,S.Complexes)
> > 
> {−i(i(2nπ+0.523598775598299)−1.11022302462516⋅10−16)∣∣n∈Z}∪{−i(i(2nπ−0.523598775598299+π)−1.11022302462516⋅10−16)∣∣n∈Z}
> >
> > --
> > 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/c98b1ad9-133b-484d-860a-00c48a7d339en%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/5c8663ec-ad06-4516-bb9a-03e4f0d30621n%40googlegroups.com.

Reply via email to