Ask Your Question

Jason Bandlow's profile - activity

2019-08-02 12:55:09 -0500 received badge  Popular Question (source)
2015-09-09 18:33:34 -0500 received badge  Good Answer (source)
2015-09-09 18:33:34 -0500 received badge  Nice Answer (source)
2015-03-02 12:36:21 -0500 received badge  Guru (source)
2015-03-02 12:36:21 -0500 received badge  Great Answer (source)
2014-06-28 20:14:31 -0500 marked best answer Finding the problem in a doctest timeout

After changing a file and running the doctests, I'm getting:

sage -t  "devel/sage-trac/sage/combinat/sf/hall_littlewood.py"
*** *** Error: TIMED OUT! PROCESS KILLED! *** ***

 [360.2 s]
----------------------------------------------------------------------
The following tests failed:

sage -t  "devel/sage-trac/sage/combinat/sf/hall_littlewood.py" # Time out
Total time for all tests: 360.3 seconds

Is there an easy way to find out which test it was running when the timeout occurred? Or, equivalently, which tests did pass successfully?

2012-04-10 19:47:52 -0500 received badge  Taxonomist
2012-03-08 19:27:00 -0500 received badge  Famous Question (source)
2011-11-15 04:54:16 -0500 received badge  Good Answer (source)
2011-08-25 03:25:10 -0500 received badge  Nice Answer (source)
2011-08-12 06:24:17 -0500 received badge  Nice Answer (source)
2011-08-11 06:53:12 -0500 answered a question numerical_approx() weirdness?

When you write pi.n(digits=3), you do not get the rational number 314/100. What you get is a floating point number $x$ with a guarantee that $|\pi - x| \le 0.01$ (I believe this number also "knows" how many digits you care about; that's why print shows exactly 3 digits). Because floating point numbers are internally stored in base 2, it is impossible to represent 314/100 exactly.

2011-07-21 14:52:33 -0500 received badge  Notable Question (source)
2011-05-23 03:46:47 -0500 commented question How to magically define variables and use functional notation instead of methods

I'm not sure I understand your question. Are you talking about pre-defining things you might want to use; for example, in your init.sage file? If you're not, I don't know what you mean, since Python will complain about any symbol it doesn't recognize, and I don't believe there is a way to change that. (I could be wrong, though.)

2011-05-20 10:12:26 -0500 received badge  Nice Answer (source)
2011-05-20 03:36:30 -0500 answered a question Solve system of equations with additional conditions in sage

Since $n$ and $k$ are both bounded, you can try something like this:

sage: var('a b c d n k')
sage: nmin = ceil(1080/90); nmax = floor(2000/60)
sage: kmin = ceil(1000/70); kmax = floor(1920/40)
sage: constraints = [a >= 80, b >= 1000, c >= 20, d >= 40, a + b <= 2000, c + d <= 90]
sage: result = []
sage: for nn in [nmin..nmax]:
....:     for kk in [kmin..kmax]:
....:         result.append( solve(constraints +  [n==nn, k==kk, a+b==n*(c+d), b==k*d], (a,b,c,d,n,k)))

I think this will take some time to run, but it should get you all the solutions you want.

2011-05-18 17:13:02 -0500 commented question Solve system of equations with additional conditions in sage

For eqn1, there is an obvious upper and lower bound for n, and for each choice of n in this range, you will have 1 equation in four unknowns to determine a,b,c,d (in addition to the constraints). Once you decide on b, you can choose k freely, and this will determine e. What sort of answer are you hoping to get?

2011-05-18 17:13:02 -0500 received badge  Commentator
2011-05-18 10:23:11 -0500 answered a question How-to: sum

To add to the diversity of answers here, another valid approach is to add a single line to what you already have:

f(x)=x^2
g(x)=x*f(x)
k=var('k')
sum(g(k),k,0,4)

This will return 100. The point is that you can use this syntax to sum the values of a proper function, but not arbitrary Python expressions.

2011-05-11 13:49:54 -0500 answered a question substitute expression instead of formal function symbol

I'm not sure I understand why your example doesn't work, but here is a workaround:

sage: var('a b x')
sage: f = function('foo',x)
sage: g(x) = a*foo(x) + b*foo(x)^2
sage: h = g.diff(x)
sage: bar(x) = a*x + b
sage: h.substitute_function(foo, bar)
2*(a*x + b)*a*b + a^2
2011-03-31 23:31:06 -0500 received badge  Popular Question (source)
2011-02-26 11:02:09 -0500 received badge  Nice Answer (source)
2011-02-26 07:32:28 -0500 answered a question How do I create subsets of sets?

Here is one solution:

sage: [p for p in [0..100] if is_prime(p) and (p%6)==1]
[7, 13, 19, 31, 37, 43, 61, 67, 73, 79, 97]

For more documentation on this, look for list comprehensions in your favorite Python documentation.

2011-01-07 19:01:10 -0500 received badge  Nice Answer (source)
2011-01-07 19:01:10 -0500 received badge  Good Answer (source)
2011-01-07 19:01:10 -0500 received badge  Enlightened (source)
2011-01-04 01:58:33 -0500 received badge  Nice Answer (source)
2011-01-04 01:58:33 -0500 received badge  Good Answer (source)
2010-12-28 13:48:45 -0500 received badge  Self-Learner (source)
2010-12-28 13:48:45 -0500 received badge  Nice Answer (source)
2010-12-24 05:13:09 -0500 received badge  Good Question (source)
2010-12-24 05:13:09 -0500 received badge  Nice Question (source)
2010-12-15 11:12:18 -0500 received badge  Good Answer (source)
2010-12-15 07:51:32 -0500 received badge  Nice Answer (source)
2010-12-15 06:43:38 -0500 commented answer multidictionaries

You're welcome! In fact, lists won't work as keys. Look up 'mutable' vs. 'immutable' in connection with Python to understand why.

2010-12-15 03:16:19 -0500 answered a question multidictionaries

If I correctly understand your question, dictionaries can do this. You just need to use tuples as keys. Example:

sage: m = {} # an empty dictionary
sage: m[('Cathy', 19)] = '555-1212'
sage: m[('Cathy', 19)]
'555-1212'
2010-12-14 03:31:30 -0500 received badge  Editor (source)
2010-12-14 03:29:42 -0500 answered a question How to add term order to free module?

To slightly elaborate on John's comment, "CombinatorialFreeModule" allows you to specify an arbitrary comparison function on the elements. Here is a sample doctest from sage.categories.modules_with_basis :

            sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename("X")
            sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3)
            sage: x.leading_monomial()
            B[3]
            sage: def cmp(x,y): return y-x
            sage: x.leading_monomial(cmp=cmp)
            B[1]
