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.Tue, 12 Jan 2021 13:42:57 +0100algebraic conditionhttps://ask.sagemath.org/question/55248/algebraic-condition/ Hi,
I have a very simple problem: I have a parameter a which is either 1 or -1. I have some very complicated expressions in which this parameter occurs raised to integer powers a^2, a^3, a^4 etc. I would like to implify those equations substituting the condition a^2=1, but with expr.subs a^3, a^4 etc are not replaced by a, 1, etc.
I would appreciate some help in this issue.tomasortinTue, 12 Jan 2021 13:42:57 +0100https://ask.sagemath.org/question/55248/Why won't sage (maxima) factor the symbolic expression 2*a3 - 2*a6?https://ask.sagemath.org/question/54530/why-wont-sage-maxima-factor-the-symbolic-expression-2a3-2a6/Here is some sample code.
maxima_calculus('algebraic: true;')
var('a3 a6')
(2\*a3 - 2\*a6).factor()
Does it not bother with integer factors with linear expressions, for some reason? It seems to handle more complicated expressions well, but now I'm a bit skeptical. For example, sage factors 2\*a3^2 + 4\*a3\*a6 + 2\*a6^2 just fine.TheHiggsBozoThu, 03 Dec 2020 01:49:54 +0100https://ask.sagemath.org/question/54530/Algebraic to symbolic expressionhttps://ask.sagemath.org/question/52951/algebraic-to-symbolic-expression/ Hello! When I write AA(sqrt(3)+sqrt(2)) i get 3.146264369941973?, and I use to recover the original symbolic expression sqrt(2)+sqrt(3) simply by asking the minimal polynomial of 3.146264369941973?, which is of degree 4, and looking for the appropiate root. But I want to know if there is a reasonable way to get the symbolic expression from an algebraic expression which I know it comes from a lot of operations, knowing that the function "minpoly()" in that case does not give an answer for hours. I hope you can help me!!!creyesm1992Tue, 11 Aug 2020 23:17:24 +0200https://ask.sagemath.org/question/52951/Solving equation with algebraic numbershttps://ask.sagemath.org/question/52927/solving-equation-with-algebraic-numbers/ Hello, SAGE gives me error when I load this:
solve(x^2-AA(sqrt(3))==0,x)
but it gives no problem when I load
solve(x^2-sqrt(3)==0,x)
This is a small example of a bigger problem I have in which I must solve a system of equations involving algebraic numbers through AA(.) and QQbar(.). How can I make SAGE solve equations with this type of numbers? or there is no way? Thanks!creyesm1992Mon, 10 Aug 2020 15:23:58 +0200https://ask.sagemath.org/question/52927/exact computations with algebraic numbershttps://ask.sagemath.org/question/52362/exact-computations-with-algebraic-numbers/I'm trying to do exact computations with algebraic numbers. In particular, I know to expect integer answers like `1`, `0`, and `3` at the end of my computations, but I'm getting something slightly off.
I noticed that if I run
sage: r = sqrt(2)
sage: a = AA(r)
sage: b = AA(1/r)
sage: c = a*b
Then I get:
sage: c
1.000000000000000?
Is this being handled in the computer as exactly `1`? Otherwise, how can I do exact computations with algebraic numbers in Sage? I obtain the algebraic numbers I'm working with using `algdep()` to find a polynomial and `.roots(QQbar)` to find the roots of that polynomial.b897069Mon, 06 Jul 2020 21:18:17 +0200https://ask.sagemath.org/question/52362/nearby algebraic number / convert polynomial type to expression typehttps://ask.sagemath.org/question/52263/nearby-algebraic-number-convert-polynomial-type-to-expression-type/Given a real number, I am trying to find a nearby algebraic number. This can be done in Mathematica with the RootApproximant function.
I couldn't find a similar function in Sage, so I am using algdep() to find an irreducible polynomial that is approximately satisfied by that number. Then I am using roots() to find the roots of that polynomial, and I can identify which root is closest to my number.
The problem is that the output of algdep() has a type that seems to be incompatible with roots().
When I execute this code, p.roots() returns an empty list:
p=algdep(sqrt(5), 10);
print(p.roots())
When I execute this code, a list of the roots is returned:
q = x^2 - 5
print(q.roots())
The output of algdep() has type sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint
In the second block of code, q has type sage.symbolic.expression.Expression
Is there a way to convert the first type into the Expression type?
b897069Mon, 29 Jun 2020 23:17:05 +0200https://ask.sagemath.org/question/52263/boolean function algebraic degreehttps://ask.sagemath.org/question/52195/boolean-function-algebraic-degree/ Hey, in the doc of the sage.crypto.boolean-function module, there's a algebraic_degree() method mentioned, but it's not available on my implementation of sage. Is it not up to date, or has it been deleted? Anyway, is there a more efficient way to find it than using B.algebraic_normal_form().deg()?HippolyteWed, 24 Jun 2020 11:54:06 +0200https://ask.sagemath.org/question/52195/What happened to BooleanFunction.algebraic_degree?https://ask.sagemath.org/question/52194/what-happened-to-booleanfunctionalgebraic_degree/ Hey, in the doc of the sage.crypto.boolean-function module, there's a algebraic_degree() method mentioned, but it's not available on my implementation of sage. Is it not up to date, or has it been deleted? Anyway, is there a more efficient way to find it than using B.algebraic_normal_form().deg()?HippolyteWed, 24 Jun 2020 11:53:04 +0200https://ask.sagemath.org/question/52194/Real Algebraic Scheme questionhttps://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 22:16:10 +0200https://ask.sagemath.org/question/43704/Question abour numerical coercionshttps://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 09:19:41 +0100https://ask.sagemath.org/question/40335/Construction of formula in Sagemath programhttps://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 07:29:40 +0100https://ask.sagemath.org/question/36533/convert from networkx to sagehttps://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 21:17:17 +0200https://ask.sagemath.org/question/34136/qepcad failing to replicate exampleshttps://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︠
MickleMouseSat, 09 May 2015 02:08:34 +0200https://ask.sagemath.org/question/26771/Groebner basishttps://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 15:03:04 +0200https://ask.sagemath.org/question/10265/reduced groebner basishttps://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 15:00:13 +0200https://ask.sagemath.org/question/10264/Is this the correct form of computing "GCD" ?https://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 13:36:27 +0200https://ask.sagemath.org/question/9984/Solving simultaneous boolean algebraic equationshttps://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 youJoshTue, 05 Mar 2013 01:38:12 +0100https://ask.sagemath.org/question/9875/How do I "tidy up" error terms in a matrix?https://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 13:20:49 +0100https://ask.sagemath.org/question/9528/substitute algebraic numbers into a symbolic expressionhttps://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 08:43:20 +0200https://ask.sagemath.org/question/9432/