[sage-support] Random sum of functions

2013-07-17 Thread Laurent Decreusefond
Hi everyone,

say I have a function of both an integer n and a complex z

def f(n,z):
 return z**n

For any tuple of integer (a_1,a_2, ..., a_k), (actually, k and a_i are 
random), I want to form the function 

z - sum_{i=1}^k |f(a_i, z)|^2

The result must still be a function. I guess it is something which can be 
done by redefining a new class but I'm a totally newbie at object 
programming.
Can you help me ?

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-support] Longest Common Subsequence

2013-07-17 Thread Nathann Cohen
Helloo everybody !!!

Is there a way to compute the longest common subsequence of two
(binary) words in Sage ? I can't find how, but it looks like something
Sage should be able to do :-)

Thaanks !

Nathann

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Random sum of functions

2013-07-17 Thread D. S. McNeil
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
:

After which

sage: f(1, 3+2*I)
2*I + 3
sage: maker((1,5,3))
function __main__.g
sage: g = maker((1,5,3))
sage: g(5)
9781275
sage: abs(f(1,5))**2 + abs(f(5,5))**2 + abs(f(3,5))**2
9781275

I used Python functions here because that's what you started with.  A
similar approach would have worked if you were making a Sage function
instead, namely write a function which accepts a tuple and returns a new
function.


Doug


On Wed, Jul 17, 2013 at 5:07 AM, Laurent Decreusefond 
laurent.decreusef...@gmail.com wrote:

 Hi everyone,

 say I have a function of both an integer n and a complex z

 def f(n,z):
  return z**n

 For any tuple of integer (a_1,a_2, ..., a_k), (actually, k and a_i are
 random), I want to form the function

 z - sum_{i=1}^k |f(a_i, z)|^2

 The result must still be a function. I guess it is something which can be
 done by redefining a new class but I'm a totally newbie at object
 programming.
 Can you help me ?

  --
 You received this message because you are subscribed to the Google Groups
 sage-support group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to sage-support+unsubscr...@googlegroups.com.
 To post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Re: Trouble with easy_install

2013-07-17 Thread Viviane Pons
Thank's, indeed I went thought the all thing and now it works!


2013/7/17 P Purkayastha ppu...@gmail.com

 On 07/16/2013 05:35 PM, Viviane Pons wrote:

 Hi everyone,

 I have installed sage-5.11-beta3 and for some reason, I cannot use use
 easy_install anymore on the sage shell. It seems to be a problem with
 https. When I do sage -sh and then easy_install -U mysql-python (for
 example), I get this:

 Reading 
 http://pypi.python.org/simple/**mysql-python/http://pypi.python.org/simple/mysql-python/
 Download error: unknown url type: https -- Some packages may not be found!

 I don't remember if I had this error before. But I'm sure I was able to
 install this package with easy_install on previous sage versions. Did
 anyone have some similar issues?

 Thank's a lot

 Viviane


 Make sure you have support for SSL installed. The details are present in
 the SSL section of the README.txt file in the Sage directory.



 --
 You received this message because you are subscribed to the Google Groups
 sage-support group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to 
 sage-support+unsubscribe@**googlegroups.comsage-support%2bunsubscr...@googlegroups.com
 .
 To post to this group, send email to sage-support@googlegroups.com.
 Visit this group at 
 http://groups.google.com/**group/sage-supporthttp://groups.google.com/group/sage-support
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Random sum of functions

2013-07-17 Thread Anton Sherwood

On 2013-7-17 02:07, Laurent Decreusefond wrote:

For any tuple of integer (a_1,a_2, ..., a_k),  [...]
I want to form the function

z - sum_{i=1}^k |f(a_i, z)|^2


Won't this work?

def ff(atuple,z):
return sum([ abs(f(n,z))**2 for n in atuple ])

--
*\\*  Anton Sherwood  *\\*  www.bendwavy.org

--
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Digest for sage-support@googlegroups.com - 5 Messages in 3 Topics

2013-07-17 Thread Carl Eberhart
Hi Nathann
Here is a Wikipedia article with what looks very much like the python code
for a solution.
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
Carl


On Wed, Jul 17, 2013 at 12:11 PM, sage-support@googlegroups.com wrote:

   Today's Topic Summary

 Group: http://groups.google.com/group/sage-support/topics

- Trouble with easy_install #13fed9de1076cc45_group_thread_0 [2
Updates]
- Random sum of functions #13fed9de1076cc45_group_thread_1 [2
Updates]
- Longest Common Subsequence #13fed9de1076cc45_group_thread_2 [1
Update]

   Trouble with 
 easy_installhttp://groups.google.com/group/sage-support/t/a269e0b629942f70

P Purkayastha ppu...@gmail.com Jul 17 01:22PM +0800

On 07/16/2013 05:35 PM, Viviane Pons wrote:
 anyone have some similar issues?

 Thank's a lot

 Viviane

Make sure you have support for SSL installed. The details are present
in
the SSL section of the README.txt file in the Sage directory.




Viviane Pons vivianep...@gmail.com Jul 17 03:13PM +0200

Thank's, indeed I went thought the all thing and now it works!


2013/7/17 P Purkayastha ppu...@gmail.com




   Random sum of 
 functionshttp://groups.google.com/group/sage-support/t/15e2f9ba3e321f12

Laurent Decreusefond laurent.decreusef...@gmail.com Jul 17 02:07AM
-0700

Hi everyone,

say I have a function of both an integer n and a complex z

def f(n,z):
return z**n

For any tuple of integer (a_1,a_2, ..., a_k), (actually, k and a_i are
random), I want to form the function

z - sum_{i=1}^k |f(a_i, z)|^2

The result must still be a function. I guess it is something which can
be
done by redefining a new class but I'm a totally newbie at object
programming.
Can you help me ?




D. S. McNeil dsm...@gmail.com Jul 17 08:19AM -0400

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
:

After which

sage: f(1, 3+2*I)
2*I + 3
sage: maker((1,5,3))
function __main__.g
sage: g = maker((1,5,3))
sage: g(5)
9781275
sage: abs(f(1,5))**2 + abs(f(5,5))**2 + abs(f(3,5))**2
9781275

I used Python functions here because that's what you started with. A
similar approach would have worked if you were making a Sage function
instead, namely write a function which accepts a tuple and returns a
new
function.


Doug


On Wed, Jul 17, 2013 at 5:07 AM, Laurent Decreusefond 



   Longest Common 
 Subsequencehttp://groups.google.com/group/sage-support/t/89f9b8e98fbbfab7

Nathann Cohen nathann.co...@gmail.com Jul 17 12:29PM +0200

Helloo everybody !!!

Is there a way to compute the longest common subsequence of two
(binary) words in Sage ? I can't find how, but it looks like something
Sage should be able to do :-)

Thaanks !

Nathann



  --
 You received this message because you are subscribed to the Google Groups
 sage-support group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to sage-support+unsubscr...@googlegroups.com.
 To post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-support] Error summing inverses of binomial coefficients

2013-07-17 Thread Ed Scheinerman
I am looking to evaluate $\sum_{k=0}^n 1/\binom{n}{k}$ so I type:

sage: n = var('n')
sage: k = var('k')
sage: sum(1/binomial(n,k),k,0,n)
(n + 1)*2^(-n)

and that answer is wrong.

For example, with n=10 we get

sage: sum(1/binomial(10,k) for k in range(11))
1433/630

but the alleged answer of (n+1)*2^(-n) is 11/1024.

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.