[sage-support] Re: Contour plots of data points...

2012-04-13 Thread Jason Grout

On 4/13/12 5:45 AM, Tobias Weich wrote:

Another possibility which I use is to add the ContourPlot Object by hand
in a Graphics object:

sage: from sage.plot.contour_plot import ContourPlot
sage: C = ContourPlot(data,(0,9),(0,9),options={'fill':True,
'contours':30, 'legend_label':None})
sage: G=Graphics()
sage: G.add_primitive(C)
sage: G.show()

One has to set some options by hand in order to make it work, but it has
the advantage that only the datapoints which one really has are used for
the plot and inbetween the ContourPlot interpolates.

The output might be really different see:
http://www.sagenb.com/home/pub/4693/

I had the same trouble as Vincent at the beginning and it took me quite
a time to find a solution. Thus might it be possible to add such an
example to the documentation? Maybe with a note that users are not meant
to use the contour plot like this.However it has been quite
dissatisfactory for me that the first example in the documentation was
in principle what I was looking for but nowhere was written how to use
it (make it visible) and in all the following examples where only
ContourPlots of functions and not of discrete data.


I think the best thing to do would be to add a way for contour_plot to 
deal with data.  We can tell the difference between a list of lists and 
a function using isinstance(f, list).  If a list of lists is passed, use 
that data directly rather than trying to generate a list of lists.   Is 
anyone up for submitting a patch?


Thanks,

Jason

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Contour plots of data points...

2012-04-13 Thread Jason Grout

On 4/13/12 5:45 AM, Tobias Weich wrote:

However it has been quite dissatisfactory  for me that the first example
in the documentation was in principle what I was looking for but nowhere
was written how to use it (make it visible) and in all the following
examples where only ContourPlots of functions and not of discrete data.


This has to do with how the documentation is generated, and you're right 
that this should be fixed.  Probably the easiest way to do it is to 
prefix such classes with an underscore (so _ContourPlot).  Then they 
won't show up in the documentation, since they aren't really meant for 
the user to use directly.  Of course, that would have made it harder for 
you to do what you wanted to do, but it would have cut down on the 
frustration of having to dive into Sage internals in order to try to do 
what an example in docs indicated you could do.


Thanks,

Jason


--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Solving a set of quadratic inequalities (continuous)

2012-04-13 Thread Nathann Cohen
Hello everybody !!!

I would like to solve a set of equations with a very easy shape. My
equations are defined on variables p1_x, p1_y, p2_x, p2_y, ..., and I
would like to obtain values for them satisfying constraints like :

|p1 - p2|  1, i.e.  (p1_x - p2_x)^2 + (p1_y - p2_y)^2  1

or something similar with a  instead of . I do not really mind
whether the inequalities are strict or not, as I feel free to replace
 1 by = 0.9.

Would you know of any way to solve this type of equations, or to
ensure that no solution exists ?

Thank yo ! :-)

Nathann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Solving a set of quadratic inequalities (continuous)

2012-04-13 Thread Nathann Cohen
 Couldn't you use SCIP for this?

O probably !!

I will take a look at its documentation :-)

Nathann

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: rank of elliptic curve

2012-04-13 Thread William Stein
2012/4/13 雷德利 dl...@xidian.edu.cn:


 Professor William A. Stein:

    Several years ago,I find a online software named elliptic curves
 calculator on your homepage which can output the rank,generators of an
 elliptic curve.Today,I can not find it.I want to know some information of
 specific elliptic curves.But,the tables on your homepage is indexed by
 conductors of elliptic curves,it is not easy to use the tables for me.I want
 to know the rank,generators of elliptic curve y^{2}=x(x+1)(x-4).Do you know
 some sotware in Windows can easily compute the conductor of elliptic curves?

Use Sage.

http://nt.sagenb.org/home/pub/156/

http://sagemath.org

http://nt.sagenb.org/

 Best wishes

 Deli lei



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] trouble with M.hessenberg_form()

2012-04-13 Thread Ben Goodrich
Hi,

I am confused by the output of the hessenberg_form() method applied to a 
symmetric matrix. In sage 4.8, the result is neither symmetric nor 
tridiagonal.

For example, I unsuccessfully tried to replicate an example from 

http://eigen.tuxfamily.org/dox/classEigen_1_1Tridiagonalization.html

sage: M = matrix([ 
:   [1.36, -0.816,  0.521,   1.43, -0.144],
: [-0.816, -0.659,  0.794, -0.173, -0.406],
:  [0.521,  0.794, -0.541,  0.461,  0.179],
:   [1.43, -0.173,  0.461,  -1.43,  0.822],
: [-0.144, -0.406,  0.179,  0.822,  -1.37]])
sage: H = M.hessenberg_form()
sage: H
[   1.36   -3.68006495098039   -4.08085704360694
1.41766340804169  -0.144]
[ -0.816  -0.934426470588235   -2.34452060554290  
-0.207782335660244  -0.406]
[  0.000  -0.233486753892734   -1.55417639277791   
0.343670122014782 -0.0802230392156863]
[  0.000   0.0003.23555952487195  
-0.919771065570464 -0.0771581451235709]
[  0.000   0.000   0.000   
-2.17915687962318  -0.591626071063390]

But this behavior is not limited to real matrices ...

