In Python generally, "X = Y" doesn't modify the *object* which is named X,
it just rebinds the name, saying that "X" now refers to the object given by
the expression Y. So in general,
for something in someloop:
something = something_else
isn't going to do much. (I want to say "nothing"
Not scoping, typing.
When you do i+1, this is preparsed into
sage: preparse('[len(top_points(i+1)) for i in range(2,10)]')
'[len(top_points(i+Integer(1))) for i in range(Integer(2),Integer(10))]'
and the addition means that top_points is passed not a Python int, but a
Sage Integer, and your
While qgamma isn't a native function, there's a qgamma implementation in
mpmath, one of the libraries included in Sage, so:
from mpmath import qgamma
plot(lambda x: qgamma(4,x), (x, 2, 10))
should give you a plot of gamma_(q=4).
Doug
--
You received this message because you are subscribed to
I don't think you need to make an explicit class here. You can build a
function from within another function, and return that:
sage: def f(n, z):
: return z**n
:
sage: def maker(tup):
: def g(z):
: return sum(abs(f(a_i,z))**2 for a_i in tup)
: return g
I mean, I can of course do f(P1[0],P1[1],P1[2]),
but this is highly non-elegant.
You can use an asterisk:
sage: f(x,y,z) = x+10*y+100*z
sage: P1 = [2,3,4]
sage: f(*P1)
432
Here, * behaves kind of like a dereferencing operator: f(*(x,y,z)) ==
f(x,y,z). See this StackOverflow question for a
Hmm. My backtrace showed:
/home/mcneil/sagedev/sage-5.4.beta0/local/lib/libcsage.so(print_backtrace+0x3b)[0xb6bd7c49]
/home/mcneil/sagedev/sage-5.4.beta0/local/lib/libcsage.so(sigdie+0x17)[0xb6bd7c89]
On Wed, Sep 19, 2012 at 12:42 PM, Christophe BAL projet...@gmail.com wrote:
What I think very confusing is that 1/4 is the Sage division and not the
Python standard one, so why it would be different for randint ?
It's not Sage division vs. Python division, it's Sage Integers vs. Python ints.
Somewhere along the path the second argument to scipy.special.lambertw
(0) is being converted to a float:
import scipy.special
scipy.special.lambertw
built-in function lambertw
scipy.special.lambertw(1, 0)
(0.56714329040978384+0j)
scipy.special.lambertw(float(1), 0)
(0.56714329040978384+0j)
After some digging -- and a fortuitous control-C at the right moment
-- it looks like it's trying to construct the basis for the ambient
free module. This will be a list of 10^4 vectors, each 10^4 elements
long, so it's not surprising it takes a lot of memory.. adding a print
statement in the
On Fri, Jun 22, 2012 at 7:19 AM, David Harvey d.har...@unsw.edu.au wrote:
--
| Sage Version 5.0, Release Date: 2012-05-14 |
| Type notebook() for the GUI, and license() for information. |
AttributeError: 'ProjectiveCurve_finite_field' object has no attribute
'riemann_roch_basis'
why?? help please!
If I understand correctly, as the documentation says:
Currently this only works over prime field and divisors supported
on rational points.
Your F is GF(4), which isn't a prime
On Fri, Jun 1, 2012 at 10:59 AM, Jeroen Demeyer jdeme...@cage.ugent.be wrote:
Looks like an infinite recursion, leading to stack exhaustion, leading
to a SIGSEGV:
I agree with the last two but not the first. I think it's just a
really long LazyBinop chain, which is why I was having trouble
I can push this back at least to
number_field_morphisms.create_embedding_from_approx: the segfault
seems to happen during the evaluation of the defining polynomial of
the cyclotomic field.
For my 5.0,
sage: CyclotomicField(160400)
[...]
/Applications/sage/spkg/bin/sage: line 312:
The following:
sage: z = pi.n(100)
sage: z.str(base=4)
'3.0210033310202011220300203103010301212022023200'
should get you started.
Doug
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
For future reference, run `md5sum filename` in a terminal to check the
MD5 sum of a file.
I'm pretty sure it's md5, not md5sum, on OS X (at least in 10.6).
Doug
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
I can reproduce this on my 10.6.8 macbook:
sage: int(2)
2
sage: int(2.75)
Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x000101723ed9 in case1 ()
(gdb) bt
#0 0x000101723ed9 in case1 ()
#1 0x000103e8bba4 in parsed_string_to_mpfr ()
#2 0x000103e8c7fb
Doug, are you using the binary or did you compile your Sage?
Deliberately the binary; I've never had problems with a Sage I've
successfully compiled myself. [Haven't compiled 5.0 myself yet on
the Mac, though I did at work today on ubuntu 12.04 and it went fine.
Will probably try overnight.]
I was able to find a case which crashed but doesn't have to crash
Sage. Doesn't tell us much new, but here it is anyway:
sage: 12345678912345678912345678912345678901234567890.
---
RuntimeError
I think you should close that. The following works fine in the
notebook. It makes no sense to close the file -- instead, you have
to delete the csv writer object, which flushes it to the file.
This isn't guaranteed to flush it to the file, though, because del
only deletes the name. That it
I think I have a smaller example:
sage: G = Graph([(0, 3, 1), (0, 4, 1), (1, 2, 1), (2, 3, 1), (2, 4, 1)])
sage: G.edge_cut(0,1,value_only=False,use_edge_labels=True)
[1, [(0, 3, 1), (1, 2, 1), (2, 3, 1)]]
sage: G.edge_cut(0,1,value_only=False,use_edge_labels=True,method='LP')
(1.0, [(1, 2)])
You're probably getting a list of dictionaries:
sage: var(x y)
(x, y)
sage: sols = solve([x^2-4==0, y^2-9==0], x, y, solution_dict=True)
sage: sols
[{y: -3, x: -2}, {y: -3, x: 2}, {y: 3, x: -2}, {y: 3, x: 2}]
This is just like any other list -- the fact the elements happen to be
dictionaries
This seems to work on test.sagenb.org (5.0.beta1) and the 5.0.beta4 I
have around, so something (whether Sage-side or matplotlib-side) must
have changed for the better from 4.8. Is it time-sensitive enough to
track it down and make a backpatch?
Doug
--
To post to this group, send email to
I am a two-tuple vector, vet=[(1,2),(3,4),(5,6),..], i want plot
this data with a line aproximation, (interpolation this points), exist
any parameter in list_plot function for this.
Maybe
line(vet)
does what you want? You can look at
sage seems to think that the gcd of 6 and (-2 mod 6) is -2 mod 6, which it
converts to 4. A mathematician would say that the gcd is 2.
Is this a bug, or does sage have a higher purpose here?
Sage is actually reasoning slightly differently, I think. First it
decides whether there's a
Anyone using numpy from Sage should beware of the following:
sage: import numpy
sage: m = numpy.matrix([[1,2],[3,4]])
sage: m[:,0]
matrix([[1, 3]])
sage: m[:,int(0)]
matrix([[1],
[3]])
That is, if you use a Sage integer to index a numpy matrix, you don't
get the expected shape back. I
On Sun, Feb 12, 2012 at 2:13 PM, mrkvon michal.sala...@gmail.com wrote:
Hello,
what is wrong with this, please? I tried to sum some matrix elements
and got error below. I tried to sum by other means (comment # and ##
in example below) without problem. I even defined my own summation
function
Warning: I haven't thought this through, but the ideas might be useful.
It looks like you'd call something a 3-cycle if for some x_0 we had
f(f(f(x_0))) == x_0, right? Then we should be able to do this
numerically, with some caveats:
# can't remember the slick way, so brute force
def
First attempt: loop through each term and try to n() the coefficient.
Madness.
Based on a suggestion Mike Hansen once gave me --
http://ask.sagemath.org/question/411/substituting-expressions-for-numbers
-- I tend to use subclasses of Converter when I need to do something
like this, so as not to
[[1],[2,8,4,6],[1,2,7],[9,3,4,6],...]
[[1],[14,17,18,19],[1,4,11],[9,14,16,19],...]
would like to figure out how to get both results like this:
[1,2,8,4,6,1,2,7,9,3,4,6,...]
[1,14,17,18,19,1,4,11,9,14,16,19...]
Two ways come to mind:
sage: a = [[1],[2,3,4],[5,6,7]]
sage: a
[[1], [2, 3,
Most of the time, filtering jobs like this can be accomplished by one-
liners using the right list combination and iteration tools:
[c for c in enumerate(zip(l1,l2)) if c[1][0] ==c[1][1]]
You can even avoid the [1][0] stuff by using some nifty unpacking:
[(c,ai) for c, (ai,bi) in
Hi all, I'm confused why this code results in a graph plotted with the
(single) edges labeled with the weight between each pair of vertices:
M = Matrix([[0,1,-1,5],[1,0,-1/2,-1],[-1,-1/2,0,2],[5,-1,2,0]])
G = Graph(M,sparse=True)
G.plot(edge_labels=True)
Whereas this code does not and
test.sagenb.org seems to be up, so if she has a saved local copy of a
worksheet, she could use that..
Doug
--
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
def U(N,M):
U=matrix(ZZ,N*M)
for i in range(N*M):
for j in range(N*M):
U[i,j]=1
return U
def Q(N,M):
Q=matrix(ZZ,N*M)
for i in range(N*M):
for j in range(N*M):
Q[i,j]=U(N,M)
return Q
U(N,M) is a function which returns a matrix.
Normally I can differentiate analytically to get the slope and
inflection points. While trying to have a quick look into these points
with numerical differentiation I noticed that mpmath is giving me
values quite distant from the ones obtained with analytical formulas.
I think there's a
:-/ That's definitely a bug. The precision used in
integral_points_with_bounded_mw_coeffs (100 bits) is too small to find
that solution. Even bumping the precision to 120 bits suffices,
although that's probably the wrong approach:
[(436 : 559 : 1), (450 : 2925 : 1), (666 : 14589 : 1), (900 :
The problem is that the solution that desolve returns:
sage: myode = tau*diff(p,t) == p*(1-p/k)
sage: sol(t) = desolve(de=myode, ivar=t, dvar=p)
sage returns:
-tau*log(-k + p(t)) + tau*log(p(t)) == c + t
isn't in an easy enough form for plot to display. You're setting
sol(t) not to an
You're assuming that the fit function is going to return the variables
in the same order in both cases, so that (e.g.) a and k1 will be the
first in both cases. That's not true, though. I found:
[a == 3.4102956225507519, b == 0.010344876276231638, c ==
-0.00094076216744204172, d ==
thread hijack but not really
Most likely, the problem here is that numpy doesn't recognize Sage Integer
objects as being convertable to python integers. I think this is a failing
of numpy (it should check the __index__ method to see if it can convert the
Integer to a python integer).
Do you know about Python dictionaries?
http://docs.python.org/tutorial/datastructures.html#dictionaries
They're a kind of general map along the lines that you want, and you
can build them in many ways. For example:
import string
m = dict((c, ord(c.lower())-ord('a')+17) for c in
Hi!
I'm not sure what you mean by
Also if I have the terms, and return on separate lines in the
definition then I get this error.
You _have_ to have the different statements on separate lines, like I
did. (Unless you use a semicolon to separate the statements, I
suppose.) Did you combine
def f(y,t): return (1+(bessel_J(0, gro)/bessel_J(2, gro)))*(r/
kro)*(bessel_J(1, r)/bessel_J(1,gro))*z.cos()-(bessel_J(0,r)/
bessel_J(2, gro))*(r**2/kro**2) if t != 0 else infinity
A few things:
(1) Your arguments to this function are y and t, but inside you use r
and z. r and z are still
Sage: y,t = var('y,t')
Sage: contour_plot(lambda y,t: (sqrt(t^2+y^2)/(2*pi*y))*(bessel_J(0,
t ).arccos()), (t, 0, 3), (y, 0, 4), fill = false, axes_labels=['$gro
$','$kro$'], contours = [0.1, 0.2, 0.3, 0.5, 0.7, 1.0, 2.0, 4.0],
fill=False, legend_label='qwall');
This is the error message
I want that legend is in left side, ... how?
Try something like:
p = plot(sin,legend_label=sin)
p.set_legend_options(loc='upper left')
p.show()
After making some plot p, you can type help(p.set_legend_options) to
see more information about the various things you can configure.
Doug
--
To
This is definitely not a bug. The definition of the _add_ method
absolutely demands that both inputs have exactly the same parent. In
the above instance, the left hand input (=1) has parent ZZ, and the
right hand input (=SR(2)) has parent the symbolic ring.
Yeah, I know that-- it's the
I don't think you should need to call _add_, but this looks like a bug to me:
--
| Sage Version 4.7.1, Release Date: 2011-08-11 |
| Type notebook() for the GUI, and license() for information.|
The shortest way to test it my above interpretation of your logs is indeed
correct is by seeing if excecuting:
echo #include limits.h | cpp
gives any errors. If so my interpretation is correct.
And if it is, which seems likely, there's probably a kernel headers
package missing. Googling
On Fri, Sep 23, 2011 at 12:39 AM, Santanu Sarkar
sarkar.santanu@gmail.com wrote:
I want to find integer such that
x= 1 mod 3
x=2 mod 5
x=3 mod 7
like this system of congruences using Chinese Remainder Theorem.
In Sage, crt() function takes only 4 argument.
sage: help(CRT)
crt(a, b,
It always returns 101, not a random prime of 100 bit integer.
That's because in Python/Cython, the carat ^ isn't exponentiation,
it's bitwise xor. The most general solution is to use **:
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
In your code, ComSet is a Python list (not a set) as are many of its
components, and you use len(x) to get the size:
sage: ComSet, type(ComSet), len(ComSet)
([[[0, 1], [0, 2], [1, 2]], [[0, 1, 2]], [[0, 1], [0, 2], [1, 2]]],
type 'list', 3)
sage: ComSet[0], type(ComSet[0]), len(ComSet[0])
([[0,
Thanks for this. There still seems to be a manual step in going from,
say,
s1 = 2*(1,8) - (1,9)
to
s1 = 2*b[1] - b[2]
I may be misunderstanding you. Are you saying you want to enter the line
s1 = 2*(1,8)-(1,9)
verbatim and have it work? That I don't think I can do (unless you're
.. I suppose you could even add a convenience function
def b(*x):
return m[x]
after which
sage: s = [2*b(1,8) - b(1,9),
: -b(1,0) + b(1,9),
: -b(1,0) + b(1,8)]
sage: s
[2*(1,8) - (1,9), -(1,0) + (1,9), -(1,0) + (1,8)]
would work.
Doug
--
To post to this group, send
We would like to know if certain sums of modular symbols span the
space.
Is this the sort of thing you had in mind?
sage: M=ModularSymbols(11,2);M
Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with
sign 0 over Rational Field
sage: b = M.basis()
sage:
sage: s1 = 2*b[1] - b[2]
How to find the nearest integer (+ve or -ve) of a rational number (P/Q)
where P,Q are very large integers?
You could use the .round method of rationals.
sage: q = 17+1/2+1/11**1000
sage: RR(q.numerator()), RR(q.denominator())
(2.48685403212345e10413928, 1.42105944692768e10413927)
sage:
My understanding was that 'x' was the indeterminate
of the ring of polynomials over QQ, i.e. the rationals. So how come
the polynomial
has coefficients which are not rational?
Because the polynomial isn't living where you think it does anymore:
sage: R.x = QQ['x']
sage: R
Univariate
Thus I wonder why this doesn't work
def f(x): return r.dnorm(x,mean=100,sd=25)._sage_()
plot(f(x)(x,90,110))
while
def f(x): return x^3
plot(f(x),(x,0,2))
works perfectly.
The problem is that the f(x) calls f with the symbolic argument x
_at the time you call the plot function_.
In
PolynomialRing(ZZ, 'x')
This is only an aside, but I should probably warn that (unlike var,
say) this doesn't change x, so it might not do what you're thinking.
x is still an Expression, an element of the Symbolic Ring, and so f is
also an Expression. You probably want to use something like
The key here is understanding exactly what x[0] is: it's not a
rational. If you run your code (after adding the line
set_random_seed(3) at the start to make sure we're working with the
same matrices), you see:
sage: minx, maxx, miny, maxy
(+Infinity, (3), +Infinity, (21/5))
and the odd
1 - On 2D plots, I have been unable to use the legend() attribute and
the set_legend_options() attribute.
I don't think you have those methods. I think you're using an old
version of sage (maybe = 4.5.2?) but reading documentation from a
later version, which occasionally causes trouble. What
time[0].right().n()
Not sure why time.rhs() doesn't work...
That I can explain. time is a list (well, technically a Sequence) of
equations, and so you'd need to type time[0].rhs(). The individual
equations have right hand sides, but the list itself doesn't.
FWIW, I prefer using dicts rather
The range function is a Python one, and it returns Python ints.
Python ints have truncating division, so that 3/2 = 1, not 3/2. When
you type 3/2 at the Sage command, it's preparsed to be Sage Integers:
sage: 3/2
3/2
sage: preparse(3/2)
'Integer(3)/Integer(2)'
sage: int(3)/int(2)
1
sage: 3r/2r
1
Emailing this instead of newpost because of the attachment.
This worksheet works well ONCE when it starts unevaluated. Reediting the
data followed by ActionEvaluate all induces TypeError: 'str' object
is not callable. My way out is to Delete output save and quit and
reopen. But I do not
TypeError: list indices must be integers, not
FiniteField_ext_pariElement
I see this problem on Mac OS X, so it's not specific to one type of system.
It may be due to a change in the way finite fields are handled as the size
grows, but I'm not familiar with that code.
Can anyone hazard
I'm not turning off warnings in numpy, though, since we use it under the hood
only
here.
I'm confused. I was going to recommend numpy.seterr(all='ignore')
before I read this, maybe wrapping plot to restore the original state
after the call.. but now I'm not sure what kind of solution you
I'm completely unable to get the scipy special functions module to
work. In addition, it seems to cause chaos on my system once imported
sage: import scipy
sage: from scipy.special import *
sage: scipy.special.lpn(1,1)
I'd avoid your second line in Sage, which pulls everything in
I tried installing the Qhull package which is an optional package on
the list at http://www.sagemath.org/packages/optional/, but i got the
error below. It appears that /usr/include/float.h can't be found, but
i *do* have that file.
I'm not sure whether this is a Sage-related issue. Could be
I want to show a tree with edge labels. I tried out
G1 = Graph({1:{5:0},2:{5:1},3:{6:1},4:{7:0},5:{6:0},6:{7:1}})
show(G1,edge_labels=true)
show(G1,layout=tree,edge_labels=true)
In the first graphic the labels are positioned on the edges but in the
second one they are not. Why is this?
On Tue, Apr 5, 2011 at 1:47 PM, tvn nguyenthanh...@gmail.com wrote:
Is there a timeout mechanism in Sage or Python that allows me to kill or
raise an exception on a command that exceeds some time threshold ?
You probably want alarm, which raises a KeyboardInterrupt.
Doug
--
Department of
On Tue, Mar 29, 2011 at 4:00 AM, tvn nguyenthanh...@gmail.com wrote:
I'd like to be able to regenerate samples by feeding a seed value to
random.seed() , but it seems sample() doesn't use this random seed. Is
there a way to do what I want ?
help(sage.misc.randstate) explains a lot of the
sage: (a^3)^(1/3)
5*(meter^3)^(1/3)
does not produce the expected units of meter. Is there a means to
force further simplification?
You could try
sage: m = units.length.meter
sage: assume(m 0)
sage: (5*m)^3
125*meter^3
sage: ((5*m)^3)^(1/3)
5*(meter^3)^(1/3)
sage:
integrate(integrate(1/16,y,-2,(z+2*x+4)/(x+2)),x,(-z-8)/4,2)
Seems to work for me:
--
| Sage Version 4.6.1, Release Date: 2011-01-11 |
| Type notebook() for the GUI, and license() for information.|
But, after a reset() command, it does not work anymore.
Confirmed. Well, that ain't proper.
Could you try reset(); forget(); instead of reset()? Right now
assumptions survive a reset in a broken state (try assumptions()
before and after the reset and you'll see them still listed even if
the
Note that you need to use randomize=False in plot if you're doing
this, because otherwise the plot positions are different each time
(!), so caching the function is useless. I don't understand the
motivation for having that be the default behaviour.
Better than having a set algorithm that
On Wed, Mar 2, 2011 at 4:55 PM, Thierry Dumont
tdum...@math.univ-lyon1.fr wrote:
One of my colleagues uses a Macintosh with a Japanese environment.
He cannot upgrade sage (4.6.1).Here is a transcription of what happens.
Any idea?
I used to hit this problem myself (not with Sage, but with other
export HGENCODING=UTF-8
(Of course not everyone uses bash, so modify as appropriate.)
Doug
--
Department of Earth Sciences
University of Hong Kong
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
I was wondering if sage implements any algorithm for counting the number of
points with integer coordinates inside polyhedra with rational coordinates.
even such an algorithm for polygons would be useful for me.
Have a look at the integral_points method of Polyhedron objects, which
might do
On Thu, Feb 24, 2011 at 1:52 PM, Ronald L. Rivest rivest@gmail.com wrote:
Is posting this bug here on this list sufficient to report it so that it
will (eventually) get fixed, or is there some other process for doing so
that needs to be done next?
I think in general you open a ticket on
On Thu, Feb 24, 2011 at 1:14 PM, Ronald L. Rivest rivest@gmail.com wrote:
I want a numeric integration, but
numerical_integral(numerical_integral(f,0,x),0,1)
doesn't work, since f takes two parameters, not one.
IIUY, you could nest it, and do
sage: numerical_integral(lambda x:
A somewhat simpler test case, which I think preserves the qualitative issue:
sage: from sage.rings.polynomial.real_roots import real_roots
sage:
sage: x = polygen(QQ)
sage: f = 2503841067*x^13 - 15465014877*x^12 + 37514382885*x^11 -
44333754994*x^10 + 24138665092*x^9 - 2059014842*x^8 -
I think it's neither Sage nor numpy that's at fault, it's a weird
interaction (Sage 4.6.1):
sage: import numpy
sage: numpy.binary_repr(17)
''
sage: numpy.binary_repr(int(17))
'10001'
and I think it's rooted in this fact:
sage: hex(17)
'11'
sage: hex(int(17))
'0x11'
That is, Sage capital-I
Sorry for the large example, but smaller examples seem to work.
After some reductions, I think we can find a slightly simpler failure,
of a somewhat suspicious size (4.6.1, OS X 10.6):
q = var('q')
for i in [1..33]:
ix = 2**i
f=(q+1)/(q^(ix) + 1)
res = (f.series(q==0,2),
hello,
why is the below code plotting a flat function rather than a box one?
There are two things going on. First, in the line
plot(box(x,1),(x,-3,3))
box(x,1) is actually being evaluated when the line is executed, and
not thereafter. IOW you're computing box(x, 1), which is 0, so the
above
On Fri, Jan 28, 2011 at 9:08 PM, Jeff wrote:
I would like to be able to plot a function, e.g. plot(sin), that has
axes and ticks on the axes but that does not have labels for the
ticks. I understand that I might be able to do this using a ticker
formatter, perhaps also, by directly using
(-6.66133814775094e-16, -1.00)
---???
Why isn't the first coordinate 0??? In theory it should be...
Such things are basically inevitable with floating point whenever any
number involved can't be perfectly represented-- and in this case
sqrt(2)
83 matches
Mail list logo