Ask Your Question

Daniel L's profile - activity

2021-11-20 17:58:00 +0100 received badge  Notable Question (source)
2021-04-28 22:43:55 +0100 received badge  Famous Question (source)
2021-02-03 15:25:24 +0100 received badge  Notable Question (source)
2021-02-03 15:25:24 +0100 received badge  Popular Question (source)
2020-12-09 21:37:56 +0100 received badge  Notable Question (source)
2020-12-09 11:35:51 +0100 received badge  Famous Question (source)
2020-12-01 05:17:48 +0100 received badge  Notable Question (source)
2020-10-27 20:10:33 +0100 received badge  Popular Question (source)
2020-10-14 10:48:02 +0100 received badge  Popular Question (source)
2020-03-10 03:34:19 +0100 commented question Unimodular matrices with additional restrictions

Good point. This certainly works if the dimension is 8 e.g. the $E_8$ root lattice gram matrix: E8 lattice wiki. I edited the post. Thank you

2020-03-09 18:56:08 +0100 asked a question Unimodular matrices with additional restrictions

I'd like to generate some unimodular matrices over ZZ with some restrictions:

  1. the entries are between -2 and 2
  2. the matrix is symmetric: $A = A^t$

Item (1) above can be addressed with the option upper_bound. Simply searching for matrices satisfying (1) and (2),

for j in [1..1000]:
A = random_matrix(ZZ,3,3, algorithm = 'unimodular', upper_bound = 3, max_tries = 1000)
    if A == A.transpose():

becomes extremely inefficient, especially as the dimension grows. Is there a way to enforce items (1),(2) within the unimodular algorithm? Or another workaround?

Edit: I originally also wanted the diagonal entries fixed at 2, but this is a bit too restrictive.

2020-03-09 18:34:07 +0100 received badge  Notable Question (source)
2020-02-26 18:30:01 +0100 commented answer continuous Fourier transform

Thank you!

2020-02-26 18:29:50 +0100 commented answer continuous Fourier transform

Thank you!

2020-02-21 17:07:18 +0100 received badge  Nice Question (source)
2020-02-19 20:38:32 +0100 asked a question continuous Fourier transform

I have some basic code to plot a "nice" real-valued function and its continuous Fourier transform. For example,

F(x) = e^(-x^2)*(1-x^2)
plot2 = F.plot(xmin = -5, xmax = 5, color = 'red')
### continuous Fourier transform on RR
fhat(xi) = integral((F(x)*exp(-2*pi*I*x*xi)),(x,-oo,oo))
plot1 = fhat(xi).real().plot(xmin = -5, xmax = 5)   #put fhat and f in the same plot
show(plot1 + plot2, xmin = -5, xmax = 5, ymin = -1, ymax = 2)

f and fourier transform

Like many things in Sage, I appreciate it when the code looks like the formal math. However, this code is not robust. For instance, if we change the function to

F(x) = e^(-x^2)*sin(x)/x

Then I get an error message "Variable 'xi' not found". I'd like to improve this code to work with a wider class of functions.


2019-09-12 14:01:42 +0100 received badge  Popular Question (source)
2019-06-06 21:29:14 +0100 received badge  Popular Question (source)
2019-04-30 03:42:53 +0100 received badge  Popular Question (source)
2019-03-01 12:40:51 +0100 received badge  Nice Question (source)
2018-07-01 23:32:37 +0100 received badge  Enthusiast
2018-07-01 00:13:48 +0100 commented answer Solving a power series equation

The workaround on the above thread works well. Thanks for the help!

2018-06-30 22:58:02 +0100 commented answer Solving a power series equation

When I run this code I get the following traceback error: ValueError: rtol too small (4.5e-16 < 8.88178e-16) I'm not sure what this means or why it's happening.

2018-06-29 19:52:53 +0100 asked a question Solving a power series equation

I'd like to solve the equation f(t) == 1 where f is a power series:

a1 = float(4 + sqrt(8)) 
b1 = float(3 + sqrt(8)) 
c1 = b1
an = 4*n*(n-1)+a1*n
an1 = 4*n*(n+1) + a1*(n+1)
anr = b1 + 2*n*(4*n+a1)
bn = 1+2*n*(n-1)+n*(b1-1)
bn1 = 1+2*n*(n+1)+(n+1)*(b1-1)
bnr = c1 + 2*n*(2*n+b1-1)

def f(t):
return (1+b1)^-t + 3/2*a1^-t + 1/2*(2*b1)^-t + b1^-t  + 2*sum(an^-t +an1^-t + anr^-t + 2*bn^-t +2*bn1^-t + bnr^-t ,n,1,1000).n()

