Ask Your Question

mlv's profile - activity

2024-03-22 16:07:50 +0200 marked best answer Cant factor certain polynomials over Gaussian integers

I tried to factor two simple polynomials 15t^2-60 and 15t^2+60. over the following rings: Z, Q, Z[i], and Q[i]. It is strange that attempting to do so over Z[i], Gaussian integers, will raise exceptions. But if the leading coefficient is 1, then the factorizations over Z[i] work and produce correct answers. I also noticed the 'I' in Z[i] factorization p3bf is 'I0'. Can anyone please explain why?

PRZ.<t> = PolynomialRing(ZZ)  # polynomial over Z
p1a = PRZ(15*t^2 - 60);   p1af = p1a.factor()
p1b = PRZ(15*t^2 + 60);   p1bf = p1b.factor()
print(f'PRZ:      {p1a = }      {p1af = }')
print(f'PRZ:      {p1b = }      {p1bf = }')

PRQ.<t> = PolynomialRing(QQ)  # polynomial over Q
p2a = PRQ(15*t^2 - 60);   p2af = p2a.factor()
p2b = PRQ(15*t^2 + 60);   p2bf = p2b.factor()
print(f'PRQ:      {p2a = }      {p2af = }')
print(f'PRQ:      {p2b = }      {p2bf = }')

PRZi.<t> = PolynomialRing(ZZ[I])  # polynomial over Z[i]
p3a = PRZi(   t^2 - 4);   p3af = p3a.factor()   # leading coeff is 1
p3b = PRZi(   t^2 + 4);   p3bf = p3b.factor()   # leading coeff is 1
print(f'PRZi:     {p3a = }          {p3af = }')
print(f'PRZi:     {p3b = }          {p3bf = }')

PRQi.<t> = PolynomialRing(QQ[I])  # polynomial over Q[i]
p4a = PRQi(15*t^2 - 60);   p4af = p4a.factor()
p4b = PRQi(15*t^2 + 60);   p4bf = p4b.factor()
print(f'PRQi:     {p4a = }      {p4af = }')
print(f'PRQi:     {p4b = }      {p4bf = }')

PRZi.<t> = PolynomialRing(ZZ[I])  # polynomial over Z[i]
p5a = PRZi(15*t^2 - 60);   p5af = p5a.factor()   # leading coeff is 15
p5b = PRZi(15*t^2 + 60);   p5bf = p5b.factor()   # leading coeff is 15
print(f'PRZi:     {p5a = }      {p5af = }')
print(f'PRZi:     {p5b = }      {p5bf = }')

The outputs are correct, except for p5a and p5b:

PRZ:      p1a = 15*t^2 - 60      p1af = 3 * 5 * (t - 2) * (t + 2)
PRZ:      p1b = 15*t^2 + 60      p1bf = 3 * 5 * (t^2 + 4)
PRQ:      p2a = 15*t^2 - 60      p2af = (15) * (t - 2) * (t + 2)
PRQ:      p2b = 15*t^2 + 60      p2bf = (15) * (t^2 + 4)
PRZi:     p3a = t^2 - 4          p3af = (t - 2) * (t + 2)
PRZi:     p3b = t^2 + 4          p3bf = (t - 2*I0) * (t + 2*I0)
PRQi:     p4a = 15*t^2 - 60      p4af = (15) * (t - 2) * (t + 2)
PRQi:     p4b = 15*t^2 + 60      p4bf = (15) * (t - 2*I) * (t + 2*I)

Factorizations of p5a and p5b will raise exceptions.

2024-03-22 16:07:49 +0200 commented answer Cant factor certain polynomials over Gaussian integers

Thanks for the explanation. I was hoping someone to point out a mistake on my code, so I can still non-monic polynomials

2024-03-21 05:37:15 +0200 asked a question Cant factor certain polynomials over Gaussian integers

Cant factor certain polynomials over Gaussian integers I tried to factor two simple polynomials 15t^2-60 and 15t^2+60

2024-02-21 16:34:47 +0200 commented answer Is it possible to use a Bitmap Image as a Graphics object?

Thanks for the comment. I looked at the example, which is very helpful. Do you have an example of displaying multiple im

2024-02-17 14:18:58 +0200 received badge  Editor (source)
2024-02-17 14:18:58 +0200 edited question Is it possible to use a Bitmap Image as a Graphics object?

Is it possible to use Image as a Graphics object? I can use PIL.Image or sage.repl.image in Sagemath. Can I mix bitmap (

2024-02-17 14:18:21 +0200 asked a question Is it possible to use a Bitmap Image as a Graphics object?

Is it possible to use Image as a Graphics object? I can use PIL.Image or sage.repl.image in Sagemath. Can I mix bitmap (

2024-01-16 18:24:08 +0200 commented answer Can we control the size of a plot, so I can use apng() in animation

Thanks for the prompt reply! It works!

2024-01-16 18:23:48 +0200 marked best answer Can we control the size of a plot, so I can use apng() in animation

I know how to control the size of a plot when I show the plot, eg: g.show(figsize=[3,5])

The following Sagemath code works without installing ImageMagick or FFmpeg, it is quite convenient.

frames = [plot(cos(k*x), (-pi, pi)) for k in range(1,7)]
a = animate(frames)
a.apng(savefile='ex1.png', show_path=True)

Unfortunately, the following will produce error:

frames = [plot(cos(x^k), (-2, 2)) for k in range(1,7)]
a = animate(frames)
a.apng(savefile='ex2.png', show_path=True)

After I done some debugging, I found that the individual frames produced in the for loop all have the same size. The he individual frames produced in the for loop do not all have the same size. I played with the apng() more and find that apng() seems to expect all frames to have the same size.

How can we control the plot so that the image produced in the memory all have the same size. I am not concerning with the 'display size on the screen', I am concerning with the 'size as seen by the apng() in the memory' in the for loop.

I would like to have the following option to force all frames resize to the same size when putting all frames together.

animate(frames, figsize=[3,5]). or apng(frames, figsize=[3,5])

2024-01-16 17:01:00 +0200 asked a question Can we control the size of a plot, so I can use apng() in animation

Can we control the size of a plot, so I can use apng() in animation I know how to control the size of a plot when I show

2023-05-07 18:57:07 +0200 asked a question The option 'size' or 'marker size' of list_plot is strange.

The option 'size' or 'marker size' of list_plot is strange. The option 'size' or 'marker size' of list_plot is strange.

2020-12-31 05:59:43 +0200 received badge  Famous Question (source)
2019-10-04 21:58:21 +0200 received badge  Notable Question (source)
2019-01-28 21:18:55 +0200 received badge  Student (source)
2018-06-28 03:13:49 +0200 received badge  Popular Question (source)
2012-12-29 01:23:16 +0200 commented answer How to output 'decimal' numbers in different radix.

Thanks for the solution!

2012-12-29 01:22:14 +0200 marked best answer How to output 'decimal' numbers in different radix.

You can use the str method:

sage: (13/7)
13/7
sage: (13/7).str(base=6)
'21/11'
sage: (13/7).n()
1.85714285714286
sage: (13/7).n().str(base=6)
'1.505050505050505050511'
2012-12-29 01:22:14 +0200 received badge  Scholar (source)
2012-12-29 01:22:07 +0200 received badge  Supporter (source)
2012-12-29 00:09:31 +0200 asked a question How to output 'decimal' numbers in different radix.

For example, how to output the fraction 13/7 as a 'decimal' number in the base 6? Perhaps to 4 'digits' after the 'decimal' point if the representation is not finite.