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.Wed, 28 Aug 2024 13:38:06 +0200Why does factor() assume that variables are real?https://ask.sagemath.org/question/78898/why-does-factor-assume-that-variables-are-real/ I am sure that I am doing something wrong, so I would appreciate if you could tell me what is going on. Consider the following code:
z1, z2 = var('z1, z2')
term = z1 * z2.conjugate() - z2 * z1.conjugate()
show(term)
show(term.factor())
The first one outputs the correct result, but the second one gives 0. It looks like sage is assuming that things are real when passing to factor(). Is this a bug or the correct behaviour? What do I need to do to avoid this? (Right now, I am expressing all such variables as Real + I * Imag explicitly, but I suspect there is a better way)razimantvWed, 28 Aug 2024 13:38:06 +0200https://ask.sagemath.org/question/78898/fast factorization of ratios of polynomialshttps://ask.sagemath.org/question/60957/fast-factorization-of-ratios-of-polynomials/I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ is a Laurent monomial with unit coefficient in variables $x_1,\ldots,x_k, q_1,q_2,q_3,m$.
I'm interested in taking ratios of the form $P_1 / (P_2 \prod_{n=1}^k x_n)$ of such polynomials, and would like to know what the fastest way is to cancel common factors using sagemath.
The final goal is to take residues at simple poles, so factorizations will happen.
Let me write a full code example:
def br(x):
return 1-1/x
q1,q2,q3,m = var('q1,q2,q3,m')
def mex(q1,q2,q3,m):
q4 = var('q4')
N.<q1,q2,q3,q4> = PolynomialRing(ZZ, 4, order='neglex')
k = 3
K = 1 + q1 + q2
rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()]
X = [var("x%d" % i) for i in range(k)]
chim = prod([ br(X[j]/m) for j in range(k)])
chix = prod([ br(X[j]) for j in range(k)])
chiup = prod([ prod([ br(q1*q2*X[i]/X[j])*br(q1*q3*X[i]/X[j])*br(q2*q3*X[i]/X[j])*(br(X[i]/X[j]))^2 for i in range(k) if i > j]) for j in range(k)])
chiups = prod([ prod([ br(X[i]/(X[j]*q1*q2))*br(X[i]/(X[j]*q1*q3))*br(X[i]/(X[j]*q2*q3)) for i in range(k) if i > j]) for j in range(k)])
chido = prod([ prod([ br(q1*X[i]/X[j])*br(q2*X[i]/X[j])*br(q3*X[i]/X[j])*br(q1*q2*q3*X[i]/X[j]) for i in range(k) if i > j]) for j in range (k)])
chidos = prod([ prod([ br(X[i]/(X[j]*q1))*br(X[i]/(X[j]*q2))*br(X[i]/(X[j]*q3))*br(X[i]/(X[j]*q1*q2*q3)) for i in range(k) if i > j]) for j in range (k)])
dx = prod([ X[j] for j in range(k)])
chinum = (chim*chiup*chiups)
chiden = (chix*chido*chidos*dx)
chi = chinum/chiden
# return chi.factor()
for xi,rhoi in zip(X,rho):
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
return chi
This currently works in the symbolic ring, but gets slow as soon as k,K grow a bit.
I was hoping that using singular (Laurent polyn ring, e.g.) would make it faster, but cannot make it such that everything happens there yet.rue82Sat, 05 Feb 2022 19:02:55 +0100https://ask.sagemath.org/question/60957/Wrong result after using factor(): known Sage bug?https://ask.sagemath.org/question/57859/wrong-result-after-using-factor-known-sage-bug/It looks like factor() doesn't play well with complicated expressions like in the code below.
Is this a known bug? I am using Sage 9.3.
var('x', domain='positive')
f(x) = (3/174465461165747500*pi*(-1750000*I*pi*x^3 - 31250000*(224*pi + 45*sqrt(448*pi + 2025) + 2025)*x^2
+ 17500000000000000*I*pi*x)
*sqrt(92821652156334811582567480952850314403/10*pi^2/(224*pi + 45*sqrt(448*pi + 2025) + 2025)
+ 98489794142024498175862287197250000*pi*sqrt(448*pi + 2025)
/(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 7713517620898636162808584411766250000*pi
/(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 659225266976959904108326638192187500*sqrt(448*pi + 2025)
/(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 29665137013963195684874698718648437500
/(224*pi + 45*sqrt(448*pi + 2025) + 2025))
/(63*pi^2*x^4 - (504000*I*pi^2 + 67500*I*pi*(sqrt(448*pi + 2025) + 45))*x^3
- 3000000*(560224*pi^2 + 45*pi*(sqrt(448*pi + 2025) + 45))*x^2 + 8400000000000000000000*pi^2
- (-5040000000000000*I*pi^2 - 675000000000000*I*pi*(sqrt(448*pi + 2025) + 45))*x))
F = f.real()^2 + f.imag()^2
G = (f.real()^2 + f.imag()^2).factor()
print(N(f(1)))
print(N(F(1)))
print(N(G(1)))
Here is the output. The result for G is clearly incorrect.
418409.917305475 + 1.28757494213663e11*I
1.65784923163565e22
4.77205703148314e29Tony-64Sat, 03 Jul 2021 22:26:48 +0200https://ask.sagemath.org/question/57859/why can't I compute the zeros of an integer polynomial using solve()?https://ask.sagemath.org/question/57833/why-cant-i-compute-the-zeros-of-an-integer-polynomial-using-solve/ This works fine, producing complex roots:
x=var('x')
f=x+x**2+x**3-100
z=solve(f==0,x)
this also works fine:
R.<x>=ZZ[]
f=x+x**2+x**3-100
f.roots()
but this seems to run forever without error message and I don't understand why:
x=var('x',domain=ZZ)
f=x+x**2+x**3-100
z=solve(f==0,x)
can anyone explain or tell me where to start reading to understand this behaviour?
dantetanteThu, 01 Jul 2021 08:12:48 +0200https://ask.sagemath.org/question/57833/How to print positive integers that divides a number without a remainder?https://ask.sagemath.org/question/55564/how-to-print-positive-integers-that-divides-a-number-without-a-remainder/Hi,
Is there a function in Sage that prints all the positive integers that divides without a remainder?
I am using `factor()` but I think it only shows the prime factorization.
For example, using `factor(54)` returns `2 * 3^3` in Sage but all the positive integers are:
1 × 54 = 54
2 × 27 = 54
3 × 18 = 54
6 × 9 = 54
9 × 6 = 54
18 × 3 = 54
27 × 2 = 54Robert HWed, 03 Feb 2021 18:54:33 +0100https://ask.sagemath.org/question/55564/Problem with factor and imag.https://ask.sagemath.org/question/53947/problem-with-factor-and-imag/I'm new to SageMath, and I'm not sure what's going wrong.
Here are the commands I enter and results I get:
sage: a, b, z = var('a, b, z')
sage: P = a*x - b*x
sage: Q = a*imag(z) - b*imag(z)
sage: P.factor()
(a - b)*x
sage: Q.factor()
0
Why is `Q` factoring to `0`?lfcSat, 17 Oct 2020 20:56:49 +0200https://ask.sagemath.org/question/53947/factoring an expressionhttps://ask.sagemath.org/question/51845/factoring-an-expression/Hello,
Is there a way to factor the following expression out
x^3+3*x
as
x^2*(x+3/x)
Thanks for your help.curios_mindMon, 08 Jun 2020 22:38:02 +0200https://ask.sagemath.org/question/51845/how to best simplify/factor symbolic expressionshttps://ask.sagemath.org/question/49616/how-to-best-simplifyfactor-symbolic-expressions/Define symbolic expressions T3 and T3s.
q1,q2,q3 = var('q1,q2,q3')
T3 = (q1^2*q2^2 + 1)*(q1^2*q3^2 + 1)*(q2^2*q3^2 + 1)*(q1*q2 + 1)*(q1*q2 - 1)*(q1*q3 + 1)*(q1*q3 - 1)*(q2*q3 + 1)*(q2*q3 - 1)/((q1^2*q2^2*q3^2 + 1)*(q1*q2*q3 + 1)*(q1*q2*q3 - 1)*(q1^2 + 1)*(q2^2 + 1)*(q3^2 + 1)*(q1 + 1)*(q1 - 1)*(q2 + 1)*(q2 - 1)*(q3 + 1)*(q3 - 1))
T3s = (q1^4*q2^4 - 1)*(q1^4*q3^4 - 1)*(q2^4*q3^4 - 1)/((q1^4*q2^4*q3^4 - 1)*(q1^4 - 1)*(q2^4 - 1)*(q3^4 - 1))
Is there any method to reduce T3 to its simpler (at least for a human) form T3s in Sage?rue82Tue, 21 Jan 2020 12:07:05 +0100https://ask.sagemath.org/question/49616/factorize symbolic expressionhttps://ask.sagemath.org/question/49040/factorize-symbolic-expression/ (ax+bx).factor()=x(a+b)
but
(2a+2b).factor()=(2a+2b)
how to obtain 2(a+b) ?
Thanks in advance...JingenblSun, 15 Dec 2019 15:36:29 +0100https://ask.sagemath.org/question/49040/Excluding a common factor in a sumhttps://ask.sagemath.org/question/26628/excluding-a-common-factor-in-a-sum/I'm trying to figure out how to simplify this expression in Sage:
y = tau1*exp(-t/tau1)/(tau1 - tau2) - tau1*exp(-t/tau2)/(tau1-tau2)
When I try *factor(y)* or *simplify(y)*, I get this:
-tau1*(e^(t/tau1) - e^(t/tau2))*e^(-t/tau1 - t/tau2)/(tau1 - tau2)
However, the result I would like to see is this:
tau1/(tau1 - tau2)*(exp(-t/tau1) - exp(-t/tau2))
which seems like the simplest form to me. I've not been able to get this result with the various simplify commands or with assumptions (BTW, all variables are real, and tau1 & tau2 > 0).
In this case the simplest form is obvious, of course, but it would be a great help to be able to get this right for larger expressions.
drs663Thu, 23 Apr 2015 11:29:25 +0200https://ask.sagemath.org/question/26628/Factor function in Sagehttps://ask.sagemath.org/question/48507/factor-function-in-sage/For factoring large semi-primes (140bit +) is there any GNFS or Msieve in sage?
What does factor() use under the hood? john_alanSat, 26 Oct 2019 11:19:23 +0200https://ask.sagemath.org/question/48507/Factor a solve outputhttps://ask.sagemath.org/question/45716/factor-a-solve-output/ I am new to sage. So, sorry if my question is too trivial.
I can not factor the output of "solve". For instance, this very simple example
x= var('x')
sols=solve(x==6, x)
factor(sols[0].right())
gives me
6
Why I am not getting the following?
2 * 3
which of course is the output of
factor(6).
PS: I guess that the "type" is a crucial thing here, but anyways I'd need to factor 'sage.symbolic.expression.Expression'tidessonFri, 08 Mar 2019 00:25:05 +0100https://ask.sagemath.org/question/45716/Wrong factorization of expressions containing exponentials ?https://ask.sagemath.org/question/45469/wrong-factorization-of-expressions-containing-exponentials/Is there something wrong with the factorization of expressions containing exponentials ?
I obtain the following strange results (Sagemath 8.6):
`factor(exp(-x)+2*exp(x))` ---> `3*e^x`,
`factor(exp(-x)+x*exp(-x))` ---> `(x + 1)*e^x`
Any suggestions welcomed.irizosFri, 15 Feb 2019 13:40:40 +0100https://ask.sagemath.org/question/45469/Factorize characteristic polynomial in SR base ringhttps://ask.sagemath.org/question/45249/factorize-characteristic-polynomial-in-sr-base-ring/ I am total newbie to SAGE so this question might be trivial. How can I factorize the characteristic polynomial obtained by a symbolic matrix in SAGE 8.6? Is there a workaround the fact that `factor()` is not defined on the base ring `SR` which is the one inherited from the symbolic matrix?
For example I have in a SAGE/Jupyter notebook something like:
a,b,c = var('a','b','c')
M = Matrix(SR,3,3)
M[0] = [a, -b, 0]
M[1] = [c, a+b, 0]
M[2] = [0, 0, 1]
e = M.eigenvalues()
f = M.charpoly()
factor(f)
The last instruction raises a `NotImplementedError` as expected from the fact that `factor` is not defined on `SR`...
In my real problem I am computing characteristic polynomials of large (8x8) symbolic matrices and I would like to get at glance all the factors, so as to quickly isolate negative real roots and instead easily discuss conditions for existence and sign of symbolic ones.maurizioThu, 31 Jan 2019 18:26:46 +0100https://ask.sagemath.org/question/45249/LaurentPolynomial can't factor constantshttps://ask.sagemath.org/question/44764/laurentpolynomial-cant-factor-constants/Hi all,
Many `LaurentPolynomials` throw errors when I try to factor them. For example:
sage: R.<x,y> = LaurentPolynomialRing(QQ)
sage: R.one().factor()
AttributeError: ...
sage: (x^-1).factor()
AttributeError: ...
This seems to come from the unit part of `Polynomial.factor()` sometimes (incorrectly) living in `Integer Ring`, and sometimes (correctly) living in whatever `self.parent()` is.
Is this intentional or a bug?
Thanks,
Henryliu.henry.hlSun, 23 Dec 2018 22:28:33 +0100https://ask.sagemath.org/question/44764/From Pari to SAGEhttps://ask.sagemath.org/question/44657/from-pari-to-sage/
f(n,p)={d=ceil(log(2)/log(10)*(n-1));s=lift(Mod(2,p)^(n-1));t=lift(Mod(10,p)^d);u=lift(Mod((2*s-1)*t+s-1,p));u}
v=[100000..101000]
forprime(q=1,10^7,z=select(m->f(m,q)==0,v);if(length(z)>0,v=setminus(v,z);print(q," ",length(z)," ",length(v))))
This is a program for PARI. For numbers of the form (2^k-1)*10^d+2^(k-1)-1 where d is the number of decimal digits of 2^(k-1)-1 in the range k=[100000..101000], it displays numbers with no factor below 10^7. Can somebody translate this PARI program in a SAGE program?polistiroloThu, 13 Dec 2018 15:46:48 +0100https://ask.sagemath.org/question/44657/code snippet resp. simplify and factorhttps://ask.sagemath.org/question/42786/code-snippet-resp-simplify-and-factor/this doesn't work
var('c')
mat=matrix([[1,0],[0,c]])
xy0=vector([c,1])
r0=-mat*xy0
p0=r0
for k in range(2):
la=r0*p0/(p0*mat*p0)
xy1=xy0+la*p0
print xy1
if xy1[0]!=0:
xy1[0]=xy1[0].factor()
if (xy1[1])!=0:
xy1[1]=xy1[1].factor()
print xy1
r1=(r0-la*mat*p0)
p1=r1+r1*r1/(r0.dot_product(r0))*p0
p1=p1.simplify_full()
p0=p1
r0=r1
xy0=xy1
print '--------------------'
but this works
var('c')
mat=matrix([[1,0],[0,c]])
xy0=vector([c,1])
r0=-mat*xy0
p0=r0
for k in range(2):
la=r0*p0/(p0*mat*p0)
xy1=xy0+la*p0
print xy1
xy1=xy1.simplify_full() # <<<<<<<<< inserted this command
if xy1[0]!=0:
xy1[0]=xy1[0].factor()
if (xy1[1])!=0:
xy1[1]=xy1[1].factor()
print xy1
r1=(r0-la*mat*p0)
p1=r1+r1*r1/(r0.dot_product(r0))*p0
p1=p1.simplify_full()
p0=p1
r0=r1
xy0=xy1
print '--------------------'rewolfSat, 30 Jun 2018 13:41:03 +0200https://ask.sagemath.org/question/42786/Why does $\frac{2}{3} t - \frac{2}{3} y$ factors only when the variables are polynomial ring over the rational numbers?https://ask.sagemath.org/question/38549/why-does-frac23-t-frac23-y-factors-only-when-the-variables-are-polynomial-ring-over-the-rational-numbers/The expression $\frac{2}{3} t - \frac{2}{3} y$ can be factored as $\left(\frac{2}{3}\right) \cdot (y - t)$.
If I try to use sage in this way to do the factorization:
var('y t')
E = -2/3*y + 2/3 * t
E.factor()
The result is still `E`.
On the other hand, if do it like this:
R.<y,t> = PolynomialRing(QQ)
E = -2/3*t +2/3*y
E.factor()
The result is as expected.
Why does the call to `factor()` works as expected when the variable $y$ and $t$ are defined to be a polynomial ring in QQ and not work then they are symbolic expressions.ensabaThu, 17 Aug 2017 00:18:50 +0200https://ask.sagemath.org/question/38549/How to get sage to keep the same form as an expression from sympy?https://ask.sagemath.org/question/38492/how-to-get-sage-to-keep-the-same-form-as-an-expression-from-sympy/ I have this expression:
$$-\frac{2}{3} t_{1} + \frac{2}{3} y_{1}$$
and would like to rewrite it as follows:
$$\frac{2}{3} (-t_1 + y_1)$$
Using sympy, I can get something close:
import sympy as sp
var('y1 t1')
expr1 = -2/3*t1 + 2/3*y1
sp.factor(sp.sympify(expr1))
This gives:
𝟸*(⎯𝚝𝟷+𝚢𝟷)/𝟹
But when I convert it back to Sage:
sp.factor(sp.sympify(expr1))._sage_()
The result reverts to `expr1`.
How can I get the call to `_sage_()` not do any rewrites on the sympy expression?ensabaWed, 09 Aug 2017 01:31:19 +0200https://ask.sagemath.org/question/38492/simplify expression (square polynomial)https://ask.sagemath.org/question/37488/simplify-expression-square-polynomial/I and using sage to convert x^2 + 2*x + 1 to (x + 1)^2 by using the following:
show((y**2 + 2*y + 1).simplify_full())
but it does not do anything and returns the expression as it is. How do I make it do it ? Thanks!sage_user47Tue, 02 May 2017 20:20:46 +0200https://ask.sagemath.org/question/37488/Factoring out complex exponentialshttps://ask.sagemath.org/question/36495/factoring-out-complex-exponentials/Hi, If I have an expression as follows
$\frac{3}{8} {{E}_y^-}^{2} \overline{{E_y^+}} e^{\left(i \omega t +
3 i k x\right)} + \frac{3}{8} \, {{E}_y^-}^{2} \overline{{{E}_y^-}}
e^{\left(i \omega t + i k x\right)} + \frac{3}{4} \, {{E}_y^-}
{E_y^+} \overline{{E_y^+}} e^{\left(i \, \omega t + i \, k x\right)} +
\frac{3}{4} \, {{E}_y^-} {E_y^+} \overline{{{E}_y^-}} e^{\left(i
\omega t - i k x\right)} + \frac{3}{8} \, {E_y^+}^{2}
\overline{{E_y^+}} e^{\left(i \, \omega t - i \, k x\right)} +
\frac{3}{8} \, {E_y^+}^{2} \overline{{{E}_y^-}} e^{\left(i \omega t -
3 i k x\right)}$
How do I factor out a complex exponential $e^{i\omega t - ikx}$ from the expression above using a command?NahsiNThu, 09 Feb 2017 04:42:46 +0100https://ask.sagemath.org/question/36495/Number of factors of a polynomialhttps://ask.sagemath.org/question/34910/number-of-factors-of-a-polynomial/Given a polynomial f, the command `f.factor()` gives the factorization of f. I want to find out the number of factors of f. Is there any command for that ?
The polynomial ring is assumed to be `ZZ[x]`.nebuckandazzerFri, 23 Sep 2016 17:41:06 +0200https://ask.sagemath.org/question/34910/Factoring a polynomial over a finite Fieldhttps://ask.sagemath.org/question/25116/factoring-a-polynomial-over-a-finite-field/Hello
I'm following a 101 algebra course, and for example, I would like to factor a polynomial on a finite field like F_9
(F_9 == ZZ/9ZZ is a field because 9 is a power of a prime number, 3)
R = PolynomialRing(GF(9),'x')
x = R.gen()
f = x^4+x^2-1
f in R
f.factor()
i get an error message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_68.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UiA9IFBvbHlub21pYWxSaW5nKEdGKDkpLCd4JykKeCA9IFIuZ2VuKCkKZiA9IHheNCt4XjItMQpmIGluIFI="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpYgKq_W/___code___.py", line 3, in <module>
R = PolynomialRing(GF(_sage_const_9 ),'x')
File "factory.pyx", line 364, in sage.structure.factory.UniqueFactory.__call__ (build/cythonized/sage/structure/factory.c:1244)
File "/home/sage/sage-6.3/local/lib/python2.7/site-packages/sage/rings/finite_rings/constructor.py", line 414, in create_key_and_extra_args
raise ValueError("parameter 'conway' is required if no name given")
ValueError: parameter 'conway' is required if no name given
i'm running sage 6.3 notebook on windows through Oracle VM winbox.
I'm a totally new user, and i've looked at the tutorial and the forum but
couldn't find any example or reason why this would not work.
thank you for your help.
faguiThu, 04 Dec 2014 09:29:43 +0100https://ask.sagemath.org/question/25116/List of prime factors with repetitionhttps://ask.sagemath.org/question/33493/list-of-prime-factors-with-repetition/Is there a simple command on Sage wich gives, in place of factor(720)= 2^4 * 3^2 * 5, the list [2, 2, 2, 2, 3, 3, 5] of prime factors with repetition?logomathSat, 21 May 2016 16:14:39 +0200https://ask.sagemath.org/question/33493/Loop over integers mod phttps://ask.sagemath.org/question/33000/loop-over-integers-mod-p/ What is the most efficient way to factor a polynomial mod $p$ for various $p$ all at once, perhaps to be assembled into a table with more fancy code?
For example, suppose I want to factor $x^2-17 mod p$ for the first 100 primes. My first guess is to type out the proper code to factor $x^2-17$ over the ring Integers(i) where i runs through an appropriate prime_range. But Sage says I am not allowed to put a variable into Integers(). So what is the best way to do this?SupersingularityTue, 05 Apr 2016 05:59:05 +0200https://ask.sagemath.org/question/33000/sqrt function not working properlyhttps://ask.sagemath.org/question/30325/sqrt-function-not-working-properly/ I have the following code where I want to substitute `a, b, c` into `s`. Since `s` factors as a square, I want to get the square root of it :
p, t= var('p t')
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi [equation (1.1)]
s=(factor(2*c^2+2*a^2-b^2));s
S=s.sqrt();S
Unfortunately the answer I get is
sqrt((3*p*t^2 - 2*p^2 - 2*p*t + t^2 + p + 2*t + 1)^2)
The `sqrt` and the square power does not cancel off which I want it to cancel. I tried using the code `S.simplify_full()` to simplify it hoping the sqrt and square power will cancel off but no luck. Is there any other specific code I can use for that.
ShaThu, 29 Oct 2015 00:45:04 +0100https://ask.sagemath.org/question/30325/Define a factor of an equationhttps://ask.sagemath.org/question/30232/define-a-factor-of-an-equation/ I have the following code :
p, t= var('p t')
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi [equation (1.1)]
s=factor(2*c^2+2*a^2-b^2);s
which yields
(3*p*t^2 - 2*p^2 - 2*p*t + t^2 + p + 2*t + 1)^2
I want to use the factor `(3*p*t^2 - 2*p^2 - 2*p*t + t^2 + p + 2*t + 1)` in my next command. How should I define that. Like I want to set `m = 3*p*t^2 - 2*p^2 - 2*p*t + t^2 + p + 2*t + 1`. Tried using `operand()` but did not help muchShaFri, 23 Oct 2015 03:50:36 +0200https://ask.sagemath.org/question/30232/List common factors of integershttps://ask.sagemath.org/question/10794/list-common-factors-of-integers/I have an `N = pq`, how do I list all common factors of
- 153593241046674892978867376676801703195333499261944069748317
- 595581987651106688365284842778515858399666547859870373300567
- 456451496401875224148239517183071489325356803521953515331953
- 732521324063413291774595255009269986704084399047286433357607
- 697998237255232517803133139640937207091669333334886072165381
- 665759389457622825753076124570026166878147870317677657070179
- 1259985415634532155096901933248348760395037298806289273584121
- 476063424836313254692044012215359579492944897779738635204933
- 176294427788887166758409622538881387638478405478915857712513
- 62438334806032841411208819703508997562716700552371135112697
- 1155831644188436440125346091174944695123678746779608256372229
- 592339248856319601455928821705423109007342115448431777433343
Also, how do I implement this in Sage?
I've read something about the `collect_common_factors()` but I'm not sure how to use it.iGrasmatMon, 02 Dec 2013 17:59:30 +0100https://ask.sagemath.org/question/10794/exact factortinghttps://ask.sagemath.org/question/10638/exact-factorting/How do you get sage to factor into exact values. For instance, I want it to factor x^2-2 and return (x-sqrt(2))*(x+sqrt(2))
However, when I input
realpoly.<x> = PolynomialRing(CC)
factor(x^2-2,x)
Sage returns
(x - 1.41421356237310) * (x + 1.41421356237310)
Any ideas? ClemFanJC07Sun, 20 Oct 2013 19:43:06 +0200https://ask.sagemath.org/question/10638/factor with a boundhttps://ask.sagemath.org/question/10273/factor-with-a-bound/Hi,
I need to find relatively small prime factors of some big numbers. How do I make factor command working with a bound? For instance let's say I am just interested in prime divisors less than 20 and I want to factor 11891. The answer I want would be 11*1081.
AlperenTue, 25 Jun 2013 03:29:04 +0200https://ask.sagemath.org/question/10273/