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.Fri, 08 Oct 2021 10:26:12 +0200- SageMath crashes when doing simple function arithmeticshttps://ask.sagemath.org/question/59282/sagemath-crashes-when-doing-simple-function-arithmetics/Hello,
I'm trying to run the following code which computes a simple rational function.
d = 4
p = (d+2)/(d-2)
W(r) = (1+r^2/(d*(d-2)))^(-(d-2)/2)
print(p*W(r)^(p-1))
This code works fine in "sagecell dot sagemath dot org" (it takes only a few seconds). But if I run it on my SageMath terminal (which I've installed yesterday, so it's up-to-date), I get : ' /usr/share/sagemath/bin/sage-python : ligne 2 : 3988 Processus arrĂȘtĂ© sage -python "$@" '
The code works fine in my SageMath terminal if I replace d by d = 3, d = 5, d = 6 or even d = 100.
I've identified that the problem is due to p = (d+2)/(d-2). When d = 4, if I replace p = (d+2)/(d-2) by p = 3 or p = RR((d+2)/(d-2)), it works.
But I don't understand why it does not work otherwise ?
EDIT :
This code was run on Ubuntu 20.04.3 (from Windows 10 using VirtualBox). SageMath 9.0 was installed using the command "sudo apt-get install sagemath". I didn't know this would not install the latest version. I'll try to update SageMath first and then we'll see.shura11Fri, 08 Oct 2021 10:26:12 +0200https://ask.sagemath.org/question/59282/
- SageMathCell Not Workinghttps://ask.sagemath.org/question/58703/sagemathcell-not-working/ I use SageMathCell on a daily basis and have never had any problems. However, today for the past few hours it hasn't been working, in the sense that it is not producing any output. The wheels are spinning but nothing is happening.voodooguruFri, 27 Aug 2021 21:26:18 +0200https://ask.sagemath.org/question/58703/
- From Jupyter to one cell serverhttps://ask.sagemath.org/question/51705/from-jupyter-to-one-cell-server/ Hi there,
A long time ago I learned how to use the one-cell server. At that moment I was creating simple .html files for my students, so they could execute some code and learn a bit of Sage.
Nowadays this seems inefficient, instead of writing .html file it seems reasonable to write everything in a jupyter notebook. As I want to embed the files into a Moodle page, and want the cells to be executable therein, or by downloading an html file, without having Sage installed in the local machine, I thought I could try to turn each code cell of the jupyter notebook into a cell pointing to the one-cell server. Is it possible to do this efficiently? Can I somehow achieve my goal with Cocalc?
Thanks!JCTue, 02 Jun 2020 16:49:21 +0200https://ask.sagemath.org/question/51705/
- Missing 1 required positional argumenthttps://ask.sagemath.org/question/49581/missing-1-required-positional-argument/What's wrong with my code? It doesn't work inside Sage Math Cell.
gp.eval("xmat(r,n) = [2*x, -1; 1, 0]*Mod(1,x^r-1)*Mod(1,n);")
gp.eval("smallestr(n)={if(n==1 || n%2==0, return(0));forprime(r = 3, oo,my(u=n%r);if (u==0 && r < n, return(0));if (u!=0
&& u!=1 && u!=r-1, return(r)));}")
gp.eval("myisprime(n)={my(r = smallestr(n));if (r == 0, return(n == 2));my(xp = xmat(r,n)^n*[x,1]~);xp[2] ==
Mod(x*Mod(1,n),x^r-1)^n;}")
def Check(n):
if gp.function_call("myisprime",[n]).sage()==true:
return ("Prime!")
else:
return ("Composite!")
@interact
def _(n=2017,action=selector(['Check'],buttons=True,label='')):
action = eval(action)
print (action())
I am getting the following message: TypeError: Check() missing 1 required positional argument: 'n'
**EDIT**
You can run this code [here.](https://sagecell.sagemath.org/?z=eJxtkVFPgzAUhd_3K-5INtqlWwAfTMQmJns28cE3wgxjZRLhlpRiWJz-di8F50zsS7m99_R8PRybjXrPKub1dWaZEchBQhKtegHrMIZQQJCuHvWBhaLfmXXIpwJ57PHZ8Ufd1llVqdYahlx-lAVDKUM4nwEXkZSBAKNsZ5AFnMeFNo0pa8UMWd0I0FrUJ9ZJXBgelwXQpwxguQQD94B_pK47H7u0h9NOXJcxw2nu85qtPpXtaDiwkdXgew083kunEn5JcSgj6pGgb0hxCWiHq6QXYfrF475JonQYHELpL9FMUe3QgRxUAdtXlb-R1d0MaJEd0RUd5rbU-JITyhWmJxJM-abNjopxKa3p1Cgb1kgHzHsaRud0_XCqqva_ma2uG92W1s09lGiVyXLrgF7oD0VBeCsyxyBbVancasMS37H6qdh31mps5TMBiCrbq0r6Pp-eMMooFpfxWHFwLXoEWpjOGOff8YW1iw==&lang=sage&interacts=eJyLjgUAARUAuQ==)PedjaFri, 17 Jan 2020 15:07:01 +0100https://ask.sagemath.org/question/49581/
- Check if code is running in SageMath Cell or Jupyter notebookhttps://ask.sagemath.org/question/48881/check-if-code-is-running-in-sagemath-cell-or-jupyter-notebook/ I am preparing interacts to be run either in a Jupyter notebook or in SageMath Cell. I would like to write code valid for both environments, taking into account the differences between them. For example, I have not seen a common way to change the default text in auto update buttons. The following code would work in both environments if I would know how to automatically set up the `running_in_Jupyter` boolean:
if running_in_Jupyter:
auto = False
else:
auto = UpdateButton(text="Press to update")
@interact
def test(n=slider(0,20,1), auto_update=auto):
print n
if running_in_Jupyter:
test.widget.children[-2].description="Press to update"
So, is there a simple test I could implement to detect where the code is running?
JuanjoMon, 25 Nov 2019 13:48:00 +0100https://ask.sagemath.org/question/48881/
- Button to copy SageMath cell to clipboardhttps://ask.sagemath.org/question/47700/button-to-copy-sagemath-cell-to-clipboard/I will be using a link to a simple SageMathCell html page during Canvas quizzes in an online Discrete Math course. I would like to provide an additional "copy" button on the SageCell page that would allow the student to copy both their code and evaluated output into a textbox in a different browser window.
I realize it is now possible to separately cut and past the code and the output into a different textbox, but I would like to keep it as simple as possible. Any suggestions for the additional html that would add the button are appreciated.
To be more specific, I realize I could create an html button using:
<button onclick="myCopySageInOut()">Copy Sage Cell</button>
and I would need JavaScript code for the myCopySageInOut() function that would copy the input box text, append the output text and place in the clipboard. This is when I could use an example of the JavaScript code.holistoneSat, 31 Aug 2019 20:37:06 +0200https://ask.sagemath.org/question/47700/
- How to show more results in sagemathcell?https://ask.sagemath.org/question/46676/how-to-show-more-results-in-sagemathcell/If I put following comand in http://sagemath.askplanck.cn/
1+2
10+20
100+200
If Evaluate above command, I can only get last result: 300. What I wish is too get 3 results one by one in **my own sagemath server** , How can I do in configure file.
In https://cocalc.com/, if I put above comand, it shows 3 results. This is nice,and is what I want. Is it possible in such like sagmathcell?
PS. I don't want to put command as following (which can show 3 results):
print 1+2
print 10+20
print 100+200
Thank you very much for your suggestion.
JohnJohn BaoSun, 26 May 2019 14:47:46 +0200https://ask.sagemath.org/question/46676/
- How to run Cython examples in SageMathCellhttps://ask.sagemath.org/question/43786/how-to-run-cython-examples-in-sagemathcell/Hi, this is not a math question, this is a programming question.
I'm trying to run the first example at doc.sagemath.org/html/en/thematic_tutorials/cython_interface by using SageMathCell service ([link](http://doc.sagemath.org/html/en/thematic_tutorials/cython_interface.html)).
For this, I've created a zip folder that I've stored in the cloud (Google Drive).
When I run the following python script in SageMathCell (I wrote it to test Cython capabilities in SageMath remote server), it seems good, but I can't see the output, that would be "Hello World".
This python script, after execution, ends with "Compiling ./Call_C_code/hello_sage.pyx..." without anyone else output.
Can you help me?
Thanks,
import os
import tempfile
import sys
from distutils.dir_util import copy_tree
directory_name = tempfile.mkdtemp()
print(directory_name)
sys.path.append(directory_name)
#https://drive.google.com/open?id=129vvaCzB0M5iuPxdSdNWRG5A2gG0DwEu
import urllib
url = "https://drive.google.com/uc?export=download&id=129vvaCzB0M5iuPxdSdNWRG5A2gG0DwEu"
filename = "/Call_C_code.zip"
urllib.urlretrieve(url, directory_name + filename)
# opening the zip file in READ mode
from zipfile import ZipFile
os.chdir(directory_name)
file_name = "Call_C_code.zip"
with ZipFile(file_name, 'r') as zip:
# extracting all the files
print('Extracting all the files now...')
zip.extractall()
print('Done!')
print(sys.path)
print(os.getcwd())
for root, dirs, files in os.walk("."):
for filename in files:
print(filename)
#############
%runfile Call_C_code/hello_sage.pyx
my_bridge_function()MatteoThu, 27 Sep 2018 17:20:24 +0200https://ask.sagemath.org/question/43786/
- sagemath cell into confluencehttps://ask.sagemath.org/question/41604/sagemath-cell-into-confluence/It would be awesome if it would be possible to embeed a sage cell in to confluence. Here is mine example running wolframalpha.
https://meintutor.atlassian.net/wiki/spaces/MAT/pages/327681
The code to embeed is :
<script type="text/javascript" id="WolframAlphaScript91c3408a1da9c9dc9435c81cf2f8ad0d" src="//www.wolframalpha.com/widget/widget.jsp?id=91c3408a1da9c9dc9435c81cf2f8ad0d"></script>
Is it possbile to embeed this server?
http://sagecell.sagemath.org/thethaSat, 17 Mar 2018 18:34:20 +0100https://ask.sagemath.org/question/41604/
- Is it possible to send a saved list of data to the sagecell-serverhttps://ask.sagemath.org/question/41454/is-it-possible-to-send-a-saved-list-of-data-to-the-sagecell-server/ Is it possible to send a precomputed list L that one has computed and saved with
> save(L,'filename')
to the server at
https://sagecell.sagemath.org/
and then do a calculation with L on that server? If so, how?Peter HeinigFri, 09 Mar 2018 16:50:57 +0100https://ask.sagemath.org/question/41454/
- @interact : Fix the default renderinghttps://ask.sagemath.org/question/40678/interact-fix-the-default-rendering/I have created the [following interact](https://sagecell.sagemath.org/?z=eJyNkTFrwzAQhfdA_oMINj5h0TqFLA2Cbt6yeLQdoySXRFSRhSRTu6H_vWqcNqVkqAYh3n3v7h16kdqjFVs_nexwTxoQXGrT-WbT9hAU0SnP549P654psUHFZwJ6OqNMZ_dAylb35AWlz9MJIQX3nVEIZUb2rSWSSE2s0AeELDSkNR2hIr1iAn7UnJs2ZHVQ6oyNOtu2qrU82Qn7erCIOmEjI9-RL7KL7c-Y4F2NUcIcI6yXqBTyopR1KkCmc3qt3TLcsPpazHmefocJFvaL-E8kd2zfIL88jUXvh8bYgMDRnxQkUVTtpDNKDM4PCivXnZqz5rH7WJ_DFTan1ZJXy9hFURJfFgo_47GHolzVDxro15lOPgG44JSK&lang=sage).
It plots the partial sums of a series up to N, et prints out the last one.
The default rendering yields a DeprecationWarning and does not show the partial sum value.
When you update the data, the rendering is fine.
How can I fix this?
BostonThu, 18 Jan 2018 16:45:46 +0100https://ask.sagemath.org/question/40678/
- Prevent SageMathCell from clearing output windowhttps://ask.sagemath.org/question/33024/prevent-sagemathcell-from-clearing-output-window/ When an interaction element, for example a numerical slider, in a SageMathCell is changed, the output window is immediately cleared while the server processes the new request. Is there a way to prevent the currently displayed output from disappearing until the updated output appears?
I'd like to be able to see the changes in the output due to the interaction as clearly as possible, and this is hard to see if the previous output is gone immediately. Mathematica's plugin doesn't clear output until the new one is ready. Can that be replicated in SageMathCell?
Thanks.
paulmassonWed, 06 Apr 2016 23:19:40 +0200https://ask.sagemath.org/question/33024/
- matrix over TropicalSemiringhttps://ask.sagemath.org/question/32595/matrix-over-tropicalsemiring/I try to build a matrix with entries from TropicalSemiring, but I get an error. This was done on SageMathCell:
T=TropicalSemiring(RR)
matrix([[T(1),T(2)],[T(3),T(4)]])
and yields:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-415e7359a236> in <module>()
1 T=TropicalSemiring(RR)
----> 2 matrix([[T(Integer(1)),T(Integer(2))],[T(Integer(3)),T(Integer(4))]])
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in _matrix_constructor(*args, **kwds)
647
648 if nrows > 0 and ncols > 0 and ring is None:
--> 649 entries, ring = prepare(entries)
650
651 elif isinstance(args[0], dict):
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in prepare(w)
805 ring = rings.CDF
806 elif not is_Ring(ring):
--> 807 raise TypeError("unable to find a common ring for all elements")
808 return entries, ring
809
TypeError: unable to find a common ring for all elements
If instead I use this syntax:
T=TropicalSemiring(RR)
matrix(T,[[1,2],[3,4]])
I get a different error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-02718e38d49f> in <module>()
1 T=TropicalSemiring(RR)
----> 2 matrix(T,[[Integer(1),Integer(2)],[Integer(3),Integer(4)]])
/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in _matrix_constructor(*args, **kwds)
713 raise ValueError("Invalid matrix constructor. Type matrix? for help")
714 else:
--> 715 raise ValueError("Invalid matrix constructor. Type matrix? for help")
716
717 if nrows is None:
ValueError: Invalid matrix constructor. Type matrix? for help
How can I do it correctly?wrognFri, 19 Feb 2016 12:45:59 +0100https://ask.sagemath.org/question/32595/
- SageMathCell timeout issuehttps://ask.sagemath.org/question/32475/sagemathcell-timeout-issue/My website currently has live math using embedded Mathematica CDFs. Since Wolfram has told me that they are dropping support for the browser plugin, I would like to convert all of my live math to SageMathCell. In the first page I'm testing, I've found that evaluating the eigenvalues of a numerical 30x30 symmetric real matrix over RDF does not finish and the cell in which the evaluation runs becomes grayed out while the working indicator continues to spin endlessly.
Is this a limitation of your server or my local machine? Is there some way to keep the cell alive until the evaluation completes? Thanks.paulmassonSat, 06 Feb 2016 22:33:48 +0100https://ask.sagemath.org/question/32475/