# \[GIF\] Square and Triangle Curve Shortening Flows

**URL:** <https://community.wolfram.com/t/gif-square-and-triangle-curve-shortening-flows/11678>\
**Category:** Ideas\
**Tags:** physics, computational-arts, algebra, calculus, geometry, graphics-and-visualization\
**Created:** [December 15, 2017, 7:53pm UTC](https://community.wolfram.com/t/gif-square-and-triangle-curve-shortening-flows/11678 "2017-12-15T19:53:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradklee](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/bradklee/32/16606_2.png) [@bradklee](https://community.wolfram.com/u/bradklee)\
**Post date:** [December 15, 2017, 7:53pm UTC](https://community.wolfram.com/t/gif-square-and-triangle-curve-shortening-flows/11678/1 "2017-12-15T19:53:57Z")

</div>

A few months ago, the thread [Circle Morphing into a triangle](https://wolfram.discourse.group/t/11478/1) came up. This thread falls short of discussing curvature flows, including the famous curve shortening flow. This is an important topic, leading to the more general Ricci flow, [as discussed by Jim Isenberg on Numberfile.](https://www.youtube.com/watch?v=hwOCqA9Xw6A) The purpose of this thread is to elaborate upon the earlier calculations by deforming square and triangle elliptic curves into circles, while preserving the interior area. As discussed elsewhere, the circle solves [Dido’s problem](http://mathworld.wolfram.com/DidosProblem.html), to enclose maximum area by the least amount of cow’s hide. Thus an area-preserving flow ending with a circle, by reverse logic, will usually be a _curve lengthening flow_. This can be proven rigorously for the two examples here by integrating the perimeter as a Fourier series expansion. Building upon the earlier humorous [Arrival thread](https://wolfram.discourse.group/t/10179/1) , future posts may explore seemingly obvious connections between elliptic curves and Zen drawings, especially Sengai’s drawing, sometimes called “Circle, Triangle, Square”, as seen on the cover of [“The Zen Art Book”](https://books.google.com/books?id=5CbJhbj0nNYC&printsec=frontcover&dq=the%20art%20of%20zen&hl=en&sa=X&ved=0ahUKEwj_5oPc3IzYAhXq5oMKHVMhDQwQ6AEIQDAE#v=onepage&q=the%20art%20of%20zen&f=false) . Additional information about these calculations will eventually be made available in the form of a more serious article.

## Curve Parameterizations and Areas

```
Quartic\[Phi]0 = ArcSin[Sqrt[4 \[Alpha] \[CapitalPhi]]]/2;
QuarticF[1] = 1/Sqrt[\[CapitalPhi]] Cos[Quartic\[Phi]0 - Pi/2];
QuarticF[2] = 1/Sqrt[\[CapitalPhi]] Cos[Quartic\[Phi]0];

Cubic\[Phi]0 = (2/3) ArcSin[3 Sqrt[3] x/2];
CubicF[n_] := 
 Sqrt[\[Alpha]] Divide[1 + 2 Cos[Cubic\[Phi]0 - n 2 Pi/3], 3 x] /. {
   x -> Sqrt[\[Alpha] ] \[CapitalPhi]}

A3 = \[Alpha] Hypergeometric2F1[1/3, 2/3, 2, 27 \[Alpha]/4];
A4 = \[Alpha] Hypergeometric2F1[1/2, 1/2, 2, \[Alpha]];

```

## Triangle Animation: “? Grow And Flow ?”

```
TriangleGrow = PolarPlot[{
      1, Evaluate[
       Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] -> 
          Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], Evaluate[
       Sqrt[1/A3 /. {\[Alpha] -> 4/27}] CubicF[1] /. \[CapitalPhi] -> 
          Cos[3 \[Phi]] /. {\[Alpha] -> #/1000 (4/27)}]}, {\[Phi], 0, 
      2 Pi}, PlotRange -> {{-2, 2}, {-2, 2}},
     PlotStyle -> {Gray, Gray, Directive[Thick, Black]}, 
     Axes -> False] & /@ (10 Range[0, 100]);

TriangleFlow = PolarPlot[{
      1, Evaluate[
       Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] -> 
          Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], Evaluate[
       Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] -> 
          Cos[3 \[Phi]] /. {\[Alpha] -> #/1000 (1/27)}]}, {\[Phi], 0, 
      2 Pi},
     PlotRange -> {{-2, 2}, {-2, 2}}, 
     PlotStyle -> {Gray, Gray, Directive[Thick, Black]}, 
     Axes -> False] & /@ Reverse[10 Range[400]];

TriangleFinal = PolarPlot[{
    Evaluate[
     Sqrt[1/A3] CubicF[1] /. \[CapitalPhi] -> 
        Cos[3 \[Phi]] /. {\[Alpha] -> 4/27}], 1}, {\[Phi], 0, 2 Pi},
   PlotRange -> {{-2, 2}, {-2, 2}}, 
   PlotStyle -> {Gray, Directive[Thick, Black]}, Axes -> False];

TriangleGrowFlow = Join[TriangleGrow, Table[TriangleGrow[[-1]], {100}],
   TriangleFlow, Table[TriangleFinal, {100}]];

ListAnimate[TriangleGrowFlow];

```

![TriangleGrowFlow.gif](https://global.discourse-cdn.com/wolfram/original/3X/1/2/122f760708ddd3e125c6fdbc09b03c0403823ce2.gif)

[Youtube Video](https://www.youtube.com/watch?v=7a5Sw4nAoiA)

## Square Animation: “? Grow and Flow ?”

```
SquareGrow = PolarPlot[{
       1, 
       Evaluate[
        Sqrt[1/A4] QuarticF[
            1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], Evaluate[
        Sqrt[1/A4 /. {\[Alpha] -> 1}] QuarticF[
            1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> #/1000}]}, {\[Phi], 0, 2 Pi}, 
      PlotRange -> {{-2, 2}, {-2, 2}},
      PlotStyle -> {Gray, Gray, Directive[Thick, Black]}, 
      Axes -> False] & /@ (10 Range[0, 100]) // Quiet;

SquareFlow = PolarPlot[{
       1, 
       Evaluate[
        Sqrt[1/A4] QuarticF[
            1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], Evaluate[
        Sqrt[1/A4] QuarticF[
            1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> #/1000}]}, {\[Phi], 0, 2 Pi},
      PlotRange -> {{-2, 2}, {-2, 2}}, 
      PlotStyle -> {Gray, Gray, Directive[Thick, Black]}, 
      Axes -> False] & /@ Reverse[10 Range[100]] // Quiet;

SquareFinal = PolarPlot[{
     Evaluate[
      Sqrt[1/A4] QuarticF[
          
          1] /. \[CapitalPhi] -> (Cos[\[Phi]] Sin[\[Phi]])^2 /. {\
\[Alpha] -> 1}], 1}, {\[Phi], 0, 2 Pi},
    PlotRange -> {{-2, 2}, {-2, 2}}, 
    PlotStyle -> {Gray, Directive[Thick, Black]}, Axes -> False] // 
   Quiet;

SquareGrowFlow = Join[SquareGrow, Table[SquareGrow[[-1]], {100}],
   SquareFlow, Table[SquareFinal, {100}]];

ListAnimate[SquareGrowFlow]

```

![SquareGrowFlow.gif](https://global.discourse-cdn.com/wolfram/original/3X/d/8/d81766b8e5e1dcfa441ea7c316e93c56369ca6a9.gif)

[Youtube Video](https://www.youtube.com/watch?v=yEQ9j6Ub_Rc)
