The Heart Model

Manipulate[
Column[{
Grid[{{"t",0,1,2,3,4,5,6,7},Join[{Subscript["V","t"]},NestList[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&,x0,7]]},Frame->All],
ListPlot[
      If[ drugi,
     {NestList[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&,x0,maxT],
     NestList[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&,If[x0+roz<0,0,If[x0+roz>1,1,x0+roz],x0+roz],maxT]},
       NestList[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&,x0,maxT]] ,
      PlotRange->{0,160},
      PlotStyle->{Directive[RGBColor[.6,.73,.36], PointSize[0.013]] ,If[drugi,RGBColor[1,.47,0], RGBColor[.6,.73,.36]]},
     DataRange->{0,maxT},
     ImageSize->{600,350},ImagePadding->30,AxesLabel -> {Style[t,Large,Bold,Blue],Style[Subscript["V","t"],Large,Bold,Blue]}
  ],
Show[Plot[{Piecewise[{{Exp[-α τ] x + u,x≤ V Exp[α τ]},{Exp[-α τ] x, x>V Exp[α τ]}}],Nest[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&, x,k],x}, {x,0,200}, PlotStyle -> Gray,Frame->True,PlotRange-> {{0,200},{0,200}},AspectRatio -> 1],Graphics[Flatten[MapIndexed[{Hue[#2[[1]] / n],Line[{{#,If[#==x0,0,#]},{#,Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]}}],
Line[{{#, Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]},{Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}], Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]}}]}  & ,NestWhileList[Piecewise[{{Exp[-α τ] # + u,#≤ V Exp[α τ]},{Exp[-α τ] #, #>V Exp[α τ]}}]&, x0, #1 ≠ Piecewise[{{Exp[-α τ] #2 + u,#2≤ V Exp[α τ]},{Exp[-α τ] #2, #2>V Exp[α τ]}}] &, 2, n]]]],ImageSize->{500,400},ImagePadding->{{20,10},{30,20}}
]
},Alignment->Center],
{{τ,1,"parameter τ"},0,2,0.1, Appearance->"Labeled"},
{{α,0.5,"parameter α"},0,10,0.1, Appearance->"Labeled"},
{{u,70,"parameter u"},0,100,1, Appearance->"Labeled"},
{{V,70,"parameter (Subscript[V, c])"},0,100,1, Appearance->"Labeled"},
{{x0,1,"initial value (Subscript[V, 0])"},0,5,1, Appearance->"Labeled"},
{{maxT, 50, "end time"}, 10, 100, 1, Appearance->"Labeled"},
{{drugi, False, "second solution?"}, {True, False}},
{{roz, 0, "difference h between initial values"}, -x0, 1-x0, 0.01, Appearance->"Labeled"},
{{n,100, "number of cobweb iterations"},1,200,1, Appearance -> "Labeled"},
{{k,1,"order of iterate in cobweb diagram"},{1,2,3,4,5,6}, ControlType -> Setter}
]

BASED ON THE NOTEBOOK:

"Discrete Logistic Equation" from The Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/DiscreteLogisticEquation/

Contributed by: Marek Bodnar

After work by: Phil Ramsden

Adapted by: Christopher Strickland (CSU 2010)