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.Sat, 10 Apr 2021 03:40:02 +0200list of all prime powers -1https://ask.sagemath.org/question/56587/list-of-all-prime-powers-1/The primes () method gives the list of all primes. Similarly, I need a list (Say PP) that consists of all $p^k-1$ where $p$ is a prime and $k \ge 1$. How to create this infinite list?
Also, I want all possible finite products of elements of PP. Using this I want to understand when two such products are equal.
How to do this? Kindly share your thoughts. Thank you.GA3165Sat, 10 Apr 2021 03:40:02 +0200https://ask.sagemath.org/question/56587/numbers in numbers - divide by 2 - cyclic -algorithm comparehttps://ask.sagemath.org/question/56130/numbers-in-numbers-divide-by-2-cyclic-algorithm-compare/We got cyclic of integers divide by 2 in number 2**n.
Example:
8192 is even number
4096 is even number 4096 is even number
2048 is even number 2048 is even number 2048 is even number
1024 is even number 1024 is even number 1024 is even number 1024 is even number
512 is even number 512 is even number 512 is even number 512 is even number
256 is even number 256 is even number 256 is even number 256 is even number
128 is even number 128 is even number 128 is even number 128 is even number
64 is even number 64 is even number 64 is even number 64 is even number
32 is even number 32 is even number 32 is even number 32 is even number
16 is even number 16 is even number 16 is even number 16 is even number
8 is even number 8 is even number 8 is even number 8 is even number
4 is even number 4 is even number 4 is even number 4 is even
2 is even number 2 is even number 2 is even number 2 is even number
1 is odd number 1 is odd number 1 is odd number 1 is odd number
second example number:
**8186 is even number 40930 is even number
4093 is odd number 20465 is odd number
4092 is even number 20464 is even number
2046 is even number 10232 is even number
1023 is odd number 5116 is even number
1022 is even number 2558 is even number
511 is odd number 1279 is odd number
510 is even number 1278 is even number
255 is odd number 639 is odd number
254 is even number 638 is even number
127 is odd number 319 is odd number
126 is even number 318 is even number
63 is odd number 159 is odd number
62 is even number 158 is even number
31 is odd number 79 is odd number
30 is even number 78 is even number
15 is odd number 39 is odd number
14 is even number 38 is even number
7 is odd number 19 is odd number
6 is even number 18 is even number
3 is odd number 9 is odd number
2 is even number 8 is even number**
1 is odd number 4 is even number
2 is even number
1 is odd number
how to analyze ciclic of divide number ? or how many ciclic are ?I mean I wuold like to perfom algorithm which will be detect probality divide number without knowing the number. it is cripto task.
for example we know that Point(X,Y) can be odd like 1,3,5,7,9 or even like 2,4,6,8,
depends is odd we must substract 1 to get even, but if even we can divide 2.
it must be analyze possibilities.MiroslawFri, 12 Mar 2021 12:01:54 +0100https://ask.sagemath.org/question/56130/Spanish numbers using LaTeXhttps://ask.sagemath.org/question/47018/spanish-numbers-using-latex/Dear SageMath community,
I am currently writing a LaTeX document in Spanish that relies heavily on sageTeX for computations. The rules for writing numbers in Spanish are a little different from English ones. For example, we are prohibited from using commas to separate every 1000 factor, instead using a small space, only if the number is longer than four digits; otherwise, no sign should be used. On the other hand, the decimal point is actually a decimal comma. For example,
- 1,000,000.25 should be written as 1 000 000,25
- 123,456,789.123456789 should be written as 123 456 789,123 456 789
- 4,000 should be written as 4000
Using sageTeX, SageMath's `latex` command, and LaTeX babel package, it is easy to replace the decimal point with a decimal comma. It is also easy to eliminate the commas for every 1000 factor. However, I haven't been able to put a small space instead.
I could use the `siunitx` LaTeX package, which has a command, `\num`, that does exactly this processing. However, it doesn't work with sageTeX's `\sage` command or any of it's environments. The only solution I can find is to apply the `\num` command directly to every number generated by SageMath via the `latex` command.
My problem is: I don't know how to do this, specially in cases where numbers are entries of a matrix, or the coefficients of a polynomial. So, **how could I apply the `\num` command to every number independently using the `latex` command?**
Thanks in advance for your answers! Any alternative approach is also welcomed.dsejasSun, 30 Jun 2019 06:08:29 +0200https://ask.sagemath.org/question/47018/How to avoid scientific notation of numbers in the Mathematica interfacehttps://ask.sagemath.org/question/48908/how-to-avoid-scientific-notation-of-numbers-in-the-mathematica-interface/ I use the mathematica interface to compute numerical values of an extended hyper-geometric function MeijerG for real arguments. This function is provided only by Mathematica:
var('x,mx')
x=0.00001
resp=mathematica.set(mx,x)
mathematica('MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, mx]')
For real arguments x >= 0.00001 I get useful numeric results, e.g.
resp=0.00025871503616237216
for x =0.00001.
However, for 0< x < 0.00001 this method fails. With a small argument x and
var('x,y,mx')
x=0.000000001
resp=mathematica.set(mx,x)
mathematica('MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, mx]'),
With this small argument, I obtain:
resp=MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, -9. + 1.*e]
Obviously, this behavious is caused by the python interpreter: It converts pure decimal presentation of numbers (see previous example) into their scientific presentation. And, as I have learned from contributions in the Mathematica's stack exchange, Mathematica doesn't accept formatted numbers like ScientficForm, etc, for numerical evaluation of functions. Thus, Mathematica lets requested numeric evaluation undone. I haven't found any hints how to prevent python from expressing the argument in scientific format. Is it possible by any means to circumvent this problem?
bekalphWed, 27 Nov 2019 16:30:46 +0100https://ask.sagemath.org/question/48908/Is it possible to change Polynomial Ring in the middle of a computation?https://ask.sagemath.org/question/42341/is-it-possible-to-change-polynomial-ring-in-the-middle-of-a-computation/ Hi, I'm trying to invert the "Pollaczek-Khinchine" Laplace transform when it is rational
This works for me at degree 2:
var('x,s')
Fx = (1/6*exp(-2*x)+5/6*exp(-6*x));rho=2/3
print('Hyperexponential claims:',Fx)
R.<s> = PolynomialRing(QQbar)#when all coefficients are not integer, use CC
FF = R.fraction_field()
L_F=laplace(Fx,x,s)#Laplace transform of F
#Compute Pollackek-Khinchine (PK) formula L_rui for the Laplace transform (LT) of ruin probability
m1=L_F(s=0)
fe=L_F/m1
Fe=(1-fe)/s
L_rui=rho*Fe/(1-rho*fe)
show(L_rui.simplify_full())
inverse_laplace(SR(L_rui),s,u)
but not at degree 3, since I do not know how to use partial_fraction_decomposition, and then to switch to RR numbers and then invert .
If I start in R.<s> = PolynomialRing(RR), for an already known LT, everything is fine. But, a certain simplification by s in PK formula will become impossible due to rounding errors, so I am forced to start with R.<s> = PolynomialRing(QQbar)
After obtaining the partial_fraction_decomposition, I must apply RR to all numbers , but I do not manage to do it. Without that conversion, inverse_laplace won't workflorinMon, 14 May 2018 19:03:38 +0200https://ask.sagemath.org/question/42341/Memory error mixing exact numbers and decimal oneshttps://ask.sagemath.org/question/36618/memory-error-mixing-exact-numbers-and-decimal-ones/ Hi,
I wonder why this code gives an error in Sage 7.5.1:
f(x)=3*sin(2*pi*(1.75-2*x))
if abs(f(0.7)) < 1e-12:
print 1
MemoryError: Not enough memory to calculate cyclotomic polynomial of 428914250225777franpenaTue, 14 Feb 2017 18:42:39 +0100https://ask.sagemath.org/question/36618/numpy.int64 vs. sage.rings.integer.Integerhttps://ask.sagemath.org/question/23366/numpyint64-vs-sageringsintegerinteger/ Hi experts!
I have a list (A) with many list generated by NetworkX. Each list have numpy.int64 numbers A=[A1,....,An], where Aj are lists of numpy.int64 integers numbers.
I want to compare this numpy.int64 numbers with sage.rings.integer.Integer numbers.
How can I do this?
Thanks a lot!mresimulatorFri, 11 Jul 2014 04:32:49 +0200https://ask.sagemath.org/question/23366/Digit Groupinghttps://ask.sagemath.org/question/10986/digit-grouping/Hello,
New to Sage--thanks to the developers--and am using it to analysis some large numbers.
Is there any way to have the resultant numbers be grouped for easy reading? Like 1,000,000 instead of 1000000?
Thank you.KChrisCMon, 03 Feb 2014 20:23:41 +0100https://ask.sagemath.org/question/10986/Artin decomposition for p-adic numbershttps://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/How can I decompose a p-adic number
... d_2 d_1 d_0. d_{-1} ... d_{-k}
into its integer part
d_2 d_1 d_0.
and fractional part
. d_{-1} ... d_{-k} ?
The does not seem to exist a kind of floor function.
Klaus ScheicherSun, 27 Oct 2013 03:06:49 +0100https://ask.sagemath.org/question/10663/Polynomial division mod nhttps://ask.sagemath.org/question/10175/polynomial-division-mod-n/Hi everyone,
Let's suppose that we are working with polynomials modulo n a composite number, for which we know the factorization (n=p*q).
If we know that f(x) can be divided by e.g. g(x), what is the most efficient way to calculate f(x)/g(x) in Z_n with Sage?
Thanks for your timecp_sageSun, 02 Jun 2013 21:37:25 +0200https://ask.sagemath.org/question/10175/