ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 31 Jan 2021 08:18:02 -0600integer solutions to this system of equationshttps://ask.sagemath.org/question/55517/integer-solutions-to-this-system-of-equations/Consider the following system of two equations:
$$
x + y + z = 24 n + 3
$$
$$
x y z = 576 n³ + 216 n^2 + 27 n - 25
$$
For what value of $n$ are there integer solutions $x$, $y$, $z$?
Can someone help me to write down a code for the above!sonu1997Sun, 31 Jan 2021 08:18:02 -0600https://ask.sagemath.org/question/55517/How do I show in sage that an ideal is contained in another?https://ask.sagemath.org/question/51802/how-do-i-show-in-sage-that-an-ideal-is-contained-in-another/ For example I have
sage: K.<a> = QuadraticField(5)
OK = K. ring_of_integers ()
sage: J=ideal(1+7*(1+sqrt(5))/2)
J.issubset(OK)
but this does not work.MoondoggySun, 07 Jun 2020 06:35:39 -0500https://ask.sagemath.org/question/51802/How do I get that sage prints me out some itemhttps://ask.sagemath.org/question/51872/how-do-i-get-that-sage-prints-me-out-some-item/ I have the following code:
sage:R.<x>=QQ[]
f=x^2-x+6
K.<a>=NumberField(f)
cl = K.class_group()
L=K.ideal(23)
S=ideal(4,a+1)
S.is_integral()
sage: for norm, ideals in K.ideals_of_bdd_norm(50).items():
for J in ideals:
for N in range(5):
if (J.is_coprime(L*N)):
if(J!=cl.one()):
if(4*J.norm()-1 in L*N):
print norm,J,N
The output is :
True
6 Fractional ideal (6, a + 2) 1
6 Fractional ideal (a - 1) 1
6 Fractional ideal (a) 1
6 Fractional ideal (6, a + 3) 1
29 Fractional ideal (29, a + 18) 1
29 Fractional ideal (29, a + 10) 1
What do I have to do to only get the item 29 Fractional ideal (29, a + 18) 1 ?MoondoggyTue, 09 Jun 2020 11:56:10 -0500https://ask.sagemath.org/question/51872/Why does the code not work?https://ask.sagemath.org/question/51834/why-does-the-code-not-work/I want to write a program which gives me all prime ideals in the ring of integers $\mathcal{O}_K $, $K= \mathbb{Q}(\sqrt{-5})$ . They should have the property to be principal. My problem is that the condition if(J.gens()[0]-1 in L):
does not really work. By this I want that the generator of the principal ideal minus 1 is contained in the ideal L.
sage: K.<a> = QuadraticField(-5)
cl = K.class_group()
g = cl.gens()[0]
L=K.fractional_ideal(-a-1)
sage: for norm, ideals in K.ideals_of_bdd_norm(10).items():
for J in ideals:
if (J.is_prime()):
if (cl(J)==g^4):
if(J.gens()[0]-1 in L):
print norm,JMoondoggyMon, 08 Jun 2020 10:24:53 -0500https://ask.sagemath.org/question/51834/How do I write a code which gives me all prime ideals up to a specific norm?https://ask.sagemath.org/question/51803/how-do-i-write-a-code-which-gives-me-all-prime-ideals-up-to-a-specific-norm/
I am new to sage. This program should give me all prime ideals in $\mathcal{O}_K$ with $K=\mathbb{Q}(i)$ up to norm $5$. So far I have
:
sage: K.<a> = QuadraticField(-1)
for j in range(5):
L= K.ideals_of_bdd_norm(j)
if L.is_prime():
print L
MoondoggySun, 07 Jun 2020 06:50:15 -0500https://ask.sagemath.org/question/51803/SageMath giving NameError on predefined functionshttps://ask.sagemath.org/question/41825/sagemath-giving-nameerror-on-predefined-functions/ I am following **Abstract Algebra an Interactive Approach** by *William Paulsen* but some of the functions in the first chapter itself, like `ShowTerry()`, `ItitTerry()`, `MultTable()` etc are giving `NameError`. Same is the case with most of the functions in the preliminaries chapter like `ShowRationals()`, `PowerMod()` <br/> I'm not really sure how to go about it. I even tried installing sage from Source Code but the problem persists. Do I have to install some separate group theory package or am I missing something here?JarwinThu, 29 Mar 2018 12:43:15 -0500https://ask.sagemath.org/question/41825/given a prime, finding where it is the list of primeshttps://ask.sagemath.org/question/41058/given-a-prime-finding-where-it-is-the-list-of-primes/ I'm writing a program that gives as an output the prime factorization of a number, and then I'm putting the primes into a matrix based on what prime number it is, (i.e 541 is the 100th prime, so if 541^2 divides my integer, then there would be a 2 in the 100th spot of my vector that represents my number)
Is there a function that takes as its input a prime and gives as an output where it is in the list of primes.
(i.e we want f(541) = 100)
Thanks in advance!JRHalesSat, 10 Feb 2018 12:30:56 -0600https://ask.sagemath.org/question/41058/Series expansion for theta function of even latticehttps://ask.sagemath.org/question/38050/series-expansion-for-theta-function-of-even-lattice/I am new to sage and trying to figure out how to calculate the series expansion of the theta function for an even lattice $L$, i.e. $$\Theta_L(q)=\sum_{x\in L} q^{\langle x,x\rangle/2}$$
I tried the following code for the $A_2$ lattice, but I doesn't really do what its supposed to do
<pre>
Q=QuadraticForm(QQ,2,[2,-1,2]); Q
Q.theta_series(20)
</pre>
I found the following code on [OEIS](https://oeis.org/A004016), which gives the correct result:
<pre>
ModularForms( Gamma1(3), 1, prec=81).0
</pre>MarcelWed, 21 Jun 2017 19:45:53 -0500https://ask.sagemath.org/question/38050/Finding out $p$-torsion elements of an elliptic curve $E$ over $\mathbb{Q}_p$https://ask.sagemath.org/question/33551/finding-out-p-torsion-elements-of-an-elliptic-curve-e-over-mathbbq_p/ Let $E$ be an elliptic curve over $\mathbb{Q}$.
Then how to compute the $p$-torsion elements of $E$ over the $p$-adic field $\mathbb{Q}_p$ using SAGE ?
At least can we say whether $E(\mathbb{Q}_p)[p]=0$ or not ?SumanThu, 26 May 2016 05:30:16 -0500https://ask.sagemath.org/question/33551/Check if element is irreducible in algebraic number fieldhttps://ask.sagemath.org/question/26695/check-if-element-is-irreducible-in-algebraic-number-field/ If I have an algebraic number field
sage: S.<x> = NumberField(x^2+13)
is there a way to find out if an element is irreducible? There seems to be only a function to check if it is prime:
sage: (S(7)).is_prime()
False
But 7 is irreducible in $\mathbb{Q}(\sqrt{-13})$... how could I find that out?OderynThu, 30 Apr 2015 18:50:34 -0500https://ask.sagemath.org/question/26695/Roots in a polynomial over $GF(2^8)$?https://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 -0500https://ask.sagemath.org/question/10355/Verifying equality with Moduloshttps://ask.sagemath.org/question/33492/verifying-equality-with-modulos/ Hello,
I would like to verify an equality such as
((a+b)%n-b)%n == a
with, naturally, integer numbers. But i couldn't find how to declare integer but empty variables in Sage in order to test such an equality, without declaring precise and specific numbers (which would be useless, I want to verify it for **any** number of Z).
Any idea? ThanksRomuald_314Sat, 21 May 2016 08:42:35 -0500https://ask.sagemath.org/question/33492/.subfields() not working in Sage 6.2; any workaround?https://ask.sagemath.org/question/33311/subfields-not-working-in-sage-62-any-workaround/ Running Sage 6.2, the .subfields() command is not working when applied to an octic number field. Is there any workaround?
(I'm using institutional resources, but they're having trouble updating the Sage version. Hence this question.)
The screenshot is linked below. (Awkward formatting because of the karma system; sorry!)
math.umd.edu/~bloom/sagescreenshot.png
samuelbloomTue, 03 May 2016 15:20:09 -0500https://ask.sagemath.org/question/33311/Does Sage has an inverse totient function command?https://ask.sagemath.org/question/31704/does-sage-has-an-inverse-totient-function-command/I know about euler_phi(n), but is there a command where I can a get a list or some sort of other collection for all those values where n = euler_phi(f(n))? demongolemSat, 19 Dec 2015 14:36:59 -0600https://ask.sagemath.org/question/31704/How do I create the character table of the group of units mod n ?https://ask.sagemath.org/question/30501/how-do-i-create-the-character-table-of-the-group-of-units-mod-n/I expected a character table from
g=Zmod(5).unit_group()
g.character_table()
instead I got an error message ending with
AttributeError: 'AbelianGroupWithValues_class_with_category' object has no attribute 'character_table'
How do I create the character table of the group of units mod n ?nilo de roockFri, 06 Nov 2015 03:18:17 -0600https://ask.sagemath.org/question/30501/Does QuadraticField use any special algorithms for computing the class group of quadratic imaginary number fields?https://ask.sagemath.org/question/26922/does-quadraticfield-use-any-special-algorithms-for-computing-the-class-group-of-quadratic-imaginary-number-fields/ I need to compute the class group of a quadratic imaginary number field that has a fairly large discriminant (over 96 bits.) I was wondering what, if any, algorithms the QuadraticField class uses for computing the class group.
Dan ShumowFri, 22 May 2015 15:23:45 -0500https://ask.sagemath.org/question/26922/Fractional ideals for $\mathbb{Z}$https://ask.sagemath.org/question/26914/fractional-ideals-for-mathbbz/ Why isn't it possible to construct fractional ideals for the integers $\mathbb{Z}$?
sage: ZZ.fractional_ideal(3/5)
AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'fractional_ideal'
sage: II = ZZ.ideal(5)
sage: II^(-1)
TypeError: bad operand type for unary ~: 'Ideal_pid'
But absurdly this works:
sage: JJ = NumberField(x-7,"a").ring_of_integers().fractional_ideal(3/5)
sage: JJ^(-1)
Fractional ideal (5/3)
What should I do? Use this crude workaround?OderynThu, 21 May 2015 23:54:38 -0500https://ask.sagemath.org/question/26914/Factor base of class group computationhttps://ask.sagemath.org/question/26696/factor-base-of-class-group-computation/After calculating the class group using SAGE's .class_group() functionality, is there any way to find out the internal details of the calculation such as the factor base of prime ideals that was used, similar to the output given by PARI's bnfinit command? Or is the only way to just do the class group calculation by calling PARI's bnfinit command directly?JMThu, 30 Apr 2015 20:39:15 -0500https://ask.sagemath.org/question/26696/log_integral gives wrong values for complex argumentshttps://ask.sagemath.org/question/24630/log_integral-gives-wrong-values-for-complex-arguments/Riemann's formula for the number of primes less than a given number requires the calculation of the logarithmic integral (Li(x) or li(x)) for complex values. This function is implemented in Sage as log_integral.
However, it does not seem to give the correct values for complex arguments. When I feed in -4.42464733272289 + 0.649996908475887*I it returns -0.0380977804390431 + 4.49840994945387*I, but -4.41940689179334 - 0.684720910130221*I returns -0.0281163576275170 - 4.50165559913773*I, i.e., there seems to be a discontinuity when the imaginary part turns negative.
This script shows the behaviour:
start = 0
end = 10
steps = 100
args = [(start * (1 - s / steps) + end * (s / steps)) for s in range(steps+1)]
val1 = [20^(1/2+s*i) for s in args]
val2 = [log_integral(s) for s in val1]
for (x,y,z) in zip(args, val1, val2):
print n(x), '\t', n(y), '\t', n(z)
Maybe the problem is that a different branch of the complex logarithm should be used. But the values of the above sequence should converge to pi * i, which doesn't seem to be the case at all.
Has anybody seen this behaviour before or any idea how to fix it?Markus SchepkeSat, 25 Oct 2014 10:15:02 -0500https://ask.sagemath.org/question/24630/Computing the dimensions of spaces of modular & cusp formshttps://ask.sagemath.org/question/11043/computing-the-dimensions-of-spaces-of-modular-cusp-forms/In OEIS [A159634](http://oeis.org/A159634) Steven Finch gave the following
MAGMA snippet to compute the
*coefficient for dimensions of spaces of modular & cusp forms of weight k/2, level 4n and trivial character, where k >= 5 is odd.*
[[4*n, (Dimension(HalfIntegralWeightForms(4*n, 7/2)) +
Dimension(CuspidalSubspace(HalfIntegralWeightForms(4*n, 5/2))))/2]:n in [1..70]];
*How can this sequence be computed with Sage?*
Note that this question is related to a [conjecture](http://math.stackexchange.com/q/677949/129098) of Enrique Pérez Herrero.
Peter LuschnySat, 15 Feb 2014 23:55:24 -0600https://ask.sagemath.org/question/11043/ABOUT K.ring_of_integers()https://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 -0600https://ask.sagemath.org/question/10806/Factoring polynomials over IntegerModRingshttps://ask.sagemath.org/question/8209/factoring-polynomials-over-integermodrings/I'd like to factor efficiently polynomials over rings (more particularly the rings of the form IntegerModRing(n), other rings don't interest me right now). I've noticed that you can factor a polynomial differently when considering FIELDS, so that something like
factor(x^2-2, QQ[])
factor(x^2-2, RR[])
will output the different expected results. But what about
x = var('x')
factor(x^5-x, IntegerModRing(25)['x'])?
What is actually outputted right now is
(x-1)*(x+1)*(x^2+1)*x
but the true factorization is
x*(x-1)*(x+1)*(x-7)*(x+7)
(I computed it by hand, Sage couldn't do it.) Going for small numbers like 25 is easy but when I go for large numbers I get nasty codes if I try to compute that myself. Isn't there anyway to make the factor command factor those polynomials or another way to do it? Any suggestion is welcome.
I am new to Sage and I am beginning to love its features since I begin to study number theory and Sage has plenty of options for that purpose, but I must admit they are quite hard to understand since I am also new to Python, PARI, Magma... (not to programming though!) explanations in detail would be deeply appreciated.Patrick Da SilvaSun, 03 Jul 2011 16:17:48 -0500https://ask.sagemath.org/question/8209/