ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 26 Dec 2017 15:05:07 +0100Getting all (complex) solutions of a non polynomial equationhttps://ask.sagemath.org/question/40302/getting-all-complex-solutions-of-a-non-polynomial-equation/Hi !
I was used to solve the following equation with Mathematica.
\begin{equation}
\alpha_1 + \alpha_2x + \alpha_3x^2 + x^4 + \frac{\alpha_4}{x^2-\alpha_0} + \frac{\alpha_5 x^2}{x^2-\alpha_0}=0
\end{equation}
where $\alpha_i$ are constants.
The Mathematica function "Solve" gives me all the numerical roots of this non polynomial equation very easily. These roots can be real or complex.
I'm a very beginner at Sage. I have tried several methods to solve this equation automatically but it seems that all methods I've used work only for polynomial equations. Here they are :
alpha0 = 0.25
alpha1 = -2.5
alpha2 = 6.9282
alpha3 = -5.5
alpha4 = 0.5
alpha5 = -0.5
x = var('x')
eq = alpha1 + alpha2*x + alpha3*x**2 + x**4 + alpha4/(x**2 - alpha0) + alpha5*x**2/(x**2 - alpha0) == 0.
# test 1
# solve(eq, x, ring=CC)
# ==> [0 == 20000*x^6 - 115000*x^4 + 138564*x^3 - 32500*x^2 - 34641*x + 22500]
# test 2
# solve(eq, x, ring=CC, solution_dict=True)
# ==> [{0: 20000*x^6 - 115000*x^4 + 138564*x^3 - 32500*x^2 - 34641*x + 22500}]
# test 3
# eq.roots(x, ring=CC,multiplicities=False)
# ==> TypeError: fraction must have unit denominator
Do you have any idea of a method to get the approximated roots of the equation ?
Thanks in advance
EDIT : correction of an error in the equation ; add few testsyoda789Tue, 26 Dec 2017 15:05:07 +0100https://ask.sagemath.org/question/40302/Ignoring the very small imaginary parthttps://ask.sagemath.org/question/10024/ignoring-the-very-small-imaginary-part/I am generating a matrix that its entries come from roots of a polynomial which are all real. Due to calculation errors sage returns entries such as: `-2.8 + 2.2e-16*I`
How can I ask sage to ignore the small imaginary part and return -2.8?k1Wed, 01 May 2013 16:03:09 +0200https://ask.sagemath.org/question/10024/