What version of SymPy are you using? For me in 1.4, solve(omega_nf -
942.5, J_u, dict=True) returns [{J_u: 0.00235331614197392}]
In general, solve() only returns closed-form solutions, so if it
doesn't return a solution, it may just mean that it couldn't find one
in closed-form. If you know that you want a numeric solution, you may
be better off starting with nsolve.
I believe nsolve() gives the wrong answer because you passed
verify=False. Without it, it gives an error that it couldn't find the
root. The default Newton's method solver has a hard time with this
equation, but you can use a different one. For instance,
nsolve(omega_nf - 942.5, [0, 1], solver='bisect') immediately returns
the solution 0.00235331614197389. See the docstring of nsolve.
Aaron Meurer
On Wed, Jun 5, 2019 at 7:20 AM pull_over93 <
mattia.o...@gmail.com> wrote:
>
> Probably I'm not using sympy correctly, here I have this equation :
>
> omega_nf = sqrt(2)*sqrt(87791997.5351708 - 12563210.5479217*sqrt(-0.00144380926150678*J_u + 48.4180817181289*(J_u + 0.00027375075)**2 - 3.58991000729848e-7)/(J_u + 0.00027375075) + 2392.05862861605/(J_u + 0.00027375075))/2
> and I want to solve this equation :
> 942.5 = omega_nf
>
> I have tried the classic sympy.solve()
>
> eq_solution = sym.solve(omega_nf - 942.5 , J_u, dict = True)
>
>
> But I do not have any output.
> Than I've tried using sympy.nsolve()
> eq_solution = sym.nsolve(omega_nf - 942.5, J_u, 0.0023, verify=False)
>
> But I don't get the right answer. (Right answer: J_u = 0.0023)
> There's a smarter way to use sympy ?
>
> --
> 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 post to this group, send email to
sy...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/sympy.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/548b341e-932e-4d6a-a32b-166e29f822c2%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.