Ask Your Question

mf's profile - activity

2018-06-26 10:30:17 -0500 received badge  Popular Question (source)
2017-10-09 07:07:10 -0500 received badge  Notable Question (source)
2017-09-23 15:12:20 -0500 received badge  Notable Question (source)
2017-07-07 15:16:16 -0500 received badge  Notable Question (source)
2017-04-20 00:15:56 -0500 received badge  Popular Question (source)
2017-01-03 16:32:50 -0500 commented question get short name for QQ, RDF, AA etc

thanks for the explanation!

2017-01-03 14:15:23 -0500 asked a question get short name for QQ, RDF, AA etc

I wonder whether there is a way to get back the short name of the function of the various rings and fields like QQ, RDF, AA, RLF, RR, etc. as a string.

For example

sage: a=QQ
sage: str(a)
'Rational Field'

But I am looking for something like:

sage: function_I_want(a)
'QQ'

I guess I could predefine a dictionary like this:

shortnames={eval(name):name for name in ['QQ', 'RDF', 'AA', 'RLF', 'RR']}

and then have a function

def function_I_want(a):
    return shortnames[a]

But this seems a bit clumsy. Is there a better way to do this; or is there somewhere in the sage code such a dictionary already defined?

The reason I am thinking about this is the following tiny bug: https://trac.sagemath.org/ticket/22132

2016-12-09 06:28:53 -0500 received badge  Nice Question (source)
2016-12-09 05:00:48 -0500 asked a question Issues with .99999999999...

Here is a result that I found surprising and I don't understand completely what corercian is causing it.

sage: int(.9999999999999999)
0
sage: int(.99999999999999999)
1
sage: int(0.99999999999999999)
0
sage: int(0.9999999999999999)
0
sage: int(0.999999999999999999999999999999999)
0

What is going on?

More to play with:

sage: a=.99999999999999999; b=0.999999999999999999999999999999999
sage: a<b
False
sage: int(a)<int(b)
False

and

sage: a=.999999999999999990; b=0.999999999999999999999999999999999
sage: int(a)<int(b)
False
sage: a<b
True
sage: a=.999999999999999997
sage: a<b
False
sage: a=.999999999999999996
sage: a<b
True
2016-08-17 10:09:56 -0500 received badge  Popular Question (source)
2016-08-16 14:42:58 -0500 received badge  Notable Question (source)
2016-08-16 14:42:58 -0500 received badge  Popular Question (source)
2016-07-16 14:06:11 -0500 received badge  Popular Question (source)
2016-05-10 16:50:24 -0500 received badge  Notable Question (source)
2016-05-10 12:57:39 -0500 received badge  Notable Question (source)
2016-05-10 12:57:39 -0500 received badge  Popular Question (source)
2015-12-29 19:57:02 -0500 received badge  Popular Question (source)
2014-07-04 08:10:35 -0500 received badge  Nice Question (source)
2014-07-03 09:44:54 -0500 received badge  Nice Question (source)
2014-07-03 07:20:21 -0500 received badge  Nice Answer (source)
2014-07-03 04:18:13 -0500 received badge  Self-Learner (source)
2014-07-03 04:18:13 -0500 received badge  Necromancer (source)
2014-07-03 04:18:13 -0500 received badge  Teacher (source)
2014-07-03 04:04:16 -0500 commented answer combinatorial equivalence for Polyhedra / isomorphism for lattices

perfect, thanks! I don't know how i missed this..

2014-07-03 03:20:12 -0500 asked a question combinatorial equivalence for Polyhedra / isomorphism for lattices

Is there an easy way to check whether two polyhedra are combinatorial equivalent, i.e. have have isomorphic face lattices.

this does not work:

Poly1=Polyhedron(vertices=[[0,1],[1,0],[1,1]], base_ring=QQ)
Poly2=Polyhedron(vertices=[[2,0],[2,2],[0,2]], base_ring=QQ)
Poly1.face_lattice()==Poly2.face_lattice()

In this case this would work:

str(Poly1.faces(1))==str(Poly2.faces(1))

but what would be a good way to check this in general?

2014-07-03 03:14:08 -0500 commented question newton's method for multiple variables / arbitrary precision

@vdelecroix: will do as soon as I have enough karma to do so..

2014-07-03 02:07:10 -0500 commented question newton's method for multiple variables / arbitrary precision

@vdelecroix: I figured out how to do this, see my answer below

2014-07-03 02:06:39 -0500 answered a question newton's method for multiple variables / arbitrary precision

One easy way to this is to use mpmath.findroot!

2014-06-28 21:43:04 -0500 received badge  Famous Question (source)
2014-06-28 21:43:04 -0500 received badge  Notable Question (source)
2014-06-28 21:43:04 -0500 received badge  Popular Question (source)
2014-06-28 20:15:57 -0500 marked best answer Combinatorial data for planar graph

I am trying to get sage working with planar embedded graphs. The answer here was quite helpful, but I have a few more questions.

  1. Is there a way to get represention of the embedding into sage? The graph6 format forgets the embedding (see the documentation of plantri).

  2. Can I presribe the outer face of my embedding when I plot a Graph in sage using .plot(layout='planar')?

Ideally, for an embedded graph, I would like to obtain something like an oriented outer face and a list of oriented inner faces. For example for the graph below I want to have

inner_faces=[[2,0,3],[0,1,4,5,3],[1,2,4],[2,3,5],[2,5,4]]
outer_face=[0,1,2]

graph

2014-06-28 20:15:55 -0500 marked best answer access to printed output

Maybe relating to this question: Access output from previous cells

Assume I defined a function that takes a string and prints it:

def f(s):
    print s
    return

Now the output of the cell

f('hello')

is just the word 'hello'.

Is there any way to access this output, for example read it as a variable?

The problem occurs when I have a MixedIntegerLinearProgram p and access it with p.show(). I then want to do something with the printed output of this command, e.g. write it to a file.

2014-06-28 20:15:36 -0500 marked best answer frozenset error when plotting polytopes: bug?

I am having trouble understanding an error I get, when i try the following:

ngon=polytopes.regular_polygon(122).dilation(18.1)
ngon.plot()

It says: KeyError: (frozenset([60]), frozenset([60])) The following works:

ngon=polytopes.regular_polygon(122).dilation(17.9)
ngon.plot()

What is going on? Is this a bug?

2014-05-20 11:25:59 -0500 asked a question newton's method for multiple variables / arbitrary precision

I am trying to find a numerical approximation with arbitrary precision to a real solution to a system of multivariate polynomial equations. I start out with an approximation which is somewhat close to solving the system, up to an precision of about 1e-05. (Meaning that the equations that I try to evaluate are not zero, but smaller than 1e-05 for my starting value)

In this question is it recommended to use scipy's fmin_tnc method, which is what I did. This works out very nicely and it quickly gave a new solution which now solves my system with precision 1e-07. In the Scipy doc it is stated that one can set the "epsilon" parameter, but not smaller than machine precision. So it seems like I can't get much more precision with this method?!

Let's say I want to solve my system with precision 1e-250. My questions are:

  1. Can I use the fmin_tnc function to find solutions with higher precision?
  2. I there another way in sage to find real solutions to polynomial systems locally (e.g. with the pari/gp)?
2014-02-04 10:58:15 -0500 marked best answer frozenset error when plotting polytopes: bug?

Its basically this bug: http://trac.sagemath.org/ticket/10046

We don't have an arbitrary precision polytopes, so sooner or later numerical errors in floating point numbers will give you the wrong answer.