Ask Your Question

tmonteil's profile - activity

2019-04-18 15:55:32 -0500 received badge  Nice Answer (source)
2019-04-11 15:44:25 -0500 commented answer Quicker expansion of multivariate polynomials

OK you decide. But you can also post a simplified version of the code that shows the issue.

2019-04-11 13:42:53 -0500 answered a question Quicker expansion of multivariate polynomials

You should provide the code of the build_polynomial function.

What is the degree of the polynomials ?

My understanding is that your polynomials are symbolic expressions, not genuine polynomials, which would explain part of the slowness. But it is hard to advise something interesting without more details.

Also, in very high degree, one could imagine to answer your questions from the list of factors without having to build a polynomial by multipliying the factors. Having the factors is a rich information, that might be sad to lose by expanding the product.

2019-04-10 03:31:26 -0500 answered a question How to access serial number corresponding to each element in $GF(2^3)$?

What you can do is a dictionary:

sage: d = dict()
sage: for i in range(2^3):
....:     d[F.fetch_int(i)] = i

sage: d
{0: 0, 1: 1, x: 2, x + 1: 3, x^2: 4, x^2 + 1: 5, x^2 + x: 6, x^2 + x + 1: 7}
sage: d[x^2]
sage: d[x+1]
2019-04-09 15:49:25 -0500 answered a question Direct substitution vs "subs" method

There basically no difference. Indeed, if you look at the source code of the __call__ method of formula by typing:

sage: formula.__call__??

you can see that there is :

return self._parent._call_element_(self, *args, **kwds)

So, if you look at the _call_element_ element of the parent of formula (which is the symbolic ring) by typing:

sage: SR._call_element_??

besides some deprecation warnings, there is:

return _the_element.subs(d, **kwds)
2019-04-04 02:53:14 -0500 received badge  Good Answer (source)
2019-03-30 08:52:28 -0500 answered a question Please help me build a mathematical models (Linear programming problem)

You can have a look at this tutorial

Please do not hesitate to tell us in case of difficulty, by showing your code and where you are locked.

2019-02-22 04:12:57 -0500 received badge  Nice Answer (source)
2019-02-19 14:00:55 -0500 answered a question Latex Transition Problem

Your construction does not really makes sense : (f+pt1).show(xmin= xmin, xmax= xmax, ymin=-20, ymax=20) does not return anything, since the show method does just plot something, but does not return any object, hence the construction of z corresponds to the empty graph, and you can check:

sage: z == Graph(None)

So, what do you want to achieve ?


Only the following 4 lines are useful:

xmin = -10 
xmax = 10
f = plot((x^2-2)/(x+2), (x,xmin, xmax), ymin = -20, ymax = 20)
pt1 = point((-2,2), rgbcolor='blue', pointsize=40)

Everything else is about discrete graphs (those with vertices and edges), not with functionnal graphs, nor graphics.

It turns out that matplotlib, which Sage uses to render such plots is able to export to latex (using pgf package), and Sage has a an interface to it. You can do:


and copy-paste the long text you get into your latex file. To let the code work, you have to add the pgf package in your latex file:

2019-02-19 12:42:44 -0500 commented question Trouble Plotting a Function

You say : "Yes I reran the code, and it worked fine." So what ?

2019-02-19 11:39:11 -0500 commented question Trouble Plotting a Function

It works well for me, both on the command line and the jupyter notebook. What is your OS, how did you install Sage, which commands did you type before that (in particular, did you redefine x), which error message did you get, etc ?

2019-02-18 18:31:11 -0500 answered a question A function being an input

The parameter locals should be a dictionary not the set {False}:

sage: var('y')
sage: f = sage_eval(str(input("What is the function:" )), locals = {'y': y})
What is the function:cos(y)
sage: integral(f,y,0,16)
2019-02-18 09:15:30 -0500 answered a question solve(x) does not fully isolate x. Can Sympy use assume()tions?

Unfortunately, the Sage's assumptions are not passed to sympy and conversely, see trac ticket 24334 and trac ticket 24078.

What you can do as a workaround is to directly pass sympyassumptions, see :

2019-02-14 12:12:20 -0500 answered a question how to substitute several variables on both sides of the equation?

You will have to struggle with wildcards, see examples on the page:

If the substitution involves both right-hand side and left-hand side of the equation expr, first put everything on a single side:

e = expr.rhs() - expr.lhs() == 0


e = expr.rhs() / expr.lhs() == 1
2019-02-14 02:50:28 -0500 answered a question "=" vs "==" - when to use what?

Actually, in Python = has another meaning when calling a function or a method: it is used to pass a value to a parameter, that is, if a function f has two parameters m and n, and you want to evaluate it with $m=1$ and $n=4$, you can do:

f(m=1, n=4)

I would say that f(m==1) is a attempt to be nice with the newcomer, but it would not mean anything outside the symbolic ring (that keeps m==1 as a symbolic expression with two operands), since in general this will just reduce to f(True) or f(False). There is nothing interesting to understand here, this is not Pythonic, and reserved to a dark part of Sage.

2019-02-14 02:43:44 -0500 answered a question Can't post karma insufficient to publish links