2010-12-12 08:24:09 -0500 answered a question Idempotent help

Here is some code for this:

for n in [2..100]:
    print n,': (',len(n.prime_factors()), sum(a.is_idempotent() for a in Zmod(n)),')'

For a fixed n, len(n.prime_factors()) gives the number of prime factors of n and sum(a.is_idempotent() for a in Zmod(n)) gives the number of idempotents.

2010-12-08 03:43:41 -0500 commented answer A Combinatorics Problem - Product Rule Indices

See also OrderedSetPartitions, which may be helpful.

2010-12-02 14:30:33 -0500 answered a question why won't simplify multiply out square roots?

Probably not what you're looking for, but the best I could do:

sage: sqrt(m^2).simplify_full()
1/2*abs(sin(theta))
2010-11-12 04:44:37 -0500 answered a question multi-symmetric functions and multi-partitions

I don't think that what you want is available directly in sage, although there may be some tricks available depending on exactly what you want to do. I don't have time to go into more depth right now, but please post this question to the Google Group: sage-combinat-devel. There are a lot of people (including me!) who read that, who would be interested in getting this kind of functionality into sage.

2010-11-09 04:00:33 -0500 commented answer Compiling R with PNG support

This was the key. I did not have libpng installed. I installed it, re-compiled r with sage -f, and everything works. Thanks for your help, everyone!

2010-11-09 02:57:14 -0500 commented answer Compiling R with PNG support

Thanks, I'll try this.

2010-11-09 02:51:50 -0500 answered a question Compiling R with PNG support

(This should maybe be a comment, but I'm posting as an answer for better formatting.) I just discovered the following:

sage: r.eval('capabilities("png")')
'  png \nFALSE '
sage: r.eval('capabilities("X11")')
' X11 \nTRUE '

So apparently, I have X11 support, but not PNG support. Does that suggest anything that I might be able to do?

2010-11-09 02:01:42 -0500 commented answer Compiling R with PNG support

I don't think we've discussed this before (maybe that was Jason Grout?). The file /usr/include/X11/Xwindows.h is present on my system; I'll try at some point to take a look at the spkg-install in more detail and see if I can't figure out what is failing. Thanks for pointing out the Trac ticket!

2010-11-08 13:18:40 -0500 received badge  Student (source)
2010-11-07 11:24:19 -0500 asked a question Compiling R with PNG support

I just compiled sage 4.6 from source on an Ubuntu 10.04 machine. I have the xorg-dev packages installed. However, I still cannot get r to save the plot of a histogram. Specifically, I am getting:

sage: r.png('/tmp/histogram.png') 
RuntimeError: R was not compiled with PNG support

What does work is:

sage: r.X11()
sage: r.hist("rnorm(100)")

But I can't save the resulting graphic. (Of course, I can print-screen and get it that way, but I was hoping there would be a better way.) Can I compile R with PNG support somehow? Or is there another workaround which will give me what I want (namely, saving a picture of a histogram)?

Thanks.