Roots of a Polynomial Equation


The solvers module in SymPy implements methods for solving equations.

Let's take an example of solving the equation of order 2.
Equation : (x - 0.4)*(x + 0.65) - 1, Now we try to find positive roots of equation

 from sympy.solvers import solve  
 from sympy import Symbol  
 beta = Symbol('x',positive=True)  
 #https://docs.sympy.org/latest/modules/solvers/solvers.html  
 f =1  
 gammavalues = [0.4, 0.35, 0.3]  
 for i in range(1,-1,-1):  
   f = f*(beta-gammavalues[i])  
   f= f+1  
 f = f-2  
 print(f)  
 beta = solve(f, beta)  
 print(beta)  

output:
 (x - 0.4)*(x + 0.65) - 1  
 [1.00443569980765]  

just go through this link where you can find other important things like solving an algebraic equation, ODEs, PDEs

https://docs.sympy.org/latest/modules/solvers/solvers.html




Comments

Popular posts from this blog

Splitting criteria

How to Handle Noisy Data in preprocessing of data?

Embedding the GitHub Gists codes into blogs