ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 May 2019 06:36:42 -0500using cplex as a solver in sage - import error undefined symbol: CPXsetlogfilehttp://ask.sagemath.org/question/46606/using-cplex-as-a-solver-in-sage-import-error-undefined-symbol-cpxsetlogfile/Hi,
Ubuntu 18.04; Installed cplex_studio129.linux-x86-64.bin and then Sage 8.7 from source.
I chose source to allow me to "make" Sage again after linking the necessary CPLEX files as described at the very bottom of the page here:
doc.sagemath.org/html/en/thematic_tutorials/linear_programming
i.e. from
/home/klara/sage-8.7/local/lib
`ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/lib/x86-64_linux/static_pic/libcplex.a .`
and from:
/home/klara/sage-8.7/local/include
`ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/include/ilcplex/cplex.h .`
and finally, also from:
/home/klara/sage-8.7/local/include
`ln -s /opt/ibm/ILOG/CPLEX_Studio129/cplex/include/ilcplex/cpxconst.h .`
But now I get the following import error when running:
sage: p = MixedIntegerLinearProgram(solver='CPLEX')
ImportError: /home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/cplex_backend.so: undefined symbol: CPXsetlogfile
(By the way, after installing Sage but before linking and remaking I got the more basic import error:
`ImportError: No module named cplex_backend`)
Any hints as what to look into would be appreciated.
Thanks.
----------
Here is the Full Output of the error:
sage: p = MixedIntegerLinearProgram(solver='CPLEX')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d320ed52392f> in <module>()
----> 1 p = MixedIntegerLinearProgram(solver='CPLEX')
/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3690)()
352 True
353 """
--> 354 return self.get_object()(*args, **kwds)
355
356 def __repr__(self):
/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.__init__ (build/cythonized/sage/numerical/mip.c:3931)()
449 self._first_variable_names = list(names)
450 from sage.numerical.backends.generic_backend import get_solver
--> 451 self._backend = get_solver(solver=solver,
452 constraint_generation=constraint_generation,
453 base_ring=base_ring)
/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/generic_backend.pyx in sage.numerical.backends.generic_backend.get_solver (build/cythonized/sage/numerical/backends/generic_backend.c:20060)()
1647 raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'Gurobi', 'PPL', 'InteractiveLP', or None.")
1648
-> 1649 cpdef GenericBackend get_solver(constraint_generation = False, solver = None, base_ring = None):
1650 """
1651 Return a solver according to the given preferences
/home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/generic_backend.pyx in sage.numerical.backends.generic_backend.get_solver (build/cythonized/sage/numerical/backends/generic_backend.c:19611)()
1794
1795 elif solver == "Cplex":
-> 1796 from sage.numerical.backends.cplex_backend import CPLEXBackend
1797 return CPLEXBackend()
1798
ImportError: /home/klara/sage-8.7/local/lib/python2.7/site-packages/sage/numerical/backends/cplex_backend.so: undefined symbol: CPXsetlogfilebucks65Tue, 21 May 2019 06:36:42 -0500http://ask.sagemath.org/question/46606/Is there any way to plot3d latex package on sagemath?http://ask.sagemath.org/question/46550/is-there-any-way-to-plot3d-latex-package-on-sagemath/I want to draw a triangle on hyperboloid and put the name of angles and vertices but for example when i want use alpha or beta it doesn't show up?
NB i use sagemath.
Here is an example of angles drawn on a surface, to illustrate what I want to achieve:
- [https://commons.wikimedia.org/wiki/File:Spherical-triangle.png](https://commons.wikimedia.org/wiki/File:Spherical-triangle.png)Taoufik ahanchaouThu, 16 May 2019 23:46:06 -0500http://ask.sagemath.org/question/46550/Anyone successfully install rdkit into sagmath?http://ask.sagemath.org/question/44617/anyone-successfully-install-rdkit-into-sagmath/ Rdkit is conda-installed and when you use the official installation instructions, the rdkit goes into the miniconda python library rather than the sagemath python.
I have been able to get them together by installing both sage and rdkit using conda, except the conda sage is 8.3, not 8.4.
JoalHeagneySun, 09 Dec 2018 02:06:30 -0600http://ask.sagemath.org/question/44617/How to realize the composition of rational function mappings with Sagemath?http://ask.sagemath.org/question/44063/how-to-realize-the-composition-of-rational-function-mappings-with-sagemath/If I have two rational function mappings :
f(x,y): (x,y )------>( x^2+15x-2 / x+15, x^2y+xy+y / x^2+30x-1 );
g(x,y): (x,y )------>( x^2+20x-18 / x+20, x^2y+xy+32y / x^2-31x+14 );
how to compute the f(g(x,y)) with sagemath?xiwang0213Wed, 24 Oct 2018 22:03:33 -0500http://ask.sagemath.org/question/44063/Sagemath does not open anymorehttp://ask.sagemath.org/question/43674/sagemath-does-not-open-anymore/ I was trying to install `sagemath-jupyter` on my Arch Linux (which turned out to be a near impossible task) and deleted a bunch of packages from pip2. Now I can't even open sagemath, even after re-installing sagemath from Pacman:
Traceback (most recent call last):
File "/usr/bin/sage-ipython", line 12, in <module>
from sage.repl.interpreter import SageTerminalApp
File "/usr/lib/python2.7/site-packages/sage/repl/interpreter.py", line 109, in <module>
from sage.repl.prompts import SagePrompts, InterfacePrompts
File "/usr/lib/python2.7/site-packages/sage/repl/prompts.py", line 16, in <module>
from IPython.terminal.prompts import Prompts
File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
File "/usr/lib/python2.7/site-packages/traitlets/__init__.py", line 1, in <module>
from .traitlets import *
File "/usr/lib/python2.7/site-packages/traitlets/traitlets.py", line 60, in <module>
from .utils.importstring import import_item
File "/usr/lib/python2.7/site-packages/traitlets/utils/importstring.py", line 8, in <module>
from ipython_genutils.py3compat import cast_bytes_py2
ImportError: No module named ipython_genutils.py3compat
Any ideas on how to overcome this? (And preferably also installing `sagemath-jupyter`?
I have installed `ipython_genutils` with pip2 already (version 0.1.0).tomchoFri, 14 Sep 2018 11:54:56 -0500http://ask.sagemath.org/question/43674/Running Sagemath 8.2 natively in Windows, how to change the Jupyter default directory?http://ask.sagemath.org/question/42445/running-sagemath-82-natively-in-windows-how-to-change-the-jupyter-default-directory/ With SageMath 8.2 running natively under Windows 10, the Jupyter dashboard opens by default in the directory `C:\Users\<me>`, so I then have to navigate to the desired directory that contains my Jupyter notebook .ipynb files.
***How can I cause Jupyter to open directly in the desired directory?***
The relevant Windows shortcut has the following Target Property:
`"C:\Program Files\SageMath 8.2\runtime\bin\mintty.exe" -t 'SageMath 8.2 Notebook Server' -i sagemath.ico /bin/bash --login -c '/opt/sagemath-8.2/sage --notebook jupyter'`
Can the `sage --notebook jupyter` portion be adjusted somehow to specify the desired directory?res0001Sat, 26 May 2018 21:59:30 -0500http://ask.sagemath.org/question/42445/Error occurs Compiling with sage “SystemError: new style getargs format but argument is not a tuple”http://ask.sagemath.org/question/43411/error-occurs-compiling-with-sage-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.jpeg')
file2=file.convert("L")
pix = file2.load()
colsize,rowsize=file2.size
for i in range(rowsize):
for j in range(colsize):
if pix[j,i]>250:
pix[j,i]=250
file2.save('/home/mks/Desktop/Shamir_VSIS/si.pgm')
How can I fix this issue?math.mks@yandex.comSat, 18 Aug 2018 01:35:18 -0500http://ask.sagemath.org/question/43411/How do I upgrade sagemath from 7.4 to 8.2http://ask.sagemath.org/question/43160/how-do-i-upgrade-sagemath-from-74-to-82/I'd like to upgrade sagemath directly without installing the software from scratch. May I have to add a specific repository or is there a command to execute it from consolle? thank you.LukakuThu, 26 Jul 2018 07:14:06 -0500http://ask.sagemath.org/question/43160/Is there a way to use sage-boolean-values in Latexhttp://ask.sagemath.org/question/43131/is-there-a-way-to-use-sage-boolean-values-in-latex/Hey there,
im completely new to sage and so far i got along quite well, but i can't figure this one out. I want to create randomized mathproblems and i want latex to decide what to print depending on calculations in sage.
So here is a functional minimal example:
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
a = ZZ.random_element(1,20)
b = ZZ.random_element(1,20)
\end{sagesilent}
$\sage{a}-\sage{b}$
\end{document}
What do i need to do if i want to switch a and b depending on if the result is negative or not?bentheteacherTue, 24 Jul 2018 16:13:31 -0500http://ask.sagemath.org/question/43131/How to show the output of print() in to jupyter notebook?http://ask.sagemath.org/question/43078/how-to-show-the-output-of-print-in-to-jupyter-notebook/ In Sagemath's Jupyter Notebook, The output of print () always is showed into terminal. So for this reason, I can not get output of the functions such as graph_classes.Tree.description(). But in the anacanda's jupyter notebook for python, we can show the output of print() in jupyter notebook. How to solve the problem? Thanks.dannyThu, 19 Jul 2018 07:50:09 -0500http://ask.sagemath.org/question/43078/Missing root when solving equation in sageMathhttp://ask.sagemath.org/question/43052/missing-root-when-solving-equation-in-sagemath/When I solve equation using sageMath, it missed one root.
sage: solve([4/5*(x - 1)^2/x^(1/5) + 2*(x - 1)*x^(4/5)==0] ,x)
[x == (2/7), x == 1]
The equation has 3 roots. It misses x==0.
What is the reason?Sam TanTue, 17 Jul 2018 18:58:17 -0500http://ask.sagemath.org/question/43052/Differences between Python2 Sagemath and Python3 Sagemath?http://ask.sagemath.org/question/42932/differences-between-python2-sagemath-and-python3-sagemath/ With sagemath looking to move away from python2 in 2020 and as a new user of sagemath, I wanted to know what the differences are between Python2 Sagemath and Python3 Sagemath?
At the moment sagemath is not fully compatible with python3 and I have been told to expect problems. I want to know how serious these problems are and how frequent they are. I would then be able to know if using python3 sagemath is worth the trouble.number123Wed, 11 Jul 2018 14:35:20 -0500http://ask.sagemath.org/question/42932/PARI/GP error in wrapping custom-defined PARI functions in Sage using the command gp.set()http://ask.sagemath.org/question/42638/parigp-error-in-wrapping-custom-defined-pari-functions-in-sage-using-the-command-gpset/ I have a library in PARI/GP and since Sage also supports the GP calculator I have been trying to shift my library using gp.set() and gp.get() commands. So far all functions are working but I got a PARI/GP error while implementing this function in Sage using gp.set(). Here is the code of that function:
compareSides(printedgesonscreen=0) =
{
local( edge, edgesCheckList1:list, edgesCheckList2:list, cancelCriterion);
edgesCheckList1 = listcreate(2*numberOfLines);
edgesCheckList2 = listcreate(2*numberOfLines);
for (j = 1, numberOfSpheres,
if( deleteFlag[j] == 0,
if( printedgesonscreen == 1,
print("Cell ",j," lies on the hemisphere with center at ",
divideInNumberField(K,Lambda[j],Mu[j]) );
print(" with radius square ", radiusSquare[j],
" and has the following edges:");
);
for( s = 1, length( pointsOfLine[j]),
edge = setintersect(Set(pointsOfLine[j][s]),
Set(pointsOfSphere[j]:list));
if(length(edge) == 2,
if(printedgesonscreen == 1, print(edge); );
if( setsearch(Set(edgesCheckList1),edge),
if(setsearch(Set(edgesCheckList2),edge),
if (printedgesonscreen == 1,
print("***Error in function compareSides: triple edge in cell diagram");
);
,
listput(edgesCheckList2,edge);
);
, /* else not yet entered in edgesCheckList1 */
listput(edgesCheckList1,edge);
);
);
if(length(edge) > 2,
print("***Error in function compareSides: edge with three corners");
);
);
);
);
if(Set(edgesCheckList1) == Set(edgesCheckList2),
print("All ", length(edgesCheckList1), " = ",
length(edgesCheckList2)," edges appear twice.");
if( length(edgesCheckList1) > 3,
cancelCriterion = 1
,
cancelCriterion = 0
);
, /* else some edges do not appear twice. */
print("Some edges do not appear twice:");
print(setminus(Set(edgesCheckList1),Set(edgesCheckList2)));
);
listkill(edgesCheckList1); listkill(edgesCheckList2);
/* Return */ cancelCriterion
};
I have run this function in the GP calculator of Sage using the gp.console() command and it works fine but I don't understand why it is not working using gp.set(). Here is the implementation I did:
gp.set('compareSides(printedgesonscreen=0)','{ local( edge, edgesCheckList1:list, edgesCheckList2:list, cancelCriterion); edgesCheckList1 = listcreate(2*numberOfLines); edgesCheckList2 = listcreate(2*numberOfLines); for (j = 1, numberOfSpheres, if( deleteFlag[j] == 0, if( printedgesonscreen == 1, print("Cell ",j," lies on the hemisphere with center at ", divideInNumberField(K,Lambda[j],Mu[j]) ); print(" with radius square ", radiusSquare[j], " and has the following edges:"); ); for( s = 1, length( pointsOfLine[j]), edge = setintersect(Set(pointsOfLine[j][s]), Set(pointsOfSphere[j]:list)); if(length(edge) == 2, if(printedgesonscreen == 1, print(edge); ); if( setsearch(Set(edgesCheckList1),edge), if(setsearch(Set(edgesCheckList2),edge), if (printedgesonscreen == 1, print("***Error in function compareSides: triple edge in cell diagram"); ); , listput(edgesCheckList2,edge); ); , /* else not yet entered in edgesCheckList1 */ listput(edgesCheckList1,edge); ); ); if(length(edge) > 2, print("***Error in function compareSides: edge with three corners"); ); ); ); ); if(Set(edgesCheckList1) == Set(edgesCheckList2), print("All ", length(edgesCheckList1), " = ", length(edgesCheckList2)," edges appear twice."); if( length(edgesCheckList1) > 3, cancelCriterion = 1; , cancelCriterion = 0; ); , /* else some edges do not appear twice. */ print("Some edges do not appear twice:"); print(setminus(Set(edgesCheckList1),Set(edgesCheckList2))); ); listkill(edgesCheckList1); listkill(edgesCheckList2); /* Return */ cancelCriterion}')
When I run this in Sage it shows a PARI/GP error and outputs the whole code. I have been trying to find the bug since the last 3 days. Please help me regarding this. Thank you.MathematicianMon, 18 Jun 2018 02:20:09 -0500http://ask.sagemath.org/question/42638/HUGE delay in sage.crypto.sbox.SBox method nonlinearity() introduced in v.8.2http://ask.sagemath.org/question/42492/huge-delay-in-sagecryptosboxsbox-method-nonlinearity-introduced-in-v82/Average time in nonlinearity() in v.8.1. was ****200 ms****
Average time in nonlinearity() in v.8.2 is ****5.1 s****
Here is the code I have used in order to track the issue:
sage: for j in range(10):
....: S = [x for x in range(256)];shuffle(S)
....: S = sage.crypto.sbox.SBox(S)
....: %time S.nonlinearity()
Results from Sage 8.1
CPU times: user 237 ms, sys: 1.87 ms, total: 239 ms
Wall time: 236 ms
94
CPU times: user 208 ms, sys: 12.5 ms, total: 220 ms
Wall time: 220 ms
94
CPU times: user 287 ms, sys: 1.41 ms, total: 288 ms
Wall time: 288 ms
92
....
Results from Sage 8.2
CPU times: user 5.12 s, sys: 30.6 ms, total: 5.15 s
Wall time: 5.16 s
92
CPU times: user 5.04 s, sys: 14.3 ms, total: 5.05 s
Wall time: 5.05 s
96
CPU times: user 5.08 s, sys: 13 ms, total: 5.09 s
Wall time: 5.09 s
94
CPU times: user 5.03 s, sys: 8.56 ms, total: 5.04 s
Wall time: 5.04 s
92
.....sageuser1Mon, 04 Jun 2018 05:23:32 -0500http://ask.sagemath.org/question/42492/how to sage a filehttp://ask.sagemath.org/question/41569/how-to-sage-a-file/I have Windows 10 installed and i can't sage a file example.sage which is in K:\sageexample
Tutorial is extremely bad and full of jargonisms and no examples in it. I don't know what does it mean to sage a file, or to run a file without example being given.
I open sage command prompt and type the following
run ('K:\sageexample\example.sage') but it returns
ERROR:root:File `u'(K:\\sageexample\\example.sagetex.sage).py'` not found.
then i use load ('K:\sageexample\example.sage") it returns nothing at all.
I spent three days trying different combinations of syntax with no result. kate_l196Thu, 15 Mar 2018 12:41:38 -0500http://ask.sagemath.org/question/41569/does as_permutation_group() respect generators?http://ask.sagemath.org/question/40927/does-as_permutation_group-respect-generators/From sage documentation I can construct a group as follows:
sage: m1 = matrix(GF(11), [[1,2],[3,4]])
sage: m2 = matrix(GF(11), [[1,3],[10,0]])
sage: G = MatrixGroup(m1, m2); G
Matrix group over Finite Field of size 11 with 2 generators (
[1 2] [ 1 3]
[3 4], [10 0]
)
Now I use the following code:
sage: G_p=G.as_permutation_group(); G_p
Permutation Group with generators [(1,2,3,4,5,6,7,8,9,10,11)(12,13,15,14,16)(17,18), (1,3,5,7,9,11,2,4,6,8,10)(12,14,13,16,15)(17,18)]
In this case it is true that the generators of G are in correspondence with the generators of G_p. Is this always the case? I mean, if I compute a very complicated group G with lots of generators and its corresponding permutation group G_p, then is it true that G.gens()[i] corresponds to G_p.gens[i]?amontero90Thu, 01 Feb 2018 13:20:47 -0600http://ask.sagemath.org/question/40927/