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.Wed, 17 Oct 2012 02:21:52 +0200roots() returns no real solutions for cubic functionhttps://ask.sagemath.org/question/9437/roots-returns-no-real-solutions-for-cubic-function/Hi there
I have a pretty complicated third-order polynomial which I use Sage to solve. However, somehow roots() only returns imaginary solutions. This should not be possible as a cubic function always has at least one root, so naturally I'm puzzled by this.
I could't seem to include all my code (formatting gets messed up).
First I checked that the equation really is a polynomial in m:
print dldm.degree(m)
Outputs 3, so that's OK. Next, I obtain the roots, which I have printed below:
-0.000119434160296805 + 2.27373675443232e-12*I
-5395.14738658974 - 7.95807864051312e-13*I
2560.33896686341 - 1.36424205265939e-12*I
As you can see, they're all imaginary, which should not be possible. The imaginary part is very small on all the solutions. My guess is that Sage uses some numerical approximations to obtain the solutions which is why it seemingly violates mathematics. But what do you think? Thanks!TheoWed, 17 Oct 2012 02:21:52 +0200https://ask.sagemath.org/question/9437/check if the result is a real numberhttps://ask.sagemath.org/question/8950/check-if-the-result-is-a-real-number/I get several results and want to check, which one is a real number. From trial and error, I can see that maxSol[2][x] is the only plausable solution.
Is there something like isReal()?
my attempt (don't laugh) ;)
for i in maxSol:
print RealField(50)(i)
where I obviously get:
TypeError: Unable to convert x (='.....disiFri, 04 May 2012 12:39:24 +0200https://ask.sagemath.org/question/8950/