Actually, there is a link in your post at the line:


This is an antispam feature, now, with 11 points of karma, you should be able to post links.

2019-02-12 09:12:12 -0500 answered a question propagation of error calculation?

The usual way for certified numerics is to use inverval arihmetics and ball arithmetics.

You can have a look at this thematic tutorial about the various representations of real and complex numbers in Sage, which include the RealIntervalField and the RealBallField:

In case the page disapears, you can finf a very close version on trac ticket 15944

(disclaimer : i am the author of the worksheet).

You can also have a look at the book Computational Mathematics with SageMath :

2019-02-11 14:07:24 -0500 received badge  Nice Answer (source)
2019-02-09 15:48:15 -0500 answered a question Algebra of functions f:Z_3 -> R

At first, you can have a look to the following thematic tutorials about implementing your own algebraic structure in Sage:

2019-02-09 07:16:40 -0500 received badge  Great Answer (source)
2019-02-09 04:13:27 -0500 commented question No output when documentation say it should be

OK I, do not have winows with me, let me just add the windows tag so that inerested people can focus on that.

2019-02-08 22:00:12 -0500 received badge  Good Answer (source)
2019-02-08 17:27:30 -0500 commented question No output when documentation say it should be

It works for me (Sage 8.7.beta3, complied on Debian jessie 64bit, run from the command line). Could you please give us some informations so that someone can try to reproduce your problem:

  • which version of Sage did you use ?
  • which OS ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage yourself ?
  • which notebook did you use (Sage notebook or jupyter notebook) ?
  • did you use the command line ?
  • which commands did you type precisely to get the error ?
  • which error message did you get ?
  • ... ?
2019-02-08 14:05:56 -0500 received badge  Nice Answer (source)
2019-02-08 11:01:40 -0500 answered a question Jupyter-Python3 notebooks.

Python 3 is compiled with Sage. To have it available as a jupyter kernel, just open a terminal and type:

sage -python3 -m pip install ipykernel
sage -python3 -m ipykernel install --user

EDIT Note that trac ticket 26441 asks for having both kernels available in Sage. The problem is that currently the ipykernel installs either the python2 kernel or the python3 kernel depending on which version of Python was used to build Sage.

2019-02-05 15:10:10 -0500 received badge  Nice Answer (source)
2019-02-04 10:26:15 -0500 commented question What does the [ File " " , Line 1, in < module > ] error mean?

I can not reproduce your problem, perhaps did you type a special character instead of a space somewhere. Try to retype everything, and do not put any space before your command.

2019-02-04 09:49:23 -0500 commented answer firefox tab completion sagemath

From the terminal, run the command :

sage -n

You will get some wbpage that proposes you to migrate your sagenb worksheets into jupyter worksheets. Open them and save them into some directory.

Then, you can start the jupyter notebook directly by typing:

sage -n jupyter
2019-02-03 08:56:13 -0500 answered a question How plot revolution of a circle to generate a sphere by animation view?

For each step of the (discretized) revolution process you have to define a picture, and you will glue the pictures into an animation with the animate function. Since each picture corresponds to a range of longitudes, the easiest way to do this should be to use a representation of the sphere by it spherical coordinates, so, you can use the following:

2019-02-03 08:33:20 -0500 answered a question How to plot a diagram of a circle obtained by section of a sphere by a plane
2019-02-03 04:38:38 -0500 answered a question firefox tab completion sagemath

I am not sure about your actual problem since i am not running ubuntu 18.10, so that i can not reproduce your problem.

That said, i would strongly recommend to switch to the jupyter notebook, not only because it will fix your problem, but also since the Sage notebook is deprecated for a while and gets updated only to fix critical issues.

On the jupyter notebook, to remove a cell, just go into the command mode by typing on the ESC key (the left of the cell becomes blue), and then type x to remove the current cell.

2019-02-03 03:06:08 -0500 answered a question jsmol problem in Sagemath/Jupyter notebooks

The easiest way in your settings is definitely to compile Sage by yourself, so that jsmol will be installed as a standard package. On Debian-like systems, it is pretty straightforward, see the doc at : The source code of Sage can be downloaded at

2019-02-01 14:08:18 -0500 answered a question how to change rhs() of an equation in an equation list

Why not just rewriting the equation:

sage: eqT[0] = eqT[0].lhs() == 5
sage: eqT
[x == 5, y == 4]
2019-02-01 07:31:37 -0500 answered a question Checking that all values in an array satisfy an inequality

You can use any of all as follows:

sage: L = [1,2,3,4,5]
sage: all(x < 10 for x in L)

sage: all(x < 3 for x in L)

sage: any(x < 3 for x in L)
2019-01-31 05:32:00 -0500 commented question how to get hints on fixing silly syntax errors

It works for me. Didi you check that the space is not a wrong invisible character ?

2019-01-31 03:51:43 -0500 answered a question x coordinate Of an Elliptic Curve point


sage: P[0]
2019-01-30 03:52:34 -0500 commented answer How to create a coercion on hyperbolic models?

This is the first thing i teach during Sage trainings !

2019-01-29 14:12:15 -0500 received badge  Nice Answer (source)