1 | initial version |
Thank you very much ! The numerical resolution works perfectly ! But notice that you have forgotten "t^4" term in F definition. Then, the solving of the equation give 6 roots identical to the one given by Mathematica. This suits me.
However, I've checked the following code on https://sagecell.sagemath.org/ :
P.<t>=PolynomialRing(CDF);
FF=FractionField(P);
alpha=[CDF(complex(2*(random()-0.5),2*(random()-0.5))) for p in range(6)];
F=alpha[1]+alpha[2]*t+alpha[3]*t^2+t^4+(alpha[4]+alpha[5]*t^2)/(t^2-alpha[0]);
foo=SR(repr(F).replace("t","x")).solve(x)
[q.rhs().n() for q in foo]
and got the following errors :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-a2132da36519> in <module>()
19
20 foo=SR(repr(F).replace("t","x")).solve(x)
---> 21 [q.rhs().n() for q in foo]
22
/home/sc_serv/sage/src/sage/structure/element.pyx in sage.structure.element.Element.n (build/cythonized/sage/structure/element.c:8063)()
861 0.666666666666667
862 """
--> 863 return self.numerical_approx(prec, digits, algorithm)
864
865 N = deprecated_function_alias(13055, n)
/home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:36129)()
5782 res = x.pyobject()
5783 else:
-> 5784 raise TypeError("cannot evaluate symbolic expression numerically")
5785
5786 # Important -- the we get might not be a valid output for numerical_approx in
TypeError: cannot evaluate symbolic expression numerically
2 | No.2 Revision |
Thank you very much ! The numerical resolution works perfectly ! But notice that you have forgotten "t^4" term in F definition. Then, the solving of the equation give 6 roots
{-2.8752155238395045 - 1.6035277768266649e-16*I,
-0.5433030528116871 + 2.5081428804803407e-17*I,
0.5277361688701939 - 0.5071712949223567*I,
0.5277361688701941 + 0.5071712949223569*I,
0.9541487172225926 + 1.4813528249977233e-16*I,
1.408897521688212 + 3.3107296343907337e-16*I}
which are identical to the one ones given by Mathematica.
{{x -> -2.87522},{x -> -0.543303},{x -> 0.527736-0.507171i},{x -> 0.527736+0.507171i},{x -> 0.95415},{x -> 1.4089}}
This suits me.
However, for information, I would to mention that I've checked the following code on https://sagecell.sagemath.org/ :
P.<t>=PolynomialRing(CDF);
FF=FractionField(P);
alpha=[CDF(complex(2*(random()-0.5),2*(random()-0.5))) for p in range(6)];
F=alpha[1]+alpha[2]*t+alpha[3]*t^2+t^4+(alpha[4]+alpha[5]*t^2)/(t^2-alpha[0]);
foo=SR(repr(F).replace("t","x")).solve(x)
[q.rhs().n() for q in foo]
and I've got the following errors :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-a2132da36519> in <module>()
19
20 foo=SR(repr(F).replace("t","x")).solve(x)
---> 21 [q.rhs().n() for q in foo]
22
/home/sc_serv/sage/src/sage/structure/element.pyx in sage.structure.element.Element.n (build/cythonized/sage/structure/element.c:8063)()
861 0.666666666666667
862 """
--> 863 return self.numerical_approx(prec, digits, algorithm)
864
865 N = deprecated_function_alias(13055, n)
/home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:36129)()
5782 res = x.pyobject()
5783 else:
-> 5784 raise TypeError("cannot evaluate symbolic expression numerically")
5785
5786 # Important -- the we get might not be a valid output for numerical_approx in
TypeError: cannot evaluate symbolic expression numerically