Ask Your Question

Andres Caicedo's profile - activity

2019-02-05 10:47:10 +0200 received badge  Famous Question (source)
2018-03-14 20:29:52 +0200 received badge  Famous Question (source)
2017-12-15 19:28:40 +0200 received badge  Notable Question (source)
2016-09-16 08:32:33 +0200 received badge  Popular Question (source)
2015-08-10 05:49:11 +0200 received badge  Notable Question (source)
2013-11-07 20:31:56 +0200 commented question defining periodic functions

The link you gave does not seem to be working anymore. The current location seems to be [here](http://innovation.it.uts.edu.au/projectjmc/articles/weierstrass/weierstrass.pdf).

2013-10-09 19:55:26 +0200 received badge  Notable Question (source)
2013-10-03 22:22:47 +0200 received badge  Popular Question (source)
2012-05-31 22:32:41 +0200 received badge  Popular Question (source)
2012-02-21 23:19:21 +0200 commented answer Thickness of points in plots

Many thanks! This is certainly much cleaner.

2012-02-21 19:15:03 +0200 marked best answer Thickness of points in plots

By thinkness of points, I assume you mean the size (radius) of the points. Use the argument size to change the size of the points.

list_plot(N,size=1).show()
2012-02-21 19:14:56 +0200 commented answer Thickness of points in plots

Ha! This certainly does it. Thanks! I stubbornly kept trying variations of "thick".

2012-02-21 18:04:30 +0200 marked best answer Graphing derivatives of implicitly given functions

Unfortunately, this is pretty hard to do in Sage. Even this attempt (eventually) fails:

sage: y = function('y',x)
sage: f = y*x==1; f
x*y(x) == 1
sage: f.derivative(x)
x*D[0](y)(x) + y(x) == 0
sage: g = f.derivative(x)
sage: g.operands()[0].operands()[0].operands()[1]
D[0](y)(x)
sage: h = g.solve(g.operands()[0].operands()[0].operands()[1])[0]; h
D[0](y)(x) == -y(x)/x
sage: implicit_plot(h.rhs(),(x,-1,1),(y,-1,1))
<boom>

I don't know that this is easy to fix in general, either, because of course derivatives in implicit functions can be arbitrarily complicated to solve for, and so not necessarily accessible to a computer method. I don't think there are any numerical methods for doing this.

2012-02-21 17:56:45 +0200 asked a question Thickness of points in plots

How can I change the thickness of points in a graph?

In case it is not clear what I mean, consider the following program, illustrating Chebyshev's bias:

var('N')
N=[]
l=0
k=7
for p in prime_range(10^k+1):
    if (p==2):
        N.append(0)   
    else:
        if (Mod(p,4)==1):
            N.append(N[l]-1)
            l=l+1
        else:
            N.append(N[l]+1)
            l=l+1
list_plot(N).show()

(Sorry, I cannot yet upload graphs, but you may quickly run this example and see that:) The dots seem too thick to rally appreciate any fine features of the graph. Is there a way to make the dots smaller (thinner)?

2011-02-02 22:46:55 +0200 received badge  Good Question (source)
2011-02-02 09:32:59 +0200 received badge  Nice Question (source)
2011-01-30 13:58:31 +0200 received badge  Student (source)
2011-01-30 02:41:42 +0200 received badge  Supporter (source)
2011-01-29 17:10:11 +0200 asked a question Graphing derivatives of implicitly given functions

Sorry if this is too elementary.

I want to graph the derivative of a function y that is given implicitly as a function of x. I would appreciate any suggestions.

2010-10-14 23:11:10 +0200 received badge  Scholar (source)
2010-10-14 23:11:10 +0200 received badge  Autobiographer
2010-09-17 02:01:26 +0200 commented answer Comparing lists

Thank you! I suspected there was something like issubset, but didn't about about itertools.imap or all.

2010-09-17 01:59:02 +0200 marked best answer Comparing lists

You can use a brute-force search by defining your own custom function. This option doesn't assume that elements in your list are unique. Your lists can contain duplicate elements if you want.

sage: def is_sublist(shortlist, longlist):
....:     for e in shortlist:
....:         if not (e in longlist):
....:             return False
....:     return True
....: 
sage: L = [2, 5, 23]
sage: P = primes_first_n(20); P
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
sage: is_sublist(L, P)
True
sage: L + [23]
[2, 5, 23, 23]
sage: is_sublist(L + [23], P)
True
sage: L.append(next_prime(P[-1])); L
[2, 5, 23, 73]
sage: is_sublist(L, P)
False
sage: is_sublist(L + [23], P)
False

Alternatively, you can use the built-in functions itertools.imap and all. The function itertools.imap is efficient when your lists are large, e.g. having hundreds or even hundreds of thousands of elements. This second option doesn't care if your lists have duplicate elements.

sage: import itertools
sage: L = [2, 5, 23]
sage: P = primes_first_n(20); P
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
sage: L + [23]
[2, 5, 23, 23]
sage: all(itertools.imap(lambda x: x in P, L))
True
sage: all(itertools.imap(lambda x: x in P, L + [23]))
True
sage: L.append(next_prime(P[-1])); L
[2, 5, 23, 73]
sage: all(itertools.imap(lambda x: x in P, L))
False
sage: all(itertools.imap(lambda x: x in P, L + [23]))
False

Or, as Mitesh Patel said, you could use set. This third approach assumes that the elements in each list are unique, i.e. each list doesn't contain duplicate elements.

sage: L = [2, 5, 23]
sage: P = set(primes_first_n(20))
sage: set(L)
set([2, 5, 23])
sage: set(L).issubset(P)
True
sage: set(L + [23])
set([2, 5, 23])
sage: set(L + [23]).issubset(P)
True
sage: L.append(111); L
[2, 5, 23, 111]
sage: set(L)
set([2, 111, 5, 23])
sage: set(L + [111])
set([2, 111, 5, 23])
sage: set(L + [111]).issubset(P)
False
sage: set(L).issubset(P)
False
2010-09-15 03:27:20 +0200 asked a question Comparing lists

This is probably too basic. If so, I apologize (where should I look for questions like this, if that is the case?). (And I'm not sure I chose the right tag either...)

How do I check all the members of a list are contained in another list? Specifically, I'm interested in lists that consist of (prime) numbers. Perhaps there is a more efficient method in this case?