2021-10-24 11:17:41 +0100 received badge ● Popular Question (source) 2020-07-09 22:39:44 +0100 received badge ● Famous Question (source) 2019-04-21 14:20:34 +0100 asked a question Rounding, using modular arithmetic, etc. in find_fit? I'm learning how to use find_fit and it works great for polynomials, but I'd like to include expressions that require integers. My variables are all integers, and my coefficients are expected to be relatively simple rationals (i.e. small denominators). In particular, I'd like to use a model like: model(x,y) = (a*x+b*y+c)%(d*x+e*y+f)  However, I get the expected error: TypeError: unsupported operand parent(s) for %: 'Symbolic Ring' and 'Symbolic Ring'  If I try to convert (dx+ey+f) to an integer within the model using int(), ceiling(), etc. then it won't convert, since of course it's a symbolic expression. Is there a way to round within a symbolic expression? Or any suggestions for other workarounds? Thanks! edit: I was able to get it to run, but it doesn't provide an acceptable solution. I imagine it's due to how find_fit works with user-defined functions but I don't know enough about the inner-workings to work that out. Here is my code: data = [(i,(i%2) ) for i in range(30)] var('a, b, c, d, x') def f(x, a, b, c, d): return int(a+b*x)%int(c*x+d) fit = find_fit(data, f, parameters = [a, b, c, d], variables = [x], solution_dict = True) print fit  and the output is {d: 1.0, c: 1.0, b: 1.0, a: 1.0}  I would like it to return, say, {d: 2.0, c: 0.0, b: 1.0, a: 0.0}  Is there a way to make this work a bit better for my needs? 2015-12-06 13:21:56 +0100 received badge ● Student (source) 2015-12-01 19:17:02 +0100 commented answer Can I scatter plot shaded grids? Thanks Karl-Dieter! I have the following spitting out black and white spaces. I've been trying to figure out how to use subdivisions to get horizontal and vertical lines to differentiate neighboring squares of the same color, but am coming up blank. T=[[2,3],[1,5],[5,1]] M=[[1 for x in range(6)] for x in range(6)] for L in T: M[L[0]][L[1]]=0 m=matrix(M) matrix_plot(m)  Is there a way to get lines? Gridlines only puts the lines through the centers of each square. Edit: I think I have it. I added the following line: m.subdivide(range(n),range(n))  and included subdivisions=True in matrix_plot. 2015-12-01 16:56:59 +0100 asked a question Can I scatter plot shaded grids? I would like to make a scatter plot, much like those in blog.zacharyabel.com/2012/06/putting-the-why-in-wythoff/ and blog.zacharyabel.com/2012/04/wythoffs-game-red-or-blue/ regarding Wythoff's Game. Right now my best approximation is using scatter_plot and gridlines='minor', but it's not quite what I'm looking for. Does anyone know if it's possible in Sage? 2015-01-23 21:57:55 +0100 received badge ● Notable Question (source) 2015-01-23 21:57:55 +0100 received badge ● Popular Question (source) 2012-04-19 22:05:18 +0100 marked best answer Notebook hangs when run from command line I always start up my sage server by using the -c option to have Sage run a command. Here is my startup script: #!/bin/sh ~/sage/sage -c "notebook(interface='localhost', directory='./sage_notebook.sagenb',port=8000, accounts=True, timeout=3600, server_pool=['sage%d@localhost'%i for i in range(10)], ulimit='-u 100 -t 36000 -v 500000', open_viewer=False)"  See step 8 of http://wiki.sagemath.org/SageServer 2012-04-19 22:05:17 +0100 received badge ● Scholar (source) 2012-04-18 20:25:48 +0100 received badge ● Supporter (source) 2012-04-18 20:25:36 +0100 received badge ● Editor (source) 2012-04-18 15:46:48 +0100 answered a question Notebook hangs when run from command line Thanks so much. That seems to work at first, it doesn't hang, but then I get no output from evaluating a cell. It just jumps to the next line with nothing to show for it. I've tried it in Chrome and Firefox. Could it be my parameters? I'm just trying to open it up to me as a user. edit: Playing with the settings I think I've sorted it out. I'm running /Applications/sage/sage -c "notebook(interface='',secure=True,accounts=False)" and it seems to work well. I'm not sure what caused the issue above, but it was clearly one of the settings. I appreciate the help. 2012-04-18 11:46:46 +0100 asked a question Notebook hangs when run from command line I'm getting comfortable with Sage with my own work, and have tasked my students with registering at sagenb.org and working through some problems. I would like to run a Sage server from my desktop machine at home to access when I'm out, instead of trying to synchronize my worksheets. I'm running OS X 10.7 on a Mac Mini, and have properly forwarded the appropriate port. When I run sage in the Terminal, then the command notebook(interface='', server_pool=['sage1@localhost'], accounts=False, secure=True) things seem to work smoothly. I can access the login screen from a remote machine, run worksheets, and evaluate commands. However, when I try to run sage from the command line with ...sage --notebook interface='' server_pool=['sage1@localhost'] accounts=False secure=True I'm still able to access the login screen from a remote machine and run worksheets, but when I try to evaluate something it hangs. The command I'm using is something I put together from pieces I found on the Sage wiki, but I admit even after reading a number of tutorials over and over I'm still not sure what all the parameters mean. I'd like to run this server at boot, so I'm calling it via a bash script. If there's another way to do things I'm all ears. Does anyone have any suggestions?