sage

python/sage: how to get the last expression?

python/sage: how to get the last expression? Question: If I do in Jupiter (in both python and sage) something like: a = 42 b = 43 a + b it will, somehow, manage to understand that this process returns the value a + b, i.e. 85 here: Similarly, if I just do: a = 42 …

Total answers: 2

Import data from a txt file to sagemath and plot it

Import data from a txt file to sagemath and plot it Question: I have data in a ‘txt’ file of the form 2 ; 4 3 ; -8 5 ; 4 next prime … So I am trying to import this data as a sequence (a_p)_{p, prime} to sagemath in order to plot it. So …

Total answers: 1

Converting Maple to Sage

Converting Maple to Sage Question: I have some Maple code below that I’m trying to convert to Sage (which is some kind of Python) code. This is the Maple code restart: m:=15: a:=array(1..m): eqn:=array(1..m): expr:=sum(a[‘i’]*u^(‘i’-1),’i’=1..m)- product((1-u^’i’)^(-a[‘i’]),’i’=1..m): for i from 1 to m do eqn[i]:=coeff(series(expr,u=0,m+2),u,i-1); od: sols:=solve({seq(eqn[i],i=1..m)},{seq(a[i],i=1..m)}): assign(sols): print(a); This is the output for this code: …

Total answers: 2

How to stop sage graph generating iterator after N iterations?

How to stop sage graph generating iterator after N iterations? Question: I want to create N planar graphs using sagemath’s graph.planar_graphs iterator. The problem is that this function return all possible planar graphs given a certain number of vertices. What I want to do is something like: while len(gen) < N: gen = list(graphs.planar_graphs(50)) So …

Total answers: 1

Using SageMath as a python library

Using SageMath as a python library Question: Is it possible to import the SageMath functions inside a python session? What I wish to do, from a user perspective is something like this: >>> import sage >>> sage.kronecker_symbol(3,5) # …or any other sage root functions instead of accessing kronecker_symbol(3,5) from a sagemath session. If possible, it …

Total answers: 3

Cannot turn numpy array into a graph in SageMath

Cannot turn numpy array into a graph in SageMath Question: After downloading testnb.sws following the instructions on the website https://sourceforge.net/p/networksym/code/ci/master/tree/ I tried to run it in the legacy “Sage Notebook” (not the Jupyter notebook), as follows: open the Sage Notebook click “Upload” click “Browse” select testnb.sws click “Upload worksheet” click “Evaluate” Evaluating the code cell …

Total answers: 1

Launch Pycharm from command line (terminal)

Launch Pycharm from command line (terminal) Question: I want to try out PyCharm for sage mathematics development. Normally I run eclipse to do sage development, but now I want to try it with PyCharm. To launch eclipse with sage environment variables, in command line I normally do the following: sage -sh cd /path/to/eclipse ./eclipse The …

Total answers: 21

What is the difference between SymPy and Sage?

What is the difference between SymPy and Sage? Question: What is the difference between SymPy and Sage a.k.a. SageMath? Asked By: Faouzi FJTech || Source Answers: (Full disclosure: I am the lead developer of SymPy) The first thing you should understand is that SymPy and Sage are not quite the same thing. SymPy is a …

Total answers: 1