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, 19 Sep 2018 15:16:10 -0500Real Algebraic Scheme questionhttp://ask.sagemath.org/question/43704/real-algebraic-scheme-question/I apologize if this question is too naive.
I need to know the irreducible components of an algebraic scheme defined over $\mathbb{R}$. I can get Sage to do this if I consider the scheme is defined over $\mathbb{Q}$, but this is not sufficient to answer my question over $\mathbb{R}$.
Can Sage actually do this for real algebraic schemes?
and here is the code I tried:
K = RealField()
A9 = AffineSpace(K, 2, 'a,b')
A9.coordinate_ring().inject_variables()
W=A9.subscheme([a*b^2]);
W.is_irreducible()tlaneWed, 19 Sep 2018 15:16:10 -0500http://ask.sagemath.org/question/43704/Question abour numerical coercionshttp://ask.sagemath.org/question/40335/question-abour-numerical-coercions/I do not understand this :
sage: t,u=(1.4,0.7)
sage: z=complex(t,u)
This works :
sage: QQ(t)
7/5
But :
sage: AA(t)
---------------------------------------------------------------------------
TypeError
# Redacted...
TypeError: Illegal initializer for algebraic number
Similarly :
sage: QQbar(t)
---------------------------------------------------------------------------
TypeError
## Redacted...
TypeError: Illegal initializer for algebraic number
However, this works :
sage: QQbar(QQ(t))
7/5
Similarly :
sage: QQbar(z)
---------------------------------------------------------------------------
TypeError
# Redacted...
TypeError: Illegal initializer for algebraic number
One has to do :
sage: QQbar(QQ(real_part(z))+I*QQ(imag_part(z)))
7/10*I + 7/5
The same happens when you try to use other numerical types (RDF, CDF, etc...)
There must be (good) reasons to have direct coercions from numerical real types to `QQ` but not to have a direct coercion from numerical complex types to algebraic types (`AA` and `QQbar`), but I do not know them.
Or does it happen to be an oversight ?Emmanuel CharpentierThu, 28 Dec 2017 02:19:41 -0600http://ask.sagemath.org/question/40335/Complex argument of an algebraic numberhttp://ask.sagemath.org/question/9497/complex-argument-of-an-algebraic-number/This question is closely related to [that question here](http://ask.sagemath.org/question/1945/complex-argument-of-a-symbolic-expression). Basically I'd like to know whether there is a way to compute an *accurate symbolic expression* for the argument of an algebraic number.
That argument will in general not be an algebraic number itself, which seems to cause a lot of headache along the way. The following all fail, sometimes in rather spectacular backtracing ways:
sage: z = QQbar(3 + 2*I)
sage: z.arg()
AttributeError: 'AlgebraicNumber' object has no attribute 'arg'
sage: atan2(imag(z), real(z))
TypeError: Illegal initializer for algebraic number
sage: atan2(SR(imag(z)), SR(real(z)))
TypeError: Illegal initializer for algebraic number
sage: atan2(AA(imag(z)), AA(real(z)))
TypeError: Illegal initializer for algebraic number
I know a few cases which will work.
sage: atan2(QQ(imag(z)), QQ(real(z)))
arctan(2/3)
This however will break if the real or imaginary part were to contain any square roots.
sage: CC(z).arg()
0.588002603547568
This will give me a numeric approximation. I know I can get that approximation to arbitrary precision, but it's still not exact.
I have the impression that `atan2` attempts to turn its result into an algebraic number, which will fail horribly. I would expect that result to contain an unevaluated call to `atan2` instead, for the cases where the argument is not an algebraic number. Can this be done?MvGFri, 02 Nov 2012 06:42:21 -0500http://ask.sagemath.org/question/9497/Construction of formula in Sagemath programhttp://ask.sagemath.org/question/36533/construction-of-formula-in-sagemath-program/Let $P_k:= \mathbb{F}_2[x_1,x_2,\ldots ,x_k]$ be the polynomial algebra in $k$ variables with the degree of each $x_i$ being $1,$ regarded as a module over the mod-$2$ Steenrod algebra $\mathcal{A}.$ Here $\mathcal{A} = \langle Sq^{2^m}\,\,|\,\,m\geq 0\rangle.$
Being the cohomology of a space, $P_k$ is a module over the mod-2 Steenrod algebra $\mathscr{A}.$ The action of $\mathscr{A}$ on $P_k$ is explicitly given by the formula
$$Sq^m(x_j^d) = \binom{d}{m}x_j^{m+d},$$
where $ \binom{d}{m}$ is reduced mod-2 and $\binom{d}{m} = 0$ if $m > d.$
Now, I want to use the Steenrod algebra package and Multi Polynomial ring package and using formular above to construction of formula following in Sagemath program
$$
Sq^m(f) = \sum\limits_{2^{m_1} + 2^{m_2} + \cdots + 2^{m_k}= m}\binom{d_1}{2^{m_1}}x_1^{2^{m_1}+d_1}\binom{d_1}{2^{m_2}}x_2^{2^{m_2}+d_2}\ldots \binom{d_k}{2^{m_k}}x_k^{2^{m_k}+d_k}.$$
forall $f = x_1^{d_1}x_2^{d_2}\ldots x_k^{d_k}\in P_k$
Example: Let $k = 5, m = 2$ and $f = x_1^2x_2^3x_3^2x_4x_5\in P_5.$ We have
$$
Sq^2(x_1^2x_2^3x_3^2x_4x_5) = x_1^4x_2^3x_3^2x_4x_5 + x_1^2x_2^5x_3^2x_4x_5 + x_1^2x_2^3x_3^4x_4x_5
+x_1^2x_2^3x_3^2x_4^2x_5^2 + x_1^2x_2^4x_3^2x_4x_5^2 + x_1^2x_2^4x_3^2x_4^2x_5^1.$$
I hope that someone can help. Thanks!davisFri, 10 Feb 2017 00:29:40 -0600http://ask.sagemath.org/question/36533/convert from networkx to sagehttp://ask.sagemath.org/question/34136/convert-from-networkx-to-sage/ plz hep
i am new user in sage,,,
how to i use one networkx function in sage
from networkx import algebraic_connectivity as AlgebraicConnectivity........?
AlgebraicConnectivity(sage.Graph)
HakanTue, 19 Jul 2016 14:17:17 -0500http://ask.sagemath.org/question/34136/qepcad failing to replicate exampleshttp://ask.sagemath.org/question/26771/qepcad-failing-to-replicate-examples/ I was attempting to replicate the examples seen here (http://www.sagemath.org/doc/reference/interfaces/sage/interfaces/qepcad.html), but I keep getting errors.
Given
︠482004e5-daf3-4312-b5d7-a61b41d210a4s︠
var('a,b,c,d,x,y,z')
qf = qepcad_formula;
ellipse = 3*x^2 + 2*x*y + y^2 - x + y - 7
F = qf.exists(y, ellipse == 0); F
qepcad(F)
︡202e02ca-ac90-4b34-afab-7d6ceb6d41f5︡{"stdout":"(a, b, c, d, x, y, z)\n"}︡{"stdout":"(E y)[3 x^2 + 2 x y + y^2 - x + y - 7 = 0]\n"}︡{"stderr":"Error in lines 5-5\n"}︡{"stderr":"Traceback (most recent call last):\n File \"/projects/45572f4b-6bd1-49bd-9d46-5f340788b465/.sagemathcloud/sage_server.py\", line 879, in execute\n exec compile(block+'\\n', '', 'single') in namespace, locals\n File \"\", line 1, in <module>\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/qepcad.py\", line 1431, in qepcad\n qe = Qepcad(formula, vars=vars, **kwargs)\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/qepcad.py\", line 777, in __init__\n qex._send('[ input from Sage ]')\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/expect.py\", line 212, in _send\n self._start()\n File \"/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/interfaces/expect.py\", line 445, in _start\n raise RuntimeError(\"unable to start %s\" % self.name())\nRuntimeError: unable to start QEPCAD\n"}︡
︠5c912bc8-cd8b-495c-9fa3-eda33c34530e︠
MickleMouseFri, 08 May 2015 19:08:34 -0500http://ask.sagemath.org/question/26771/Get coefficients of a polynomial in quotient ringhttp://ask.sagemath.org/question/24902/get-coefficients-of-a-polynomial-in-quotient-ring/Let say I have the following quotient ring:
F.<t> = PolynomialRing(GF(2), 'x').quotient(x^128 + x^7 + x^2 + x + 1);
Then I create a polynomial, for example t^128 which yields:
t^7 + t^2 + t + 1
Now how do I obtain the array of coefficients of this polynomial?
Or, similarly, how do I actually substitute 2 for t and evaluate this polynomial? The `subs` method doesn't work. (Probably the polynomial needs to be coerced to other ring with base field where 2 != 0).
NumberFourTue, 18 Nov 2014 06:04:35 -0600http://ask.sagemath.org/question/24902/ABOUT K.ring_of_integers()http://ask.sagemath.org/question/10806/about-kring_of_integers/in William Stein book PAGE 31[Algebraic Number Theory,a Computational Approach](http://wstein.org/books/ant/ant.pdf)
there can run out the ***module basis*** derectly,but I try in sagenb online,there no ***module basis***,why?
----------------------------------
sage: K.<a> = QuadraticField(5)
sage: OK = K.ring_of_integers(); OK
Order with ***module basis 1/2*a + 1/2***, a in Number Field
in a with defining polynomial x^2 - 5
sage: Frac(OK)
Number Field in a with defining polynomial x^2 - 5
----------------------------------
K.<a> = QuadraticField(5);K;OK = K.ring_of_integers(); OK
Number Field in a with defining polynomial x^2 - 5
Maximal Order in Number Field in a with defining polynomial x^2 - 5
cjshWed, 04 Dec 2013 20:13:24 -0600http://ask.sagemath.org/question/10806/algebraic integer - PARI/GPhttp://ask.sagemath.org/question/9174/algebraic-integer-parigp/in sage you check if an algebraic number is an algebraic integer with is_integral. If I have a number(s) in an algebraic number field, and I want to check if it is an algebraic integers how do I do it in Pari/GP. Please help! Excuse me for using the forum for sage for questions about Pari/GP.paussseMon, 23 Jul 2012 12:11:12 -0500http://ask.sagemath.org/question/9174/Groebner basishttp://ask.sagemath.org/question/10265/groebner-basis/hello
I'm trying to compute groebner basis for I=( x^2+y+z-1,x+y^2+z-1,x+y+z^2-1) in sage, but why the groebner basis of this ideal is same as ideal?
thank youRoxanaThu, 20 Jun 2013 08:03:04 -0500http://ask.sagemath.org/question/10265/reduced groebner basishttp://ask.sagemath.org/question/10264/reduced-groebner-basis/hello,
how can I compute reduced groebner basis with out using buchberger algorithm in sage?RoxanaThu, 20 Jun 2013 08:00:13 -0500http://ask.sagemath.org/question/10264/Is this the correct form of computing "GCD" ?http://ask.sagemath.org/question/9984/is-this-the-correct-form-of-computing-gcd/Hi
I want to compute the following GCD,
GCD(x^4+x^2+1,x^4-x^2-2*x, x^3 - x^2-4 * x+4 )
I wrote it as
R.< x, y ,z>=PolynomialRing(QQ,3);
f=x^4+x^2+1;
g=x^4-x^2-2*x;
h=x^3-1;
k= f.gcd(g)
w=k.gcd(h)
w
Is it the correct form? or I should try any other commands?
NedaThu, 04 Apr 2013 06:36:27 -0500http://ask.sagemath.org/question/9984/Solving simultaneous boolean algebraic equationshttp://ask.sagemath.org/question/9875/solving-simultaneous-boolean-algebraic-equations/Hi,
I have been searching around for a method of solving and simplifying simultaneous boolean algebraic equations. So far I have found programs that allow the simplification of boolean algebraic expressions but non that can perform the task of solving simultaneous equations. Any help would be greatly appreciated.
Thank youJoshMon, 04 Mar 2013 18:38:12 -0600http://ask.sagemath.org/question/9875/How do I "tidy up" error terms in a matrix?http://ask.sagemath.org/question/9528/how-do-i-tidy-up-error-terms-in-a-matrix/Hi - I have some calculation results in the form of a complex Gram matrix which are all supposed to be integers (or "obvious" algebraic numbers which I know about). However inevitably in the course of creating them as inner products, some "error" terms arise which are of a size of the order of 10^-16 (real and/or complex). Is there an easy way to "clean up" my matrix with some sort of threshold, so that things which differ from a user-specified list of algebraic numbers by less than a tiny amount like 10^-15, are assumed to be the relevant algebraic number? At the moment I'm having to do it by a bunch of hideous if-statement contortions but I'm sure there's a better way!
Many thanks in advance for any help.GaryMakMon, 12 Nov 2012 06:20:49 -0600http://ask.sagemath.org/question/9528/substitute algebraic numbers into a symbolic expressionhttp://ask.sagemath.org/question/9432/substitute-algebraic-numbers-into-a-symbolic-expression/How can I substitute algebraic numbers into a symbolic expression, in order to evaluate that expression with specific values for these variables? I tried the following:
var('a')
(a*3).substitute(a=AA(2))
but this yields
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_43.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("KGEqMykuc3Vic3RpdHV0ZShhPUFBKDEpKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/ft/9rycr1td4nxdkvbf122dg4rr0000gn/T/tmpaq8Q8E/___code___.py", line 3, in <module>
exec compile(u'(a*_sage_const_3 ).substitute(a=AA(_sage_const_1 ))
File "", line 1, in <module>
File "expression.pyx", line 3759, in sage.symbolic.expression.Expression.substitute (sage/symbolic/expression.cpp:18273)
File "expression.pyx", line 2304, in sage.symbolic.expression.Expression.coerce_in (sage/symbolic/expression.cpp:13187)
File "parent_old.pyx", line 234, in sage.structure.parent_old.Parent._coerce_ (sage/structure/parent_old.c:3573)
File "parent.pyx", line 1000, in sage.structure.parent.Parent.coerce (sage/structure/parent.c:8227)
TypeError: no canonical coercion from Algebraic Real Field to Symbolic Ring
How could I modify my code above to compute the result `6` using algebraic numbers along the way? In my real life scenario, I have several variables, so turning everything into polynomials in between doesn't feel right. On the other hand, all my coefficients in my expressions are integers, so there should be no problems due to inexact floating point numbers.MvGTue, 16 Oct 2012 01:43:20 -0500http://ask.sagemath.org/question/9432/