Re: HW 7

0 views
Skip to first unread message

William Stein

unread,
May 21, 2009, 1:24:57 AM5/21/09
to Chad Jerde, 480-uw09
On Wed, May 20, 2009 at 10:01 PM, Chad Jerde <cha...@u.washington.edu> wrote:
> Professor Stein,
>
> I am having a little trouble with a few of the homework problems.
>
> Number 2 part 1 I am unable to get the given function:
>
> *Composition(n).cardinality()
>
> to work.  It says :*
>
> AttributeError: 'Composition_class' object has no attribute
> 'cardinality'
>
> So I am not sure what the issue is.

Here is an example of using the Compositions function:

sage: Compositions(10).cardinality()
512


>
> Also I am a little confused about exactly what a poset is and what the
> question is asking me to do.  Thanks for your help.

Type "Poset?" in Sage to learn more about how to use posets in Sage.
Also read this article:

http://en.wikipedia.org/wiki/Partially_ordered_set

William

William Stein

unread,
May 21, 2009, 2:33:40 AM5/21/09
to Chad Jerde, 480-uw09
On Wed, May 20, 2009 at 11:25 PM, Chad Jerde <cha...@u.washington.edu> wrote:
> Thanks for your help on my previous question.  Also for problem 2 part 4 I
> attempted to verify the identity using the following two code snippets and
> looking at there output.  They appear to be drastically different.
>
> left=0;
> for n in range (0,10):
>   left =left + Partitions(n).cardinality()*x^n
> print ans

>
>
> right=1
> for k in range (1,11):
>   k *= (1/(1 - x^k))
> print k

There is a bug in the loop. You are assigning to k each time (where
it says "k *= "), but should be assigning to right (which you never
use), e.g.,
right *= ...

William

>
> Am I taking the correct approach?
>
> Chad

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

Reply all
Reply to author
Forward
0 new messages