Ask Your Question

process91's profile - activity

2019-05-22 11:08:17 +0200 received badge  Popular Question (source)
2019-04-11 20:09:06 +0200 received badge  Famous Question (source)
2017-12-22 10:44:09 +0200 received badge  Nice Answer (source)
2016-10-31 05:38:36 +0200 received badge  Famous Question (source)
2016-07-20 09:47:35 +0200 received badge  Popular Question (source)
2015-04-29 04:37:22 +0200 received badge  Notable Question (source)
2014-06-29 03:15:04 +0200 marked best answer Bug or desired behavior of eval?

I am fairly certain this is a bug, but I wanted to ask here before reporting it on trac. I understand that when we enter something in sage, like

sage: 5/3
5/3

We want to receive 5/3 instead of the normal python output:

>>> 5/3
1.6666666666666667

However, eval in sage seems to be rounding down:

sage: eval('5/3')
1

Where I would expect it to return 5/3 again, or at the very least 1.6666666666666667 (if eval ran through python first and had already returned 1.6666666666666667). The standard eval in python does return 1.6666666666666667.

2014-06-29 03:15:03 +0200 marked best answer What file does the "in" operator reside in?

When I run something like

sage: 32 in ZZ
True

Where is this "in" operator defined? In general, is there a nice way to trace something like this to find the file(s) being accessed?

2014-06-29 03:15:01 +0200 marked best answer Is there a way to prefix all sage code in order to include a custom module?

I have a library of commonly used functions and variables which I import, when required, into sage by using the following commands:

import os, sys
cmd_folder = '/home/username/sage'
if cmd_folder not in sys.path:
     sys.path.insert(0, cmd_folder)
import defaults as d

This allows me to access all my frequently used saved functions and variables. I essentially only use Sage through the web interface, and I would like to know if it is possible to make this code run as a "prefix" so that I no longer have to type this include in every worksheet.

2014-04-25 14:21:52 +0200 received badge  Notable Question (source)
2014-02-20 20:47:17 +0200 commented answer The tachyon object used for rendering plots

@niles I would love to take a stab at it; I think the best way to go about it would be to add a method to Tachyon objects which allows you to attach plot3d elements to the Tachyon object similarly to how you can add a sphere. I will check out the trac ticket and see if I can implement this soon. After this is completed, animating 3d graphs similarly to how 2d graphs are animated should be quite simple (this is actually why I created the above function). The only thing that will need to be changed is the way of thinking about animating - we really don't want to animate plot3d for instance, we want to animate a Tachyon object with a plot3d object attached to it. We can, of course, hide this in the animation code.

2014-02-20 09:49:29 +0200 received badge  Necromancer (source)
2014-02-19 18:08:39 +0200 commented answer Dancing x-axis in animation [solved]

Since you were able to answer your own question, you may click the "accept" icon next to your answer. This is how the site indicates the question as "solved", rather than editing the title of the question.

2014-02-19 18:06:15 +0200 answered a question The tachyon object used for rendering plots

William Stein's answer was very helpful for me, but I also wanted to animate output of a plot3d based function (specifically I was trying to animate a surface of revolution, therefore I was using the revolution_plot3d function, but it's the same idea). Essentially, if you look at how the tachyon string is created, you can recreate the functionality quite simply. Here's a function that allows you to combine a plot3d output with a Tachyon object.

from sage.plot.plot3d.base import flatten_list
from sage.plot.plot3d.transform import Transformation

def combineTachyonPlot(T,P):
    P = P.transform(scale=[-1,1,1]) # Tachyon does not have a right-hand-rule coordinate system
    render_params = P.default_render_params()
    return r"""
    begin_scene
    %s
    %s
    %s
    %s
    %s
    end_scene"""%(
                  T._res(),
                  T._camera(),
                  '\n'.join([x.str() for x in T._objects]),
                  '\n'.join(sorted([t.tachyon_str() for t in P.texture_set()])),
                  '\n'.join(flatten_list(P.tachyon_repr(render_params))))

# Example how to use this

T = Tachyon(xres=1024,yres=576, camera_center=(0,20,20), updir=(0,0,1) , viewdir=(0,-20,-20), antialiasing=True)
T.light((4,3,5), 0.2, (1,1,1))
T.texture('bg', ambient=1, diffuse=1, specular=1, opacity=1, color=(1,1,1))
T.plane((-2000,-1000,-500),(2.3,2.4,2.0),'bg')

u,v = var('u,v')
P = plot3d(u^2+v^2,(-2,2),(-2,2))

tachyon_rt(combineTachyonPlot(T,P))

You can add things to the Tachyon object as you see fit, lights, backgrounds, spheres, etc. You can also add a 2-dimensional plot to the variable P and Tachyon will render it as well.

2013-09-04 12:14:33 +0200 received badge  Popular Question (source)
2013-06-07 17:24:37 +0200 received badge  Nice Answer (source)
2013-04-13 16:19:34 +0200 received badge  Popular Question (source)
2012-03-01 10:52:09 +0200 commented answer Show the polynomials in the Groebner Basis as they are found

Thanks, that is useful. Unfortunately the radicalMemberShip function uses RAM even faster than the groebner function does, but that's my problem to solve.

2012-03-01 10:51:14 +0200 marked best answer Show the polynomials in the Groebner Basis as they are found

After you reformulated your question, it seems to me that what you want to do is test "radical membership" of some of the x_i. That's to say: You want to know whether there is some integer n such that x_i^n belongs to the ideal.

Actually, the Gröbner basis of an ideal is not enough to solve that radical membership! In Singular, radical membership can be tested as explained here.

