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.Thu, 23 Nov 2017 11:18:11 -0600Characteristic polynomial wont be used in solvehttp://ask.sagemath.org/question/39746/characteristic-polynomial-wont-be-used-in-solve/ When I try to find roots in a characteristic polynomial it gives me errors:
sage: #Diagonalmatrix
....:
....:
....: A=matrix([[1,-1,2],
....: [-1,1,2],
....: [2,2,-2]])
....: var('x')
....: poly=A.characteristic_polynomial()
....: eq1=solve(poly==0,x)
....:
x
--------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-86-fee7a7de2ea1> in <module>()
7 var('x')
8 poly=A.characteristic_polynomial()
----> 9 eq1=solve(poly==Integer(0),x)
/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
sage:
What can I do in order to use the polynomial in an equation I wish to solve?PoetastropheThu, 23 Nov 2017 11:18:11 -0600http://ask.sagemath.org/question/39746/Not understandable error when solving polynomial equationhttp://ask.sagemath.org/question/33050/not-understandable-error-when-solving-polynomial-equation/Hi all,
when I enter command
solve(symbolic_expression(x^12 - x^11 - 12*x^10 + 11*x^9 + 54*x^8 - 43*x^7 - 113*x^6 + 71*x^5 + 110*x^4 - 46*x^3 - 40*x^2 + 8*x + 1)==0, var(x), to_poly_solve=True)
I get the expected result, but when I enter command
solve(symbolic_expression(x^10 - 10*x^8 + 35*x^6 + x^5 - 50*x^4 - 5*x^3 + 25*x^2 + 5*x - 1), var(x), to_poly_solve=True)
I get the error message
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-203-6108bea90b72> in <module>()
----> 1 solve(symbolic_expression(x**Integer(10) - Integer(10)*x**Integer(8) + Integer(35)*x**Integer(6) + x**Integer(5) - Integer(50)*x**Integer(4) - Integer(5)*x**Integer(3) + Integer(25)*x**Integer(2) + Integer(5)*x - Integer(1)),var(x),to_poly_solve=True)
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/relation.py in solve(f, *args, **kwds)
732 from sage.symbolic.expression import is_Expression
733 if is_Expression(f): # f is a single expression
--> 734 ans = f.solve(*args,**kwds)
735 return ans
736
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:47061)()
/usr/local/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:46887)()
TypeError: 'sage.symbolic.expression.Expression' object does not support indexing
What happened here? The error message is totally misleading (no index in the command!) and it is not to understand why the second command fails while the first works fine.
By the way, the polynomial in question has ten simple real roots, so there should be no problem to compute the roots if symbolic evaluation is not possible.
Thanks in advance
Wolfgang
wjansenSun, 10 Apr 2016 11:29:46 -0500http://ask.sagemath.org/question/33050/Extended Euclid with polynomialshttp://ask.sagemath.org/question/10884/extended-euclid-with-polynomials/Suppose given polynomials $e,q,h,r$ in $R[x]$, $p \in R$ (R a ring), how can I use Sage to find $f$ in $R[x]$ so $f e = q h + r (\text{mod } p)$?
Similarly, given $f,g$ in $R[x]$ with $\text{gcd}(f,g)=1$, what function can I use to compute $s,t$ in $R[x]$ so $s f + g h = 1 (\text{mod } p)$ ?
erinbFri, 03 Jan 2014 12:31:55 -0600http://ask.sagemath.org/question/10884/Real Solution of x^3+8 == 0?http://ask.sagemath.org/question/8393/real-solution-of-x38-0/I do not understand the following:
sage: assume(x,'real')
sage: solve(x^3+8==0,x)
[]
Why does this equation have no solution?
But -2 is a solution!
Thanks for help!
amaleaTue, 18 Oct 2011 08:07:48 -0500http://ask.sagemath.org/question/8393/Solve a "big" polynomial system numericallyhttp://ask.sagemath.org/question/10605/solve-a-big-polynomial-system-numerically/I would like to solve numerically a polynomial system with around 10^5 variables and 10^7 equations. Each equation is of degree 4 with integer coefficients and contains around 10 variables, so that the **jacobian** of the system is a very "**hollow**" matrix with **integer entries**.
Let X=[x_0,x_1, x_2,...] and E=[eq_0,eq_1, eq_2...] the list of variables and equations :
> Is there a SAGE function f(E,X) which
> find numerically solutions for such a system?
> Is SAGE relevant for such intensive
> computation ?
I think the code needs to be **100% cython**, for not losing time.
My computer has a hard disk of 980 Go, 4Go of RAM and its processor "Intel Core i5 CPU 760 @ 2.80GHz × 4" is around 10^9 FLOPS.
I guess my computer is not enough powerful for doing such computation in a reasonable time :
The jacobian J is a (10^5)x(10^7) matrix, so for example, the [Gauss-Newton algorithm](http://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm) would require around 1000 Go of RAM and 10^16 operations.
> I know very few things in numerical
> analysis, so some advices would be
> welcome.
Sébastien PalcouxWed, 16 Oct 2013 00:25:28 -0500http://ask.sagemath.org/question/10605/multivariate polynomial root-findinghttp://ask.sagemath.org/question/10331/multivariate-polynomial-root-finding/I have a series of large, high-degree, bivariate polynomials in two variables, p and q. For example, one of these polynomials is:
$p^7 (25/4 q^6 - 75 q^5 + 525/2 q^4 - 400 q^3 + 300 q^2 - 120 q + 20) + p^6 (-175/8 q^6 + 525/2 q^5 - 3675/4 q^4 + 1400 q^3 - 1050 q^2 + 420 q - 70) + p^5 (255/8 q^6 - 765/2 q^5 + 2655/2 q^4 - 1980 q^3 + 1425 q^2 - 540 q + 84) + p^4 (-25 q^6 + 300 q^5 - 8175/8 q^4 + 1450 q^3 - 1875/2 q^2 + 300 q - 35) + p^3 (45/4 q^6 - 135 q^5 + 1785/4 q^4 - 580 q^3 + 300 q^2 - 60 q) + p^2 (-45/16 q^6 + 135/4 q^5 - 855/8 q^4 + 120 q^3 - 75/2 q^2) + p (5/16 q^6 - 15/4 q^5 + 45/4 q^4 - 10 q^3) + 1$
I would like to find all values of $q$ for which this polynomial is equal to $1-p$. The following code block illustrates my problem:
sage: fid7tof
5/4*(5*q^6 - 60*q^5 + 210*q^4 - 320*q^3 + 240*q^2 - 96*q + 16)*p^7 - 35/8*(5*q^6 - 60*q^5 + 210*q^4 - 320*q^3 + 240*q^2 - 96*q + 16)*p^6 + 3/8*(85*q^6 - 1020*q^5 + 3540*q^4 - 5280*q^3 + 3800*q^2 - 1440*q + 224)*p^5 - 5/8*(40*q^6 - 480*q^5 + 1635*q^4 - 2320*q^3 + 1500*q^2 - 480*q + 56)*p^4 + 5/4*(9*q^6 - 108*q^5 + 357*q^4 - 464*q^3 + 240*q^2 - 48*q)*p^3 - 15/16*(3*q^6 - 36*q^5 + 114*q^4 - 128*q^3 + 40*q^2)*p^2 + 5/16*(q^6 - 12*q^5 + 36*q^4 - 32*q^3)*p + 1
sage: solve([fid7tof == 1-p], q)
[0 == 5*(10*p^4 - 20*p^3 + 16*p^2 - 6*p + 1)*q^6 - 60*(10*p^4 - 20*p^3 + 16*p^2 - 6*p + 1)*q^5 + 30*(70*p^4 - 140*p^3 + 109*p^2 - 39*p + 6)*q^4 - 160*(20*p^4 - 40*p^3 + 29*p^2 - 9*p + 1)*q^3 + 160*p^4 + 600*(4*p^4 - 8*p^3 + 5*p^2 - p)*q^2 - 320*p^3 - 960*(p^4 - 2*p^3 + p^2)*q + 112*p^2 + 48*p + 16]
All Sage returns is another multivariate polynomial, which doubtless has many solutions $\bar{q}(p)$. Is there something I can do to get these solutions?bcrigerMon, 08 Jul 2013 07:10:36 -0500http://ask.sagemath.org/question/10331/wxMaxima cannot reduce system to a polynomial in one variablehttp://ask.sagemath.org/question/8204/wxmaxima-cannot-reduce-system-to-a-polynomial-in-one-variable/I'm attempting to use wxMaxima 11.04.0 to solve some non-linear equations symbolically, but I get the error "algsys: tried and failed to reduce system to a polynomial in one variable; give up.". Having solved these eqns by hand, I believe there is a solution. Since I am new to wxMaxima, I am probably using it incorrectly. Can someone suggest how I can get the solution I want?
Here is the wxMaxima transcript:
(%i1) A14:d=s*r/(D*M);
A11:\alpha *\eta *(M*(1-d)/\rho)^(1/3)*D=r/F;
(%o1) d=(r*s)/(D*M)
(%o2) (alpha*(1-d)^(1/3)*eta*D*M^(1/3))/rho^(1/3)=r/F [this is actually rendered with Greek letters]
(%i3) solve([%o1,%o2],[d,D]);
algsys: tried and failed to reduce system to a polynomial in one variable; give up.
Substituting d from A14 into A15 yields a cubic in D. I would like to see that, and also the solution of that cubic. For values of the parameters s, r, etc that I will use, there will be only one real root, but of course 'solve' can't know that, as I have asked for a symbolic solution.
WoodySMFri, 01 Jul 2011 08:16:49 -0500http://ask.sagemath.org/question/8204/