ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Feb 2019 00:49:28 -0600Groebner basis computationhttp://ask.sagemath.org/question/45340/groebner-basis-computation/ How we can use SageMath for computing Groebner basis? e.g. we have 35 multivariate polynomial equations, is it possible to compute groebner basis at a time?MMumtazWed, 06 Feb 2019 00:49:28 -0600http://ask.sagemath.org/question/45340/Multiplying Roots of a Polynomialhttp://ask.sagemath.org/question/45077/multiplying-roots-of-a-polynomial/ Hello - I'm new to SAGE, so trying to get to grips with the basics!
I have a polynomial $f = x^{2}((x+\frac{1}{x})^{2} - 1) $. I would like to be able to do to things:
1) See $f$ in the form $\beta(x - \alpha_1)(x-\alpha_2)(x-\alpha_3)(x-\alpha_4)$
2) Know the value of $\beta (\prod_i \alpha_i)$
Using
>f.factor
>f.roots
Does not give me the linear factorisation, nor can I see a simple way of getting the product of the roots.
In the long term I'm hoping to do this for polynomials of larger degree, so any advice would be great!LukeC93Thu, 17 Jan 2019 05:29:29 -0600http://ask.sagemath.org/question/45077/Roots of multivariable polynomials with respect to one variable?http://ask.sagemath.org/question/44686/roots-of-multivariable-polynomials-with-respect-to-one-variable/This question was previously titled "Finding residues of a huge multivariable rational function."
From my understanding, when computing with huge rational functions, we shouldn't use symbolic variables. However, I don't see how to find roots and residues without symbolic variables. Here is a small scale example of the issue. I have a rational function that looks like below:
$f(u_1,x_1,u_2,x_2,u_3,x_3) = \frac{1}{{\left(u_{1} u_{2} u_{3} - x_{1} x_{2} x_{3}\right)} {\left(u_{1} u_{2} u_{3} - 1\right)} {\left(u_{1} u_{2} - x_{1} x_{2}\right)} {\left(u_{1} u_{2} - 1\right)} {\left(u_{1} - x_{1}\right)} {\left(u_{1} - 1\right)}}$
First I want to solve for $u_1$ in the denominator and find those roots (poles) that have $x_1$ as below.
Then I will loop through the roots and compute the residue of $f$ w.r.t. $u_1$ at those poles.
u1,u2,u3,x1,x2,x3 = var('u1,u2,u3,x1,x2,x3') #symbolic variables
f=1/((u1*u2*u3 - x1*x2*x3)*(u1*u2*u3 - 1)*(u1*u2 - x1*x2)*(u1*u2 - 1)*(u1 - x1)*(u1 - 1))
fden=f.denominator() #denominator of f
list1=fden.roots(u1) #poles of u1
[root for (root, multiplicity) in list1] #list of roots
The output is
[x1*x2*x3/(u2*u3), x1*x2/u2, x1, 1/(u2*u3), 1/u2, 1]
Then we choose those roots that have $x1$
poles1 = [x1*x2*x3/(u2*u3), x1*x2/u2, x1] #choose those that have x1
Finally, we find the residue of $f$ w.r.t $u1$ of the rational function at the poles containing $x1.$
ans1=0
for ff in poles1:
tmp=f.residue(u1==ff)
ans1+=tmp #ans1 is the residue of f w.r.t u1 at all the poles containing x1
ans1
The output is then
1/((u2*u3*x1 - x1*x2*x3)*(u2*u3*x1 - 1)*(u2*x1 - x1*x2)*(u2*x1 - 1)*(x1 - 1)) - 1/((u3*x1*x2 - x1*x2*x3)*(u3*x1*x2 - 1)* (x1*x2 - 1)*u2*(x1 - x1*x2/u2)*(x1*x2/u2 - 1)) + 1/((x1*x2*x3 - 1)*(x1*x2 - x1*x2*x3/u3)*(x1*x2*x3/u3 - 1)*u2*u3*(x1 x1*x2*x3/(u2*u3))*(x1*x2*x3/(u2*u3) - 1))
Then I replace $f$ with $ans1$ to continue to do the same process w.r.t $u2$ and poles containing $x2$ and finally w.r.t $u3$ and poles containing $x3.$ However, this consumes about 800GB of memory on an HPC when I feed it a larger rational function.
Is there a way to find
1. roots of multivariable polynomials with respect to one variable?
2. residue of a rational function avoiding symbolic variables?
Both .roots() and .residue() are not defined for rational functions that are not defined in terms of symbolic variables.HoldenSun, 16 Dec 2018 16:32:23 -0600http://ask.sagemath.org/question/44686/Roots of Polynomials over finite Fieldshttp://ask.sagemath.org/question/43734/roots-of-polynomials-over-finite-fields/Hi guys,
How can I define all polynomial as this form -> `a*x^2+b*y-1` over QQ where `a` and `b` are constants.
for examples polynomials as : `2*x^2+3*y-1` or `5*x^2+y-1` , ...
I know that I have to create a PolynomialRing, but I don't understand how exactly.
Thank you so much.ZacariasSatrusteguiSun, 23 Sep 2018 13:17:59 -0500http://ask.sagemath.org/question/43734/Roots of a Polynomial in a PolynomialRinghttp://ask.sagemath.org/question/43733/roots-of-a-polynomial-in-a-polynomialring/ If I do:
`R.<x,y>= PolynomialRing(QQ,2)`
`f=x^2-y^2`
`f.roots()`
Why it doesn't work?
And next code work:
`R.<x>= PolynomialRing(QQ)`
`f=x^2-1`
`f.roots()`
I don't understand why.
And one more things,
If I want to define all polinomials as this form -> a*x^2 - b*y^2 where $a$ and $b$ are constants.
Have I do this?
`R.<a,b,x,y>=PolynomialRing(QQ,4)`
`I=R.Ideal([a*x^2 - b*y^2])`
`f= 2*x^2 - 3*y^2`
How can I do that?
Thank you so much.ZacariasSatrusteguiSun, 23 Sep 2018 13:01:56 -0500http://ask.sagemath.org/question/43733/inverse_laplace of a fraction whose denominator has real roots (or complex)http://ask.sagemath.org/question/42331/inverse_laplace-of-a-fraction-whose-denominator-has-real-roots-or-complex/ Hi, this is the simplest and very important method of Laplace inversion . It can be applied to any Laplace transform
(LT), by starting with a Pade approximation of the LT, then partial fractions and inversion. For some reason, a program I had written last year stopped working
def Ruin(Fx, rho, x, u):#assumes rational survival function Fx, i.e. a hyperexponential density
var('s')
L_F=laplace(Fx,x,s)
m1=L_F(s=0) #some algebraic manipulations known as Pollaczek-Khinchine formula
fe=L_F/m1
Fe=factor((1-fe)/s)
L_rui=rho*Fe/(1-rho*fe)
C=ComplexField(53);
dec=Frac(C['s'])(L_rui).partial_fraction_decomposition();
n=len(dec)
par=[inverse_laplace(dec[1][i],s,u) for i in [0..n]];
rui=sum(par)
return rui, L_rui, fe
It's pretty easy to repair the program when roots are rational -- see question "partial_fraction_decomposition" with possibly "complex roots", again. For nonrational roots, I proposed there the following test case
var('s,u')
R.<s> = PolynomialRing(QQbar)
F = R.fraction_field()
L=3/4*(19*s^2 + 156*s + 284)/(19*s^3 + 174*s^2 + 422*s + 228)
whole,LL=L.partial_fraction_decomposition()
show(LL[0])
inverse_laplace(LL[0],s,u)
Thanks in advance :)florinMon, 14 May 2018 04:04:41 -0500http://ask.sagemath.org/question/42331/"partial_fraction_decomposition" with possibly "complex roots", againhttp://ask.sagemath.org/question/42220/partial_fraction_decomposition-with-possibly-complex-roots-again/ Hi I come back to this question, even though it's been answered before, since I am still not able to make it work. I should mention maybe that I am just trying to teach undergraduate students to invert
rational Laplace transforms (for myself I am able to afford a Mathematica licence, but it would be nice to be able to show students that such simple things may be done nowadays for free). Following a previous answer, I tried
L = 2*(s + 3)/(3*s^2 + 13*s + 10)
Ks=FractionField(PolynomialRing(CC,names='s'))
Lr=Ks(L)
Of course, with quadratic rational roots, I could do this by hand, but the purpose here is to do it when you do not know the roots. The first two commands work, but the third has error message
TypeError: ('cannot convert {!r}/{!r} to an element of {}', 2*(s + 3)/(3*s^2 + 13*s + 10), 1.00000000000000, Fraction Field of Univariate Polynomial Ring in s over Complex Field with 53 bits of precision)
I should add that a different attempt which used to work last year
C=ComplexField(53);
dec=Frac(C['s'])(Lrs).partial_fraction_decomposition();
gets now same error message. So, this is probably due to an "improvement" of sageflorinMon, 30 Apr 2018 03:58:31 -0500http://ask.sagemath.org/question/42220/Laurent Expansion at Infinity / Root findinghttp://ask.sagemath.org/question/42317/laurent-expansion-at-infinity-root-finding/I'm new to sage, and I was trying to implement the following, to partial success:
I want to take the $p^{th}$ root of a polynomial (for a specified $p$), expand it as a Laurent series at infinity, and take the polynomial part of the expansion. I've written some code which seems to work with partial success, but it also fails in some very straightforward cases.
def poly_truncate(f):
g=f(1/x)
h = g.series(x==0,1).truncate()
return h(1/x)
It works, for instance, with $(x^2-3x+5)^{1/2}$ and $(x^3-5x^2+45x-713)^{1/3}$, but not (for example) with $(x^8-x^7+9x^6-7x^5+4x^4-x^3)^{1/2}$. I feel as though my method is kind of ad-hoc, and was hoping somebody could point me to a better way to do this. This is the error message it throws, for what it's worth:
poly_truncate((x^8-x^7+9*x^6-7*x^5+4*x^4-x^3)^(1/2))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-d95c1391d7b5> in <module>()
----> 1 poly_truncate((x**Integer(8)-x**Integer(7)+Integer(9)*x**Integer(6)-Integer(7)*x**Integer(5)+Integer(4)*x**Integer(4)-x**Integer(3))**(Integer(1)/Integer(2)))
<string> in poly_truncate(f)
/Applications/SageMath-8.1.app/Contents/Resources/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:32775)()
5273 z^2 + x^y
5274 """
-> 5275 return self._parent._call_element_(self, *args, **kwds)
5276
5277 def variables(self):
/Applications/SageMath-8.1.app/Contents/Resources/sage/src/sage/symbolic/ring.pyx in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:11496)()
973 d[ vars[i] ] = arg
974 except IndexError:
--> 975 raise ValueError("the number of arguments must be less than or equal to %s"%len(vars))
976
977 return _the_element.subs(d, **kwds)
ValueError: the number of arguments must be less than or equal to 0
Additionally, is there a faster/more trustworthy built-in function or package which computes the rational/integer roots of polynomials in $\mathbb{Q}[x]$ (i.e. better than just f.roots())?canuckleheadFri, 11 May 2018 23:00:02 -0500http://ask.sagemath.org/question/42317/"partial_fraction_decomposition" with "complex roots"http://ask.sagemath.org/question/41893/partial_fraction_decomposition-with-complex-roots/ Hi six months ago I used a hint from Zimmerman's book
var('s')
L=2*(s + 3)/(3*s^2 + 13*s + 10)
C=ComplexField(53)
dec=Frac(C['s'])(L).partial_fraction_decomposition()
but this does not work anymore (see below). How to do this? Thanks
----> 2 dec=Frac(C['s'])(Lrs).partial_fraction_decomposition();
TypeError: ('cannot convert {!r}/{!r} to an element of {}', 2*(s + 3)/(3*s^2 + 13*s + 10), 1.00000000000000, Fraction Field of Univariate Polynomial Ring in s over Complex Field with 53 bits of precision)
/opt/sagemath-8.1/src/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9641)()
937 if mor is not None:
938 if no_extra_args:
--> 939 return mor._call_(x)
940 else:
941 return mor._call_with_args(x, args, kwds)
/opt/sagemath-8.1/src/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4928)()
152 print(type(C), C)
153 print(type(C._element_constructor), C._element_constructor)
--> 154 raise
155
156 cpdef Element _call_with_args(self, x, args=(), kwds={}):
/opt/sagemath-8.1/src/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4796)()
147 cdef Parent C = self._codomain
148 try:
--> 149 return C._element_constructor(x)
150 except Exception:
151 if print_warnings:
/opt/sagemath-8.1/local/lib/python2.7/site-packages/sage/rings/fraction_field.py in _element_constructor_(self, x, y, coerce)
616 except AttributeError:
617 raise TypeError("cannot convert {!r}/{!r} to an element of {}",
--> 618 x0, y0, self)
619 try:
620 return self._element_class(self, x, y, coerce=coerce)
florinFri, 06 Apr 2018 14:42:27 -0500http://ask.sagemath.org/question/41893/Change Precision of complex_roots()http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/I am trying to find the complex roots of the polynomial
poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
But when I do poly.complex_roots(), the system gives:
PariError: overflow in expo()
Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example).
How do I change the complex_roots() function to get lower-precision roots?cshiringWed, 06 Dec 2017 23:10:52 -0600http://ask.sagemath.org/question/39987/Change Precision on complex_roots()http://ask.sagemath.org/question/39988/change-precision-on-complex_roots/ I am trying to find the complex roots of the polynomial
poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
But when I do poly.complex_roots(), the system gives:
PariError: overflow in expo()
Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example).
How do I change the complex_roots() function to get lower-precision roots?
Alternatively, how do I deal with the PariError?
cshiringWed, 06 Dec 2017 23:13:28 -0600http://ask.sagemath.org/question/39988/Finding roots of equation made of Bessel functions, some of which have complex argumentshttp://ask.sagemath.org/question/39863/finding-roots-of-equation-made-of-bessel-functions-some-of-which-have-complex-arguments/I want to find the roots (values or w) for an equation of spherical Bessel functions for L = 1 and \Omega^2 = 14.28 (capital Omega, not w):
My code is:
L = 1
ome = 14.28 #MeV
w = var('w')
Arg1 = sqrt(ome*(1-w^2))
Arg2 = I*sqrt(ome)*w
a = -I*sqrt(1-w^2)
b = spherical_bessel_J(L-1, Arg1)
c = spherical_bessel_J(L, Arg1)
d = spherical_bessel_J(L, Arg2)+I*spherical_bessel_Y(L, Arg2)
e = spherical_bessel_J(L-1, Arg2)+I*spherical_bessel_Y(L-1, Arg2)
eq = a*(b/c)*(d/e)-w == 0
eq.find_root(0, 1)
But I get an error on line 12, which specifies:
"TypeError: unable to convert 3.77888872553824*I to float; use abs() or real_part() as desired"3ndingThu, 30 Nov 2017 22:55:27 -0600http://ask.sagemath.org/question/39863/Bug in roots()?http://ask.sagemath.org/question/25083/bug-in-roots/Hi guys,
I might have found a bug in the roots method.
Below is some (ugly) polynomial of degree 4 over a fraction field of a polynomial ring over a finite extension of GF(11).
The roots() method returns 0 as a root which it is not.
If i do the same thing over QQ instead of GF(11) "Not implemented" is returned.
Sry i couldn't come up with a shorter example.
sage: K0=GF(11)
sage: #K0=QQ
sage: R0.<b>=K0[]
sage: K.<b>=K0.extension(b^5+4)
sage: R1.<z3>=K[]
sage: L=FractionField(R1)
sage: R.<x>=L[]
sage: f=(x^4 + ((3*b^3*z3^24 + 9*b^4*z3^23 + 8*z3^22 + 7*b*z3^21 + 9*b^2*z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*z3^18 + 5*b^2*z3^17 + z3^14 + 2*b*z3^13 + 7*b^2*z3^12 + b^3*z3^11 + 4*b^4*z3^10 + 3*z3^9 + 3*b^3*z3^6 + 5*b^4*z3^5 + 3*z3^4 + 2*b*z3^3 + 6*b^2*z3^2 + 8*b^3*z3 + 5*b^4)/(b^4*z3^34 + 7*z3^33 + 7*b*z3^32 + 2*b^2*z3^31 + b^3*z3^30 + 5*b^4*z3^29 + 9*z3^28 + 7*b*z3^27 + 2*b^3*z3^25 + 8*b^4*z3^24 + 2*z3^23 + 7*b*z3^22 + 6*b^3*z3^20 + 6*b^4*z3^19 + 4*z3^18 + b*z3^17 + 8*b^3*z3^15 + 5*b^4*z3^14)simon89Tue, 02 Dec 2014 09:42:34 -0600http://ask.sagemath.org/question/25083/Roots in a polynomial over $GF(2^8)$?http://ask.sagemath.org/question/10355/roots-in-a-polynomial-over-gf28/Hi,
I have a polynomial $x^8+x^7+x^5+x^3+1$ and I want to find the roots of this polynomial over $GF(2^8)$?
In the paper of Patrick Ekdahl and Thomas Johansson about a new version of SNOW they used this roots ($\beta^{23}, \beta^{48}, \beta^{239}$ and $\beta^{245}$, but I want all roots for this polynomial.
Thanks Gustavo BanegasTue, 16 Jul 2013 05:50:49 -0500http://ask.sagemath.org/question/10355/Finding roots of a polynomial over an extension fieldhttp://ask.sagemath.org/question/34042/finding-roots-of-a-polynomial-over-an-extension-field/ Apologies if I am not articulating this very well. I am still in an early learning phase.
I am trying to find the roots of a polynomial s^37 + 7 over a finite field of size 241 and modulus x^32 + 44.
My code is as follows:
`K.<x> = GF(241)[]`
`T.<a> = K.quotient(x^32 + 44)`
`J.<s> = T[]`
`G = s^32 + 7`
`G.roots()`
and here I get : 'root finding with multiplicities for this polynomial not implemented (try the multiplicities=False option)'
I think I expressed this correctly as some sanity-checking with known roots is correctly evaluated as follows:
rootList = [20*a^29, 51*a^13, 221*a^13]
for r in rootList:
assert(G(r) == 0)
It does not appear root finding is implemented for G.
Is there some alternative way to find the roots of G?
Thank you.
jimboThu, 07 Jul 2016 00:22:22 -0500http://ask.sagemath.org/question/34042/Decomposing a Root vector into simple rootshttp://ask.sagemath.org/question/32630/decomposing-a-root-vector-into-simple-roots/
Is there a sage functions which does the following:
Input = Root System / Ambient Lattice or Ambient space of irreducible (or even classical) Root System and a Root vector $v$
Output = a list containing the integers which expresses $v$ as a linear combination of simple roots.
Thank you for your help.
DBSMon, 22 Feb 2016 11:22:02 -0600http://ask.sagemath.org/question/32630/Computations with complex algebraic numbers?http://ask.sagemath.org/question/31857/computations-with-complex-algebraic-numbers/I am trying to perform some Newton-type computations: `z-p(z)/p'(z)` where `p(z)` is a polynomial over the field of algebraic numbers.
For example, this shows the sort of thing I'm trying to do:
p = (z^2+1)*(z^2+4)
q = p/(z-I)
pd = diff(p,z)
qd = diff(q,z)
sol = solve(qd=0,solution_dict='true')
a0 = sol[0][z]
b0 = a0-p.subs(z=a0)/pd.subs(z=a0)
However, this doesn't work because the expression `z-I` is not recognized as a factor of `p`. So I might try defining
`p` as a polynomial over the field `QQbar`:
R.<z> = PolynomialRing(QQbar)
p = (z^2+1)*(z^2+4)
q = p.quo_rem(z-I)[0]
pd = p.differentiate(z)
qd = q.differentiate(z)
The trouble now is that I can only seem to solve `qd` over `CC`: that is, in numerical form. Both the commands
qd.roots()
qd.factor()
produce numerical roots; I can't use `solve` on `qd` to obtain closed-form expressions for the roots. I've also tried the first method above prefaced with `z=QQbar['z'].0` but to no avail.
Is there some way of doing this entire computation over `QQbar`, that is, with exact complex numbers instead of numerical approximations?AlasdairSun, 27 Dec 2015 02:33:06 -0600http://ask.sagemath.org/question/31857/eigenvalues vs roots of characteristic polynomialhttp://ask.sagemath.org/question/31656/eigenvalues-vs-roots-of-characteristic-polynomial/Hi,
Sorry if this is a stupid question but I am struggling to make Sage compute the exact eigenvalues of a matrix.
I am also confused that when I ask for the roots of the characteristic polynomial Sage answers with complex roots...
I am new to Sage so please forgive me :)
Here is my worksheet:
sage: A = matrix([[1, 1, 2], [1, -2, 0], [2, 0, 1]])
sage: A
[ 1 1 2]
[ 1 -2 0]
[ 2 0 1]
sage: A.eigenvalues()
[-2.439311671683875?, -0.6611203141265045?, 3.100431985810380?]
sage: x = var('x')
sage: H = A.charpoly()
sage: H
x^3 - 8*x - 5
sage: H.roots()
[]
sage: (x^3-8*x-5).roots()
[(-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(I*sqrt(3) + 1) + 1/3*(4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
1),
(-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(-I*sqrt(3) + 1) + 1/3*(-4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
1),
((1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3) + 8/3/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
1)]
Laurent BThu, 17 Dec 2015 07:58:59 -0600http://ask.sagemath.org/question/31656/`roots` doesn't find all roots of a polynomialhttp://ask.sagemath.org/question/31385/roots-doesnt-find-all-roots-of-a-polynomial/ Let's consider the following example:
w = x^4 - (1+3*i)*x^3 - (2-4*i)*x^2 + (6-2*i)*x - 4 - 4*i
p = x^4 + (1-3*i)*x^3 - (4-3*i)*x^2 - (4-2*i)*x + 2*i
solve(w, x)
w.roots()
When using `solve`, all complex roots are found. When using `roots`, only two of them. Why?marmistrzMon, 07 Dec 2015 12:44:44 -0600http://ask.sagemath.org/question/31385/Finding complex rootshttp://ask.sagemath.org/question/26702/finding-complex-roots/ So, what is the best way to find complex roots of polynomials?
I only found that [one](http://www.sagemath.org/doc/reference/polynomial_rings/sage/rings/polynomial/complex_roots.html):
sage: from sage.rings.polynomial.complex_roots import complex_roots
sage: x=polygen(ZZ)
sage: complex_roots(1.3*x^3-x^2-5*x-1)
[(-1.479272103982880?, 1), (-0.2113935621844148?, 1),
(2.459896435398064?, 1)]
Should I use that? Isn't there an inbuilt function? Even PARI/GP has one, namely `polroots`...
And why is the `x` casted as an element of $\mathbb{Z}[X]$, why not $\mathbb{C}[X]$? Can somebody explain that to me?
Thank you!OderynSat, 02 May 2015 09:05:56 -0500http://ask.sagemath.org/question/26702/simplify roots with mulitple inbedded rootshttp://ask.sagemath.org/question/10840/simplify-roots-with-mulitple-inbedded-roots/Hi everyone,
I know this questions has been asked quite some times before and I've browsed a couple of hours searching for the answer but I haven't found anything that worked yet. So here it is:
![](http://i40.tinypic.com/33awkzm.png)
So I have these two functions and I need to calculate k. I've found you can use the maxima_methods, but as you can see, it doesn't work here either. (I tested the example question and I could simplify that one with these commands, so it's not the virtual machine)
I know you can calculate it by using the maxima engine itself on the virtual machine en then you should find 37/4+3*sqrt(7). But isn't there any method a bit less far-fetched, and I also still need to find a way to switch to maxima on the cloud, so this solution is for the virtual machine only...
I'm working on a project for school concerning Sage and so far this is the only problem I've encountered.
Thanks in advance!KurothSun, 22 Dec 2013 23:45:40 -0600http://ask.sagemath.org/question/10840/Roots of polynomials over a non-prime finite field in a given extensionhttp://ask.sagemath.org/question/10711/roots-of-polynomials-over-a-non-prime-finite-field-in-a-given-extension/I am trying to find the roots of a primitive polynomial
over a non-prime finite field, in a desired extension.
Here is an example of what I'm trying to do:
First, I define my non-prime finite field (GF(4)), and
a primitive polynomial f.
sage: F.<a>=GF(4)
sage: K.<x>=F[]
sage: F
Finite Field in a of size 2^2
sage: K
Univariate Polynomial Ring in x over Finite Field in a of size 2^2
sage: f=x^4 + (a + 1)*x^3 + a*x^2 + a
sage: f.is_primitive()
True
Now, I define an extension field G where f has its roots
sage: G=f.root_field('b')
sage: G
Univariate Quotient Polynomial Ring in b over Finite Field in a of size 2^2 with modulus x^4 + (a + 1)*x^3 + a*x^2 + a
I assume that b is a root of f, by definition (correct me if I'm wrong).
Now, I take a new primitive polynomial h.
sage: h=x^4 + x^3 + (a + 1)*x^2 + a
sage: h.is_primitive()
True
But when I try to find the roots of h in G, I get nothing.
sage: h.roots(ring=G)
[]
Could somebody tell me how I could get the roots of h in G
with respect to b?geo909Wed, 06 Nov 2013 11:48:49 -0600http://ask.sagemath.org/question/10711/Roots of p-adic polynomialshttp://ask.sagemath.org/question/10695/roots-of-p-adic-polynomials/Hello again,
I want to get the roots of a p-adic polynomial. I wrote the following code:
p = 2
q = 4
K = Qp(p)
L.<omega> = Qq(q)
O_L = L. integer_ring()
pi = L.uniformizer()
q = L.residue_class_degree()
f = X^q + pi*X
f.roots()
This rises following error:
NotImplementedError: root finding for this polynomial not implemented
I still use version 5.10 of Sage. The compile of the latest version 5.12 is ongoing. Do I miss something or is there no way to get the roots in this case?
Will this be implemented in the future or does someone know a workaround?
Thanks for your time again!
Bye
Lars
lars.tennstedtMon, 04 Nov 2013 07:54:57 -0600http://ask.sagemath.org/question/10695/roots() returns no real solutions for cubic functionhttp://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!TheoTue, 16 Oct 2012 19:21:52 -0500http://ask.sagemath.org/question/9437/obtaining all numerical roots of a function in an intervalhttp://ask.sagemath.org/question/8886/obtaining-all-numerical-roots-of-a-function-in-an-interval/Hello, thanks for reading.
I'm working on single variable calculus here:
Basically what I need is what "find_root" does, but I need a list of ALL roots in a given interval, not just one.
So I've been playing with "solve". I found this piece of code which works in most cases:
sage: roots = solve(f(x),x,solution_dict=True)
sage: roots = [s[x] for s in roots]
sage: num_roots = map(n, roots)
but it gives an error if the function is periodic and has inifinite roots, becuase the symbolic expression that "solve" gets has infinite solutions too.
Defining a desired interval should solve this issue, but I have no idea how to implement such thing!
Thanks you and have a good day.NilSat, 14 Apr 2012 18:17:01 -0500http://ask.sagemath.org/question/8886/Finding complex roots numerically using sagehttp://ask.sagemath.org/question/8205/finding-complex-roots-numerically-using-sage/Can sage find complex roots numerically for equations like
cos(cos(cos(cos(x)))) == sin(sin(sin(sin(x))))
if so, how?ebsSat, 02 Jul 2011 14:04:50 -0500http://ask.sagemath.org/question/8205/