# Questions tagged [sage]

348 questions

1

votes

2

answer

277

Views

### How to run SageTeX on Windows?

I want to use Sage in LaTeX, how do I do that running Sagemath 8.0 on Windows? I use the MikTeX distribution.
I followed the instructions from Sagemath but they are for linux. I included the sagetex package, which generates a myfile.sage file but when I start the Sage shell and run sage myfile.sage...

1

votes

1

answer

47

Views

### How to compose two partial orders in Sage?

Suppose I have two finite posets (e.g. constructed with sage.combinat.posets.posets.FinitePoset).
I want to calculate the binary relation which is the composition of the order relations of these posets.
How to do this in Sage?
(I am a Sage novice.)

1

votes

0

answer

41

Views

### How to scatter a smaller array in to a larger array using a list as index?

I need help to obtain the following type of result in Python (that I was used to in Matlab):
M = numpy.zeros((5,5))
m = numpy.array([[1,2,3],[4,5,6],[7,8,9]])
indx = [0, 2, 3]
# in Matlab: M(indx,indx) = M(indx,indx) + m
so that the output is:
[[ 1. 0. 2. 3. 0.]
[ 0. 0. 0. 0. 0.]
[ 4. 0. 5...

1

votes

0

answer

45

Views

### Defining constraints in Lagrangian (SageMath)

I am trying to maximize the function P, with constraints of x >= 75,000 and y >= 200,000. However, I do not think I am defining them correctly. I attempt to define them as arguments of the solve() function.
var('x','y', 'lam')
P = (0.05*x*(1-(x/150000) - 0.0000008*x*y)) + (0.08*y*(1-(y/200000) -
0....

1

votes

0

answer

35

Views

### How to avoid recompiling Cython files on every execution of a script?

I am running a script in Sage repeatedly and want to avoid the overhead of Cython translation on every invocation. What can I do?

1

votes

0

answer

72

Views

### Django, Markdown and SageCell

I am building a blog with Django. This blog is made up by posts whose content would benefit a lot from using Markdown syntax. But some of this posts also include SageMath cells, which process some Python-Sage Code enclosed in some special divs, as in this tutorial. Now every Markdown engine parses t...

1

votes

0

answer

48

Views

### Elliptic Curve Points in sagemath

I want to implement Pollard_Lambda for finding discrete log of an elliptic curve point in sage.
for dividing elliptic points in three sections I need to compare y coordinates of elliptic point.So is there any function in sage witch can separate our x and y coordinates of elliptic point pleaze tell...

1

votes

0

answer

68

Views

### How to acheive 3D plot this in python or SageMath with contours?

I want to plot a quadratic form with its level sets in SageMath. How to do that?
I want the following diagram.
The following is my try.
But it did not give me the same figure as in the above pic.
The output was separate files.
[First one]
[]2
and the second one is the [contour plot][]3, rest all...

1

votes

0

answer

65

Views

### Using CAS (Sage,Maxima,Octave?) with PHP (Linux), Converting LaTex to Sage / Octave script

Hi for my student project I need to send a math expression (translated in TeX,LaTeX) from php server to some CAS and recieve its result back , translate it into LaTex (and e.g. compare it with my answer). I'm considering to use Sage(via console somehow) or Octave(octave-daemon?).
I am new in web de...

1

votes

0

answer

88

Views

### Cannot get SageMath to solve simultaneous equations

I will provide some context on the problem if necessary. I've thought about this problem, but cannot seem to see why SageMath wont solve it. I am asking this question here as I think it has more a place here than the mathematics StackExchange.
When I run this code, it just returns/shows the equation...

1

votes

1

answer

48

Views

### Installed Sage Package but coundn't use

I want to use the spkg 'coxeter3', and I installed it successfully because it shows up under 'installed_packages()'.
code and spkg
Here's my code:
def MuL(C):
W = CoxeterGroup(C, implementation='coxeter3')
List=[]
for u in W:
U = (W(v) for v in W.bruhat_interval(u, W.long_element()))
next(U)
for v i...

1

votes

0

answer

16

Views

### In a bipartite graph finding the edges that are present in all maximum matchings

Has anyone written up the algorithm in Sage given by Tamir Tassa in, ``Finding all maximally-matchable edges in a bipartite graph''?

1

votes

0

answer

230

Views

### sagemath kernel death in jupyter notebbok

I followed the instructions in
How to install sagemath kernel in Jupyter
but as soon as a I create a new sagemath worksheet in the jupyter notebook, the worksheet opens, and, after a few seconds, I get a message saying the sage kernel died. This, without having the time to ask for the least computa...

1

votes

0

answer

126

Views

### Using sagemath pollard rho function

i'm trying to use sagemath to solve a cryptographic problem. All i have right now is this code:
︠# coding: utf-8
# A big prime:
p = power(2,256) - power(2,224) + power(2,192) + power(2,96) - 1
F = GF(p)
#Elliptic curve in normal form: y^2 = x^3 * ax * b
a = -3
b = 0x5ac635d8aa3a93e7b3ebbd5576...

1

votes

1

answer

48

Views

### Comparing two numbers in sage

i would like to know why by comparing two real numbers (e.g. bool(r1 == r2)) in sage cas online it returns wrong boolean values.
E.g.§1:
(x,y,z)=var('x,y,z');
x=2
r1= (sin(x)).n()
r2= (sin(x)).n(digits=3)
print r1, type(r1)
print r2, type(r2)
bool(r1==r2)
0.909297426825682 ==
0.909
True
But E.g....

1

votes

0

answer

125

Views

### Cannot cast the underlying exported value of type

I have a project that is attempting to connect to Sage 200. However it is complaining that the type initialisation has failed now usually that is to do with assembly not being in the cache however this time it is. I have restarted,
The error that I am receiving I also ran the gac utility to ensure t...

1

votes

0

answer

22

Views

### Extracting A Single Solution From Sage

I'm working on a project in Sage that requires Sage to solve an underdetermined system. I understand that the variables such as 'r956' are free variables once I run the solve command. I have given Sage some assumptions on my symbolic variables and wish to know if there's a way to ask Sage to gener...

1

votes

0

answer

19

Views

### Indescript LetsEncript Certificate Generating Error

I have built a site with Roots' Trellis. But I forgot to enable SSL. So I changed the setting in group_vars/production/wordpress_sites.yml and re-provisioned but I'm getting this error.
TASK [letsencrypt : Generate the certificates] *****************************************************************
S...

1

votes

0

answer

132

Views

### Compiling with sage occurs “SystemError: new style getargs format but argument is not a tuple”

When the following codes are compiling with python everything is good, there is no error, but when I compile with sage it occurs the error : 'SystemError: new style getargs format but argument is not a tuple'
Here is my code
from PIL import Image
file=Image.open('/home/mks/Desktop/Shamir_VSIS/si.jp...

1

votes

0

answer

18

Views

### why I get huge number in converting V-reresentation to H-representation in sage?

I have a set of vertices and I want to find a H-representation of them. I used sage to do that but I got weird number in the inequalities!
here is my code:
vert2 = [[1,2,3,4,2,3,6,0,0,7,6,8,0,1,2,3,4,5,6,7,4,3,2,3,4,1,0,3,0,1],[1,1,2,3,4,2,3,6,0,0,7,6,8,0,1,2,3,4,5,6,7,4,3,2,3,4,1,0,3,0],[0,1,1,2,3...

1

votes

0

answer

33

Views

### How to get the coefficient vector of a PolyBoRi polynomial in Sage

I am trying to use SageMath for something that involves a lot of manipulation of boolean polynomials.
Here are some examples of what a coefficient vector is:
x0*x1*x2 + 1 has coefficient vector 10000001
x1 + x0 + 1 has coefficient vector 11100000
x1 + x0 has coefficient vector 01100000
(x0 is the...

1

votes

0

answer

47

Views

### Plotting a solution of a differential equation with Sagemath

I need to solve a differential equation. The solution will depend on t and q, and I need to define that q piecewise depending on t.
var('k,Tmax,Tmin,w,T0,q'); T=function('T')(t); Te=function('Te')(t);
assume(k>0); assume(Tmax>Tmin); Te(t)=(Tmax+Tmin)/2+(Tmax-Tmin)/2*sin(w*t);
Now this is the differe...

1

votes

1

answer

89

Views

### How to load file in SageMath 7.1

I am new to Sage & I wish to load a .sage file from a Sage Notebook worksheet.
I am on OSX 10.9.5.
If I evaluate
load (example.sage)
I get
IOError: did not find file 'example.sage' to load or attach
The example file is on my Desktop.
Do I need to explicitly state the full file path?
If so how?
Thx.

1

votes

1

answer

24

Views

### Trying to use CoCalc (sage) to plot solutions to a function requiring a modulus

I have the following code and error message. Something I am doing seems to be messing up the % function in the hb function. I'm not really sure what or how to fix it. Any ideas?
def h(n):
if (n % 4 >= 0) and (n % 4 < 1):
k = 1
else:
k = 0
return k
def hb(n):
if (((n/4) % 2) >= 0) and (((n/4) % 2...

1

votes

1

answer

108

Views

### gulp watch issue in sage 8.5.1

I'm currently working on a site that is using Sage 8.5.1.
I've done all of the following:
Install gulp and Bower globally with npm install -g gulp bower
Navigate to the theme directory and run npm install
Run bower install
But when I run gulp watch, I get the following issue:
gulp watch[8188]: ../sr...

1

votes

0

answer

20

Views

### Loading file from USB into SageMath

I can load a file from my desktop into my SageMath IPython window. But can't determine the correct path for a USB drive. Is there a specific path line needed for USB's?
SageMath version 8.6 and Windows 10 operating system.

1

votes

1

answer

56

Views

### Sagemath simplification

I am interested in expressions like
w=2*cos(3/7*pi) - 2*cos(2/7*pi) + 2*cos(1/7*pi) - 1
w is exactly 0, as is easily verified by expressing each cosine as sum of powers of a 7'th root of -1; Sage can verify this approximately by evaluating w as real.
I have tried to apply all simplify methods to w,...

1

votes

0

answer

19

Views

### Using CPLEX via SAGE when it's package installed

I would like to use CPLEX via SAGE.
There is this tutorial here.
However, my Sage is installed via a package (debian). Therefore, in my SAGE_ROOT (/usr/share/sagemath), I don't have local directory.
Is there another directory then?

1

votes

0

answer

26

Views

### Creating a unit squircle with sage

My goal is to create an animated graph, using Sage, that produces something similar to sine and cosine but for a squircle instead of a circle. I have spent a lot of time trying to create something but my limited experience is proving to be a great hindrance. I am doing this purely to develop my know...

1

votes

0

answer

13

Views

### memoryerror using nauty_geng in Sage

I am trying to get Sage to generate all graphs with 11 vertices, 30 edges, and clique number 4. I typed in the following:
g11=[g for g in graphs.nauty_geng('11 30') if g.clique_number()==4]
After a while I see the following message:
MemoryError Traceback (most recent ca...

1

votes

1

answer

21

Views

### Unable to Post an invoice to Sage One via API 422 Error

I am able to authenticate against the SAGE ONE API and also able to retrieve data from the API however I am now trying to post a simple invoice however keep getting a 422 error. Is there something obvious I am missing?
I have double checked the JSON structure and the values i am providing and are a...

1

votes

1

answer

259

Views

### sage math software: using cli interface, is && operator(i.e. “background and control”?) functionality supported?

I'm new to sage math software. i've been looking though sage documentation to find if the sage cli supports any way to run multiple commands one after another, i.e. behave like bash when using the && operator. for example, on linux:
$ cp file1 file2 && rm file1
at the command line will copy file1...

1

votes

1

answer

756

Views

### Sage notebook not opening

I installed the sagemath software on an ubuntu machine and nothing executes. I type
sage: notebook()
NameError: name 'notebook' is not defined
sage: 2+3
---------------------------------------------------------------------------
NameError Traceback (most recent call l...

1

votes

1

answer

902

Views

### Retrieving All Payments From Sage Line 50 Database

I'm trying to retrieve a list of all payments received/entered into a Sage Line 50 database. The company I work for are members of the Sage developer program, so I have access to the SDK, help files and the like but I have been unable to find any specific information regarding payments.
Some of the...

1

votes

2

answer

1.4k

Views

### input text in python using sage math

Below is the code i tried using python
>>> import string
>>> def main():
print 'hey'
print
key = input ('key?')
message = raw_input('Enter the message: ')
codedMessage = ''
for ch in message:
codedMessage = codedMessage + chr(ord(ch) + key)
print 'the coded is: ', codedMessage
>>> main()
hey
key?-1...

1

votes

1

answer

374

Views

### How do I find the Subsets of given Set in Sage?

I have code that looks like this:
def Z(m,n):
return CartesianProduct(IntegerRange(m),IntegerRange(n))
for v in Subsets(Z(2,2)):
print v
However, when I try to run it, I get the following error:
Traceback (most recent call last):
File 'x.py', line 13, in
for v in Subsets(Z(_sage_const_2 ,_sage_cons...

1

votes

1

answer

304

Views

### Error on running Sage

I am trying to use Sage but when I type ./sage I get a lot of errors like these, with strange characters:
----------------------------------------------------------------------
| Sage Version 4.8, Release Date: 2012-01-20 |
| Type notebook() for the GUI, and license() for inf...

1

votes

1

answer

1.3k

Views

### Importing common files to Sage

I'd like to import some utility files in a separate directory to my project, e.g. so that I can do import util from the Sage prompt. Adding that directory to the SAGE_PATH variable allows me to do so, however doing so will cause problem when I want to read the document of any function in SAGE. F...

1

votes

1

answer

131

Views

### Assignment of Sage Matrix to variable in R

From sage (v5.4.1) in a terminal session i try to assign a value in R:
sage: r.assign(''M'',5)
[1] 5
That works. I could also do
sage: b=4
sage: r.assign(''M'',b)
[1] 4
But I would like to assign M a matrix from sage.
sage: r.assign('M',sage_M)
Error: object 'sage6' not found
The type of error depen...

1

votes

1

answer

220

Views

### Django error: settings.Databases improperly configured

I'm completely new to Django and have no idea what that means. I'm really just trying to get codenode setup for sage. I've tried following the installation guide at codenode's website, but when I load localhost:8000, I get the following message and a whole bunch of debug text:
settings.DATABASES is...