Re: [sympy] Problem in solving non linear equation equation

2019-06-06 Thread Oscar Benjamin
SymPy will find the solution eventually I think.

This is a polynomial of order 8 having only even powers so with a
substitution omega**2 -> x it's a quartic in x with complicated
symbolic coefficients. The general formula for a quartic is horrendous
and in this case your coefficients are already large expressions.

What this means is that the solution will take a while to compute and
will probably be too complicated to be useful when done anyway. Really
complicated analytic expressions can be difficult to use without
substituting numeric values in and it's much easier to find the roots
if you substitute the numbers in first.

I'm not sure why it is so slow though. You can get to the solutions
for omega^2 like this:

In [39]: coeffs = Poly(omega_nf_eq.rhs.subs(omega, sqrt(x)),
x).coeffs()

In [40]: a, b, c, d, e = symbols('a, b, c, d, e')

In [41]: p = Poly(a*x**4+b*x**3+c*x**2+d*x+e, x)

In [42]: rs = solve(p, x)

Print the first root:

In [43]: rs[0].subs(zip((a,b,c,d,e), coeffs))

(output omitted as it's long and complicated)


My suggestion is to consider why you need the solutions to this
equation. There may be a better way to reach your actual end goal then
getting the solutions in explicit analytic form.

--
Oscar

On Fri, 7 Jun 2019 at 00:13, pull_over93  wrote:
>
> Hi everybody, I'm tring to solve this equation without succes: omega_nf_eq = 0
>
> import sympy as sym
> m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2
>  = 
> sym.symbols('m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2',
>  real  = True)
> t, omega_nf = sym.symbols('t, omega_nf', real = True)
>
> omega_nf_eq = sym.Eq(omega_nf, -J_d**2*k_yy*k_zz*omega**4 + 
> 0.382*J_d**2*k_yy*omega**6 + 0.382*J_d**2*k_zz*omega**6 - 
> 0.145924*J_d**2*omega**8 + J_d*k_phiphi*k_yy*k_zz*omega**2 - 
> 0.382*J_d*k_phiphi*k_yy*omega**4 - 0.382*J_d*k_phiphi*k_zz*omega**4 + 
> 0.145924*J_d*k_phiphi*omega**6 + J_d*k_thetatheta*k_yy*k_zz*omega**2 - 
> 0.382*J_d*k_thetatheta*k_yy*omega**4 - 0.382*J_d*k_thetatheta*k_zz*omega**4 + 
> 0.145924*J_d*k_thetatheta*omega**6 - J_d*k_yphi**2*k_zz*omega**2 + 
> 0.382*J_d*k_yphi**2*omega**4 - J_d*k_yy*k_ztheta**2*omega**2 + 
> 0.382*J_d*k_ztheta**2*omega**4 + J_p**2*Omega**2*k_yy*k_zz*omega**2 - 
> 0.382*J_p**2*Omega**2*k_yy*omega**4 - 0.382*J_p**2*Omega**2*k_zz*omega**4 + 
> 0.145924*J_p**2*Omega**2*omega**6 - k_phiphi*k_thetatheta*k_yy*k_zz + 
> 0.382*k_phiphi*k_thetatheta*k_yy*omega**2 + 
> 0.382*k_phiphi*k_thetatheta*k_zz*omega**2 - 
> 0.145924*k_phiphi*k_thetatheta*omega**4 + k_phiphi*k_yy*k_ztheta**2 - 
> 0.382*k_phiphi*k_ztheta**2*omega**2 + k_thetatheta*k_yphi**2*k_zz - 
> 0.382*k_thetatheta*k_yphi**2*omega**2 - k_yphi**2*k_ztheta**2)
>
> solution = sym.solve(omega_nf_eq.rhs, omega, dict = True , force=True, 
> manual=True, set=True)
>
> Even after half an hour, sympy is unable to give a solution.
> I also tried sage math, but I had the same failure.
> Suggestions?
>
> --
> 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 post to this group, send email to sympy@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/a4ebc67b-3e40-448b-b6a3-5500f6b9dab3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to sympy@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/CAHVvXxSfe3rvn9V38YkJ%3DsZgnmeN1bFpu6j5wV0f%3DhBmbWtsWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Problem in solving non linear equation equation

2019-06-06 Thread pull_over93
Hi everybody, I'm tring to solve this equation without succes: omega_nf_eq 
= 0

import sympy as sym
m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2
 
= 
sym.symbols('m,J_d,J_p,y,Y,omega,Omega,phi,Phi,z,Z,theta,Theta,k_yy,k_zz,k_phiphi,k_yphi,k_ztheta,k_thetatheta,plane_xy1,plane_xy2,plane_xz1,plane_xz2',
 
real  = True) 
t, omega_nf = sym.symbols('t, omega_nf', real = True)

omega_nf_eq = sym.Eq(omega_nf, -J_d**2*k_yy*k_zz*omega**4 + 
0.382*J_d**2*k_yy*omega**6 + 0.382*J_d**2*k_zz*omega**6 - 
0.145924*J_d**2*omega**8 + J_d*k_phiphi*k_yy*k_zz*omega**2 - 
0.382*J_d*k_phiphi*k_yy*omega**4 - 0.382*J_d*k_phiphi*k_zz*omega**4 + 
0.145924*J_d*k_phiphi*omega**6 + J_d*k_thetatheta*k_yy*k_zz*omega**2 - 
0.382*J_d*k_thetatheta*k_yy*omega**4 - 0.382*J_d*k_thetatheta*k_zz*omega**4 
+ 0.145924*J_d*k_thetatheta*omega**6 - J_d*k_yphi**2*k_zz*omega**2 + 
0.382*J_d*k_yphi**2*omega**4 - J_d*k_yy*k_ztheta**2*omega**2 + 
0.382*J_d*k_ztheta**2*omega**4 + J_p**2*Omega**2*k_yy*k_zz*omega**2 - 
0.382*J_p**2*Omega**2*k_yy*omega**4 - 0.382*J_p**2*Omega**2*k_zz*omega**4 + 
0.145924*J_p**2*Omega**2*omega**6 - k_phiphi*k_thetatheta*k_yy*k_zz + 
0.382*k_phiphi*k_thetatheta*k_yy*omega**2 + 
0.382*k_phiphi*k_thetatheta*k_zz*omega**2 - 
0.145924*k_phiphi*k_thetatheta*omega**4 + k_phiphi*k_yy*k_ztheta**2 - 
0.382*k_phiphi*k_ztheta**2*omega**2 + k_thetatheta*k_yphi**2*k_zz - 
0.382*k_thetatheta*k_yphi**2*omega**2 - k_yphi**2*k_ztheta**2)

solution = sym.solve(omega_nf_eq.rhs, omega, dict = True , force=True, 
manual=True, set=True)

Even after half an hour, sympy is unable to give a solution.
I also tried sage math, but I had the same failure.
Suggestions?

-- 
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 post to this group, send email to sympy@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/a4ebc67b-3e40-448b-b6a3-5500f6b9dab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] tensor module

2019-06-06 Thread Rybalka Denys
I am new to the sympy community, but I haven't found a similar topic 
anywhere. I am interested in the tensor module, but so far, unfortunately, 
it does not work. I am thinking about contributing to its development, but 
first wanted to get a wider perspective. I hope someone can help me with 
the following questions.

1) What are (or can be) the general uses of the tensor module? From a 
physicist point of view the main purpose is the ability to expand/simplify 
sums and products of tensors with respect to their symmetries and the 
ability to calculate these expressions given their explicit form. Are there 
any other uses? 

2) What was the reason of deprecating tensor.data for the sake of 
replace_with_arrays()? I just don't understand the benefit of having the 
data separate from the tensor objects, it seems unnatural even from the 
coding point of view.

I will be grateful for any help.

-- 
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 post to this group, send email to sympy@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/23056a16-0109-49a1-a279-35a18d0c2356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.