MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pascal's Triangle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37356] Re: Pascal's Triangle
  • From: "Borut L" <gollum at email.si>
  • Date: Fri, 25 Oct 2002 02:46:40 -0400 (EDT)
  • References: <ap86hf$554$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Helo,

I should thank you for this pleasent mind excercise, though not tough, it
was just basic geometry.

$TextStyle={FontFamily->Verdana,FontSize->10};

(* first create a basic object, a colored triangle with text inscribed, note
that the height of the triangle is a unit *)

Triangle[j_,i_]:=
  Module[
    {
      x0=(i-.5 j)2/Sqrt[3],y0=-j,a=2/Sqrt[3]
      },
    {
      If[EvenQ[Binomial[j,i]],Hue[0,.5,1],Hue[.55,.5,1]],
      Polygon[{{x0,y0},{x0-.5 a,y0-1},{x0+.5 a,y0-1}}],
      GrayLevel[0],Text[ToString[Binomial[j,i]],{x0,y0-.5},{0,1}]
      }
    ]

(* the following command will show the agglomerate, note that it doesn't
draw each of the triangles having no text, instead it draws a big triagle as
a background and puts the numbered ones onto it *)

ShowBigTriangle[jmax_]:=
  Show[
    Graphics[
      Prepend[
        Table[Triangle[j,i],{j,0,jmax},{i,0,j}],
        {Hue[0,.5,1],
Polygon[{{0,0},{-(jmax+1)/Sqrt[3],-(jmax+1)},{(jmax+1)/Sqrt[3],-(jmax+1)}}]}
        ]
      ]
    ,AspectRatio->Automatic
    ]

ShowBigTriangle[33]//Timing

(1.3 sec on my P2-350, how's your timming?)


p.s. : According to S. Wolfram and his new kind of science, the solution to
your problem is just a simple program. He ilustrates this in 2nd Chapter. It
may be worthy to take a peak.


Bye,

Borut


"Al Mannon" <almannon at attbi.com> wrote in message
news:ap86hf$554$1 at smc.vnet.net...
| I want to write a program that will create an array of equilateral
triangles
| such that in the first row there is 1 triangle, in the second row there is
3
| triangles, in the third row there will be 5 triangles...in the nth row
there
| will be 2n - 1 triangles. Putting all of these triangles together and
| calling the first row, row 0, we would have a large triangle with n + 1
rows
| along the side of the large triangle and 2n - 1 columns along the base of
| the triangle.
|
| This would be phase one of the project.
|
| Phase 2: Fill in the binomial coefficients into the triangle.
| Phase 3: Color all odd numbered triangles blue.
| Phase 4: Color all even numbered triangles red.
| Phase 5: Any triangle that shares an edge with a red triangle, color red.
|
| The result is Zierpinski's Triangle! I have done this by hand for a
triangle
| with 16 rows. Needless to say the work was tedious. The result, however,
is
| quite satisfying and remarkable. I would like to be able to use this as a
| tool to teach some of the other derivations that are possible from
Pascal's
| triangle other than binomial coefficients and combinations. Therefore it
| would be beneficial to be able to reproduce this work at will.
|
| Since my Mathematica programming skills are practically nil, any help
would
| be appreciated.
|
| I can be reached directly by electronic mail by deleting "the" in the
| following:
|
| althemannon at attbi.com
|
|




  • Prev by Date: Re: Re: PlotVectorField3D in Cylindrical Coordinates
  • Next by Date: Re: help on bootstrap sample
  • Previous by thread: Re: Pascal's Triangle
  • Next by thread: Re: Pascal's Triangle