Author Topic: The one unforgivable sin is to be boring  (Read 2225 times)

0 Members and 1 Guest are viewing this topic.

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4766
  • Life teaches me not to want it.
    • What Now?
Re: The one unforgivable sin is to be boring
« on: August 06, 2017, 01:01:36 pm »
We are in synch, Holden.

In the video above, the guy stops short just before he had the opportunity to introduce a formula based on Pascal's Triangle.

In the following video, you will have to forgive the instructor for his sloppy hand writing and sometimes quirky way of speaking (as in, using the acronym "FOIL" as a verb and other idiosyncratic annoyances).  At first, the voice may conjure up images of the overbearing Hasidic Jew in the black and white film, PI, but you can tell he really loves math.

Unlike that character in PI, this guy eventually grows on you, becoming even amiable.  I especially like his genuine appreciation of Sage.  He is refreshingly enthusiastic about it.  This reinvigorates my interest in computer algebra systems.

What attracted me to his videos in the first place is I was curious to see how he would present Sage to high school students.

Strangely, I was viewing this video when you sent the above link.

Can I use the word "uncanny" here, or is the term "coincidence" more appropriate?

Skip through to about 7 minutes.

You are interested in patterns, and there is a cool pattern which includes the row and column of Pascal's triangle without actually having to write the entire triangle of numbers.  Probably in around 11 or 12 minutes he gets to the good shiit, Combinatorics:  (nCr).

Each row is identified by n, where the first row of Pascal's Triangle is n = 0, the second is n =1, etc, and each column "r" is r = 0 for first column, r =1 for second column, etc .

For example, 3C2 would correspond to the fourth row, third column.

You can find each coefficient in this manner.

All in all, there is no getting around the tedious drudgery involved ... which is why one can't help but appreciate Sage (free, as in free beer).  Observe how elegantly it constructs the following:

Copy this into a sagecell:

for n in range(10):
    show(expand((x+1)^n))

Note that, if the SageCell complains about a syntax error, it is very picky about spaces.  Backspace from show until it is just before the colon, :, and then hit enter so show(expand((x+1)^n)) is indented precisely with the s under the n.  That is, four spaces indented.



Maybe skip into 26 minutes at first.  You have to patient as the video is in real time, which means the instructor is assisting students with "technical difficulties" throughout the video.  The example is (3*x + 1)^4, and he shows the coefficients in terms of nCr, where nCr --->  (n   r)  [but vertical instead of horizontal, obviously]

nCr means (n!)/[r! * (n - r)!]

So, 5C2 means (5!)/[2! * 3!] = (5*4)/2 = 10

Notice the 3! = 3*2*1 in the denominator cancels out the 3*2*1 in 5! leaving 5*4 in the numerator.


----------------------------------------------------------------------------------
PS:  for (3*x + 1)^4
In Sage:

for n in range(4):
    show(expand((3*x+1)^n))

def combo(n,r):
    return factorial(n)/factorial(r)/factorial(n-r)

I like the way he divides twice instead of typing the denominator with parentheses and using multiplication:  factorial(n)/(factorial(r)*factorial(n-r))

As he points out, multiplication by a reciprocal is division, so it is cooler, I think to write it as double division ...

Cheap thrills, I know.   8)
---------------------------------------------------------------------------------------

On paper, how would you show the work?  What's the pattern?
Let nCr be represented by the defined function, combo(n, r)
To find binomial expansion of (3*x + 1)^4:

    combo(4,0) * (3*x)^4 * (1)^0
 + combo(4,1) * (3*x)^3 * (1)^1
 + combo(4,2) * (3*x)^2 * (1)^2
 + combo(4,3) * (3*x)^1 * (1)^3
 + combo(4,4) * (3*x)^0 * (1)^4

 = [4!/(0!*4!)] * 81*x^4 * 1
 + [4!/(1!*3!)] * 27*x^3 * 1
 + [4!/(2!*2!)] * 9*x^2 * 1
 + [4!/(3!*1!)] * 3*x * 1
 + [4!/(4!*0!)] * 1 * 1
 = 81*x^4 + 4 * 27*x^3 + 6 * 9 * x^2 + 4 * 3*x + 1
 = 81*x^4 + 108*x^3 + 54*x^2 + 12*x + 1

In sage:
combo(4,0) * (3*x)^4 * (1)^0 + combo(4,1) * (3*x)^3 * (1)^1 + combo(4,2) * (3*x)^2 * (1)^2 + combo(4,3) * (3*x)^1 * (1)^3 + combo(4,4) * (3*x)^0 * (1)^4

In a sagecell, copy and paste the following:

def combo(n,r):
    return factorial(n)/factorial(r)/factorial(n-r)

show( combo(4,0) * (3*x)^4 * (1)^0 + combo(4,1) * (3*x)^3 * (1)^1 + combo(4,2) * (3*x)^2 * (1)^2 + combo(4,3) * (3*x)^1 * (1)^3 + combo(4,4) * (3*x)^0 * (1)^4)


The pattern is

for r in range(5):
    combo(4,r) * (3*x)^(4 - r) * (1)^r

So this is a series (a + b)^n = Sum( combo(n,r) * a^(n - r) * b^r, r, 0, n)

The sum of combo(n, r) * a^(n - r) * b^r from r = 0 to r = n

I will take it one step further than MrG in the above video, and write the summation as sage code. Remember we have to define combo(n, r) and the variable r in the sagecell.

In Sage (for the binomial expansion of (3*x + 1)^4), where a = 3*x and b = 1 [n = 4]:

def combo(n,r):
    return factorial(n)/(factorial(r)*factorial(n-r))

r = var('r')
sum(combo(4,r) * (3*x)^(4 - r) * 1^r, r, 0, 4)


Copy this into a sagecell
« Last Edit: August 06, 2017, 09:36:58 pm by { { } } »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~