sage: a = var('a')
sage: b = var('b')
sage: c = var('c')
sage: 
sage: M = matrix(SR, 3, 3, 1)
sage: M[0,1] = M[1,0] = a
sage: M[0,2] = M[2,0] = b
sage: M[1,2] = M[2,1] = c
sage: 
sage: H = M.hessenberg_form()
sage: H
[ 1  a + 
b^2/a  b]
[ a  b*c/a + 
1  c]
[ 0 -(b*c/a - 1)*b/a + c - b/a 
-b*c/a + 1]
sage: 

Am I supposed to do something else to tridiagonalize a symmetric matrix?

Thanks,
Ben

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Importing Cython .so module

2012-04-13 Thread Emil
If no-one can answer this question, does anyone have an idea of another forum 
where people may know the answer?

Thanks!  -Emil

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Importing Cython .so module

2012-04-13 Thread Robert Bradshaw
On Sat, Apr 7, 2012 at 4:06 AM, Emil emi...@gmail.com wrote:
 On 7 April 2012 01:14, Maarten Derickx m.derickx.stud...@gmail.com wrote:
 Does executing:

 import foo

 give what you want or is your problem different?

 import foo doesn't do much, as foo/__init__.py is empty. I have
 adopted the Sage-like behaviour of having an all.py file which has
 from bar import * statements.

 The issue is that all.py contains lines like:

 from bazz import *
 from bar import *

 For some reason, the line corresponding to the bar.so file imports
 things into the top-level of the name space, rather than as
 foo.bar.. I can't find anything in the Cython docs or anywhere
 else about how to stop this. The Sage Cython modules seem to be
 imported into the correct places in the namespace hierarchy, so it
 must be possible...

Just a guess, does placing an __init__.pxd file at that level help?
Are you compiling the .so file and then moving it into place? (The
fully qualified name of the pyx file is determined at compile time.)
Otherwise, could you try posting a tarball/repo that illustrates the
problem for someone to play around with?

- Robert

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Random Polynomials with restricted coefficients and homogeneous.

2012-04-13 Thread Robert Bradshaw
Doing

sage: ZZ.random_element?

tells you that ZZ takes x and y arguments for min/max. Polynomial
rings' random_element pass extra keywords down to the basrings, so one
can do

sage: P.random_element(degree=10, terms=10, x=-9, y=9)
 -9*x^8*y^2 + x^8 + x^7*y + 8*x^6*y^2 - 7*x^2*y^6 - 2*x^6*y +
4*x*y^2 - 5*y^3
sage: P.random_element(degree=10, terms=10, x=100, y=200)
 113*x^2*y^8 + 107*x^6*y^3 + 104*x^2*y^7 + 102*x*y^8 + 194*x*y^6 +
196*x^3*y^3 + 192*x^5 + 133*x^4*y + 179*x^3*y^2 + 152*x*y^2

To make a homogeneous polynomial, you could do

sage: S.random_element(x=-9,y=0, degree=10)(x/y) * y^10
 -7*x^10 - 5*x^9*y - 6*x^8*y^2 - 3*x^7*y^3 - 8*x^6*y^4 - 2*x^5*y^5
- 3*x^4*y^6 - 4*x^3*y^7 - 9*x^2*y^8 - 9*x*y^9 - 3*y^10

though this is unfortunately in the fraction field, so you'd have to cast it.

sage: f = S.random_element(x=-9,y=0, degree=10)(x/y) * y^10
sage: f.parent()
Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring
sage: P(f)
-9*x^10 - 5*x^9*y - 6*x^8*y^2 - 3*x^7*y^3 - 9*x^6*y^4 - 9*x^5*y^5
- x^4*y^6 - x^3*y^7 - 8*x^2*y^8 - 3*x*y^9 - 5*y^10
sage: P(f).parent()
Multivariate Polynomial Ring in x, y over Integer Ring

You could also construct it directly (which may be faster for large degree):

sage: dict(((k, 10-k), ZZ.random_element(-9, 9)) for k in range(10))
 {(6, 4): -7, (5, 5): -5, (7, 3): 8, (2, 8): -1, (8, 2): 3, (0, 10):
-4, (1, 9): -8, (9, 1): -5, (3, 7): -8, (4, 6): 7}

sage: P(dict(((k, 10-k), ZZ.random_element(-9, 9)) for k in range(10)))
 -8*x^9*y + 4*x^8*y^2 - 6*x^7*y^3 - 4*x^5*y^5 - 5*x^4*y^6 + 4*x^3*y^7
- 3*x^2*y^8 + 2*x*y^9 - 3*y^10


- Robert

On Fri, Apr 13, 2012 at 8:51 AM, PavelY yartsevpa...@gmail.com wrote:
 Hi.

 I've been working on making random polynomials with sage and I cant seem to
 find a way to create them with restricted coefficients (or make a
 homogeneous polynomial).

 I've been constructing my polynomials with the help of the
 random_element(degree, term) function on PolynomialRings(ZZ). However I cant
 seem to find a way to restrict the coefficients (ex: coefficients from -9 to
 9)

 Here is a segment of my code:

 x,y = var('x,y')
 P.x,y=PolynomialRing(ZZ)
 fcn = P.random_element(degree=3,terms=4)

 This produces very large coefficients (at times). I would like to restrict
 them to -9..9 and make the random polynomial homogeneous.
 Please let me know if there are functions which take care of this, or if
 this polynomial needs to be created manually without the random function.


 Thank You.

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org