I've tried simply plugging in values for t and I estimate that if f(t) = 1 then t is approximately 1.51. I'd like to possibly do something like

solve(f(t) == 1,t)

but this appears to lock sage up and I have to interrupt the process. The true f function is actually an infinite series, but I am truncating it to the first 1000 terms. I know there are methods of solving series equations such as the method of regula falsi. Does Sage have anything like this? Thanks!

2018-04-22 20:45:13 +0100 asked a question problem loading large file

I have a file which was generated and saved from a Sage notebook worksheet:


where G is a list of vectors of length roughly 20 million, and the file 'G4D200.sobj` is about 370Mb.

When I try to load this file later to do some analysis

new_G = load('/path_of_file.../G4D200.sobj')

my computer goes deep into swap memory (with python eating it all up) and basically freezes. I have done the exact same thing for smaller file sizes (<10Mb) with no issues. I've tried waiting over 30 minutes and nothing seems to happen. Is this possibly a memory issue? Something with Sage? Possible workaround? I'm running the Sage notebook in fedora linux with an older laptop with 8Gb of RAM.


2018-04-02 05:13:06 +0100 commented answer 3d plot, slow

Great, thanks for the help!

2018-03-22 21:52:29 +0100 commented question 3d plot, slow

Also, is there a way to crank up the resolution so the spheres don't look pixelated?

2018-03-22 19:47:01 +0100 asked a question 3d plot, slow

I have some graphical objects (spheres and planes) and I'm trying to create a nice picture to export as a .png (other options?). The problem I'm having is that the interactive mode (right clicking on the graphic) is so slow that the menu options freeze up. I'd like to preview the image (rotate it around, zoom, etc.) before saving so that I can make sure I've got the right picture. What is a more efficient/ faster way to create and export a 3d picture? Thanks!


E1 = implicit_plot3d(x^2+y^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray', opacity = 0.6)

E2 = implicit_plot3d((x-1)^2+y^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

E3 = implicit_plot3d((x-1/2)^2+(y-sqrt(3)/2)^2+z^2==1/4, (x,-1/2,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

E4 = implicit_plot3d(z == -1/2, (x,-1,4), (y,-1,4), (z,-0.6,0.5), color = 'gray', opacity = 0.2)

E6 = implicit_plot3d((x+1/2)^2+(y-sqrt(3)/2)^2+z^2==1/4, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'gray')

S1 = implicit_plot3d((x-1)^2+y^2+(z-1/2)^2==1, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'blue', opacity = 0.2)

S2 = implicit_plot3d((x+1/2)^2+(y-sqrt(3)/2)^2+(z+1/2)^2==1, (x,-1,3/2), (y,-1/2,sqrt(3)/2+1/2), (z,-0.5,0.5), color = 'blue', opacity = 0.2)

show(E1+E2+E3+E6+M1+S1+S2, aspect_ratio = 1, frame = false)

Also, if I try

t = E1+E2+E3+E6+M1+S1+S2'spheres.png', aspect_ratio = 1, frame = false) then the picture is quite distorted. Is aspect_ratio not what I want for 3d plots?

2018-02-01 16:25:51 +0100 commented answer random matrix with determinant +- 1

This works. Nice simple solution. Thanks Dan.

2018-02-01 06:27:00 +0100 commented answer random matrix with determinant +- 1

Right, that should work!...I'll let you know...

2018-02-01 05:15:26 +0100 asked a question random matrix with determinant +- 1

I want to generate a random 4x4 matrix with integer entries and determinant either 1 or -1. I know that you can use

random_matrix(ZZ,4,4, algorithm = 'unimodular')

to generate matrices with determinant 1 (so in the special linear group). However, I'm actually more interested in the matrices with determinant -1.

Is there a 'Sage' way to do this? Or are there other functions/routines out there I should look at?


2018-01-24 16:01:36 +0100 received badge  Popular Question (source)
2017-11-09 21:31:28 +0100 commented answer tree of vectors

On the last line tikz.pdf(), I don't get any output. I have dot2tex, graphviz, and slabbe installed. Any idea why this may be so?

2017-11-08 09:14:23 +0100 received badge  Nice Question (source)
2017-11-07 23:18:12 +0100 commented answer tree of vectors

Ok got it. In some cases, my thin_group may have loops and in other cases not. The visualization is very nice!

2017-11-07 23:18:12 +0100 received badge  Commentator
2017-11-07 22:49:01 +0100 commented answer tree of vectors

Very nice code, thank you. Can I ask, in line 4, why did you use random matrices?