Results 1 to 2 of 2

Math Help - Filling graphics in Mathematica

  1. #1
    Senior Member bkarpuz's Avatar
    Joined
    Sep 2008
    From
    R
    Posts
    481
    Thanks
    2

    Exclamation Filling graphics in Mathematica

    Dear friends hi again,

    I am using the following code:
    Code:
    Manipulate[Plot[{p-Floor[k]^Floor[k]/(Floor[k]+1)^(Floor[k]+1)(Floor[k]-1),1,0},{p,0,2},PlotRange->{{0,2},{0,2}}],{k,1,10}]
    The code above gives the following graphic:

    My first question is how can I fill the graphic in the following form:

    And the second question is how can I plot the following graphic?

    Or simply, how can I put the graph of x=1 into the first graph?

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member bkarpuz's Avatar
    Joined
    Sep 2008
    From
    R
    Posts
    481
    Thanks
    2

    Exclamation

    I could do what I wanted with the following codes, I am giving them below.
    Code:
    kmax = 10;
    Manipulate[
     Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
      Graphics[{Cyan, 
        Polygon[{{2, 0}, {k^k/(k + 1)^(k + 1) (k - l), 
           0}, {1 + k^k/(1 + k)^(k + 1) (k - l), 1}, {2, 1}}]}]], {k, 1, 
      kmax, 1}, {l, 0, k - 1, 1}]
    Manipulate[
     Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
      Graphics[{Magenta, Line[{{1, 1}, {2, 1}}]}]], {k, 1, kmax, 1}, {l, 
      0, k - 1, 1}]
    Manipulate[
     Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
      Graphics[Table[If[s == k - l, Line[{{1, 1}, {2, 1}}], If[s == 0,
          Line[{{1, 0}, {1, 1}}], 
          Line[{{1, 1}, 
            If[(k - l)/(k - l - s) > 2, {2, (2 s - k + l)/s}, {(k - l)/(
              k - l - s), 0}]}]]], {s, 0, k - l}]]], {k, 1, kmax, 1}, {l, 
      0, k - 1, 1}]
    Manipulate[
     Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
      Graphics[{Magenta, Polygon[{{2, 0}, {1, 0}, {1, 1}, {2, 1}}]}]], {k,
       1, kmax, 1}, {l, 0, k - 1, 1}]
    And all in one version
    Code:
    kmax = 10;
    Manipulate[
     Show[If[c == 1, 
       Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
        Graphics[{Cyan, 
          Polygon[{{2, 0}, {k^k/(k + 1)^(k + 1) (k - l), 
             0}, {1 + k^k/(1 + k)^(k + 1) (k - l), 1}, {2, 1}}]}]], 
       If[c == 2, 
        Show[Graphics[{White, Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}],
          Graphics[{Cyan, 
           Polygon[{{2, 0}, {k^k/(k + 1)^(k + 1) (k - l), 
              0}, {1 + k^k/(1 + k)^(k + 1) (k - l), 1}, {2, 1}}]}], 
         Graphics[{Magenta, Line[{{1, 1}, {2, 1}}]}]], 
        If[c == 3, 
         Show[Graphics[{White, 
            Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
          Graphics[{Cyan, 
            Polygon[{{2, 0}, {k^k/(k + 1)^(k + 1) (k - l), 
               0}, {1 + k^k/(1 + k)^(k + 1) (k - l), 1}, {2, 1}}]}], 
          Graphics[
           Table[If[s == k - l, Line[{{1, 1}, {2, 1}}], If[s == 0,
              Line[{{1, 0}, {1, 1}}], 
              Line[{{1, 1}, 
                If[(k - l)/(k - l - s) > 2, {2, (2 s - k + l)/s}, {(
                  k - l)/(k - l - s), 0}]}]]], {s, 0, k - l}]]], 
         Show[Graphics[{White, 
            Polygon[{{2, 0}, {0, 0}, {0, 1}, {2, 1}}]}], 
          Graphics[{Cyan, 
            Polygon[{{2, 0}, {k^k/(k + 1)^(k + 1) (k - l), 
               0}, {1 + k^k/(1 + k)^(k + 1) (k - l), 1}, {2, 1}}]}], 
          Graphics[{Magenta, 
            Polygon[{{2, 0}, {1, 0}, {1, 1}, {2, 1}}]}]]]]]], {k, 1, kmax,
       1}, {l, 0, k - 1, 1}, {c, 1, 4, 1}]
    Is there a way to simplify the latter code?

    Thanks.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 0
    Last Post: August 17th 2011, 08:42 AM
  2. Pipe Filling
    Posted in the Algebra Forum
    Replies: 2
    Last Post: February 28th 2011, 10:03 AM
  3. Replies: 1
    Last Post: March 22nd 2010, 10:14 AM
  4. Replies: 0
    Last Post: March 7th 2010, 06:49 AM
  5. Filling in table
    Posted in the Algebra Forum
    Replies: 16
    Last Post: October 5th 2009, 12:57 PM

Search Tags


/mathhelpforum @mathhelpforum