That functionality is provided by some library of Singular. If you want to do the same in Sage, without using a Singular sub-process, you can meanwhile do as follows:

First, we define some ideal, and show that the Gröbner basis does not immediately show that some power of y vanishes:

sage: P.<x,y> = QQ[]
sage: I = P*[x*y^3+y^5, x*y^6]
sage: I.groebner_basis()
[x^3*y^3, x^2*y^4, y^5 + x*y^3]

Next, we import some stuff that is needed to benefit from Singular library functions in Sage, load the library, define the Singular function, and test for radical membership of y in I:

sage: from sage.libs.singular import lib, singular_function
sage: lib("tropical.lib")
sage: rad_mem = singular_function("radicalMemberShip")
sage: rad_mem(y,I)
   skipping text from `parameter`
1

I don't know where the text "skipping text ..." comes from - anyway, the answer of the function is 1, and that means that indeed some power of y belongs to I. Let us verify it:

sage: y in I
False
sage: y^2 in I
False
sage: y^3 in I
False
sage: y^7 in I
False
sage: y^8 in I
True

However, no power of x belongs to I:

sage: rad_mem(x,I)
0

I hope this is enough to solve your problem. In particular, I believe that looking at some protocol output of slimgb would certainly not solve your problem: As demonstrated above, the Gröbner basis does, in general, not directly provide the radical membership information for variables).

Also, as much as I know, there is no option to make slimgb or std or another Singular function make print the polynomials being considered.

2012-03-01 09:09:33 +0200 received badge  Nice Question (source)
2012-02-29 22:42:42 +0200 commented answer Show the polynomials in the Groebner Basis as they are found

I added more information about my problem to my original question. I'm not sure this will totally address my problem, but I will try it now.

2012-02-29 16:09:12 +0200 received badge  Editor (source)
2012-02-29 16:08:42 +0200 asked a question Show the polynomials in the Groebner Basis as they are found

This is more a question about singular, since that is what Sage uses to computer the Groebner Basis. In Singular, you can use option(prot) and then, upon using the groebner function of your choice, you will see verbose output. From the Singular manual, we are told that when "s" is printed in the verbose output, a new element of the standard basis has been found. It is sometimes enough, and in particular very useful for my needs, to know that a certain polynomial is in the groebner basis.

I am working with an overdetermined system of polynomials for which the full groebner basis is too difficult to compute, however it would be valuable for me to be able to print out the groebner basis elements as they are found so that I may know if a particular polynomial is in the groebner basis. Is there any way to do this?


My question is above, but more details specifically related to my problem are below, which may be useful in providing an alternate answer.

The problem is as follows: I have a system of (not necessarily homogeneous) multivariate polynomials $f_1(x_1,\dots,x_n)=0,\dots f_m(x_1,\dots,x_n)=0$. I would like to prove that a few of the $x_i$ must be equal to zero. I was able to uncomment lines 240, 241, and 242 in this toy implementation library of Faugere's f5 algorithm for Singular and remove the "lead" function around the to-be-printed output on line 241. After just a couple of seconds while running this command, $x_7^5$ was printed out as a member of the basis.

This would seem to imply that $x_7$ must equal zero. The toy library is useful in this regard, since it was able to be modified to print out the members of the basis as they were discovered, however it is still a toy implementation and is not as efficient as slimgb, for instance. My question is, how can I get this same behavior from slimgb?

2012-01-18 12:32:31 +0200 received badge  Commentator
2012-01-18 12:32:31 +0200 commented answer Faugère's F4 Algorithm

Thanks, that is what I have found as well. It looks like the command is actually J.groebner_basis('singular:slimgb')

2012-01-18 12:32:20 +0200 marked best answer Faugère's F4 Algorithm

As much as I know, there are only toy implementations of F5 in Sage (and I don't recall how it is available) - that's to say, they are good for educational purposes, but it would be much more efficient to use the default ways of computing Gröbner bases.

Note that Michael Brickenstein's "slimgb" (which is often used in Singular and thus also in Sage) is sometimes referred to as a version of F4. If you create a multivariate ideal J and want to compute its Gröbner basis with a particular algorithm, you can use something like

J.groebner_basis(algorithm='slimgb')
2012-01-17 22:40:56 +0200 asked a question Faugère's F4 Algorithm

There are many places online which mention that Faugère's F4 (and even F5) algorithms are included (or were going to be included) in Sage, but the only result in the documentation I can find is here: http://www.sagemath.org/doc/reference...

Does anyone know if it is currently included in Sage?

2011-11-22 20:58:20 +0200 marked best answer Bug or desired behavior of eval?

Eval doesn't return 1.666...67 in python-- at least not in python 2, unless you import from the future.

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 5/3
1
>>> eval('5/3')
1
>>> from __future__ import division
>>> eval('5/3')
1.6666666666666667

Switching to so-called true division was one of the incompatible changes between python 2 and python 3, one made among other reasons because it proved a pretty common mistake. (I made it myself several times in production code, and, come to think of it, it was the source of a number of bugs in Sage's graph plotting code.)

Python 3.2.1 (default, Jul 12 2011, 22:22:01) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> eval('5/3')
1.6666666666666667

Sage's underlying python is python 2, so integer division is truncating, and eval is doing the expected thing here. You can import from the future within Sage in the above way if you want to change the default behaviour, or use sage_eval instead:

----------------------------------------------------------------------
| Sage Version 4.7.2, Release Date: 2011-10-29                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: 5/3
5/3
sage: eval('5/3')
1
sage: from __future__ import division
sage: eval('5/3')
1.6666666666666667
sage: sage_eval('5/3')
5/3