Hi,

I need to solve univariate polynomial equation in my project using sympy. 
For example if "n = 8" my equation is 

(1.61587088302977e-46*a**16 + 3.11063525654906e-41*a**15 + 
1.33738676638385e-36*a**14 + 2.36049383729794e-32*a**13 + 
2.19291207543437e-28*a**12 + 1.17057706002292e-24*a**11 + 
3.04669883570163e-21*a**10 + 3.13042181519432e-18*a**9 - 
4.9127494077918e-16*a**8 - 2.35193838773191e-12*a**7 + 
6.33603683578917e-11*a**6 + 7.08281587983605e-7*a**5 - 
0.000231970250549824*a**4 + 0.0257440586719532*a**3 - 1.59324649322617*a**2 
+ 47.5727869457329*a - 443.798489454948)/((-0.193492645584951*a + 
72)*(4.86248832786888e-11*a**2 + 1.52976656088174e-7*a + 
0.000120318321248167)*(1.7504957980328e-9*a**2 + 5.50715961917428e-6*a + 
0.00433145956493402)*(1.0940598737705e-8*a**2 + 3.44197476198393e-5*a + 
0.0270716222808376)*(3.8121908490492e-8*a**2 + 0.000119933698373129*a + 
0.094329563858563)*(0.000259995860385164*a**2 - 0.193492645584951*a + 
36)*(0.00288884289316849*a**2 - 2.14991828427724*a + 
400)*(0.012739797158873*a**2 - 9.48113963366262*a + 1764))

I solved equation by using  1) solve()   2) polyroots() . These two 
functions could give roots. According to my equation real roots should 
converge if I increase "n" value. But roots are not converging properly.

I tried using "mpmath" findroot() function. It could not give roots. I 
could not select proper algorithm to solve this kind of equation.

I am adding my code for reference. I am new to sympy. Is there any better 
way to solve polynomial equation ? 

Thanks in advance for your support.
Rekha.


a,C,D = symbols( 'a C D')
Y = [0,C]
VPHI = [D,0]
Ev = 5500000000000
nuv = 0.19
K = 0.563
G = Ev/(2*(1+nuv))                                            
#initialization
d = 0.000000000678
t = 0.000000000066 
R = d/2
L = 10*d
Iv = (pi/4)*((R+t)**4 - (R-t)**4)

A = pi*((R+t)**2 - (R-t)**2)
ssq = (Ev*Iv)/(K*G*A*(L**2))
rsq = (Iv/(A*(L**2)))
mu = 0.7


# n = 8

for i in range(0,8):
   Y.append(expand(((-ssq*a*Y[i])+((i+1)*VPHI[i+1]))/((1-((mu**2)*ssq*a))*(i
+1)*(i+2))))                       # Differential transformation 
   VPHI.append(expand((VPHI[i]-((i+1)*Y[i+1])+(rsq*ssq*a*VPHI[i]))/((ssq+((
mu**2)*ssq*rsq*a))*(i+1)*(i+2))))


s1 = sum(Y)
e1 = expand(s1) 



z = []

for j in range(0,8):
   z.append(expand((-(j+1)*VPHI[j+1])-(a*(mu**2)*Y[j])-(a*(mu**2)*rsq*(j+1)*
VPHI[j+1])))                 #Boundary conditions


s2 = sum(z)

e2 = expand(s2)



a11 = together(expand(e1.coeff(C)))
a12 = together(expand(e1.coeff(D)))

a21 = together(expand(e2.coeff(C)))

a22 = together(expand(e2.coeff(D)))



M = Matrix([[a11,a12],[a21,a22]])
d = together(expand(M.det()))                   # univariate polynomial in 
"a" , which need to be solved.           







l = Poly(numer(d),a).all_coeffs()               # solving with polyroots() 
function
nprint(polyroots(l))





#R = solve(d,a)


#R = roots(d,a)                                                # solved 
with different type of functions to find roots


#R = findroot(lambda a:d,(1,100),solver='bisect', tol=None, verbose=False, 
verify=True)




-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to