{NotebookFileName[],DateString[]}

Square wave

style[
t_
]:=
Style[t,Bold,FontFamily->"Arial",FontSize->14]

Open and closed plot markers:

closedM[
size_:10
]:=
Graphics[Disk[],ImageSize->size]

closedM[]

openM[
size_:10
]:=
Graphics[Circle[],ImageSize->size]

openM[]

Show[
ListPlot[Range[0,10,2]
,PlotMarkers->openM[]
],
ListPlot[Range[1,10,2]
,PlotMarkers->closedM[]
]
]

Show[
Plot[UnitStep[x],{x,-1,1}
,PlotLegends->{"H(x)"}
,ExclusionsStyle->Dashed
],
ListPlot[{{0,1}}
,PlotMarkers->closedM[]
],
ListPlot[{{0,0}}
,PlotMarkers->openM[]
]
]

ones=Range[-3π,3π,π];
ones=Transpose[{ones,ConstantArray[1,Length[ones]]}]

zeros=Range[-3π,3π,π];
zeros=Transpose[{zeros,ConstantArray[0,Length[zeros]]}]

Show[
Plot[UnitStep[Sin[x]],{x,-3π,3π}
,Ticks->{Range[-3π,3π,π],Automatic}
,PlotLegends->{"H(sin(x))"}
,ExclusionsStyle->Dashed
],
ListPlot[ones
,PlotMarkers->closedM[]
],
ListPlot[zeros
,PlotMarkers->openM[]
]
]

Krogh tissue-cylinder model

Krogh, A. (1919). The number and distribution of capillaries in muscles with calculations of the oxygen pressure head necessary for supplying the tissue. J. Physiol. 52, 409–415.

Here’s the formula Krogh comes up with:

(Subscript[T, 0])-(Subscript[T, x])=(p/d)((1/2)(R^2)ln((x/r))-(((x^2)-(r^1))/4))

(Subscript[T, 0]) is oxygen tension in the capillary, (Subscript[T, x]) is oxygen tension at distance (radius) x from the capillary, r is the radius of the capillary. (x runs from r to R, the location at which another capillary takes over the supply. p is the “gas exchange”, i.e., the rate at which the tissue takes up oxygen, and d is the diffusion constant of oxygen in the tissue. The appearance of R in this formula indicates that it has already been adapted to have no diffusion past R.

Parameter values: (Subscript[d, 37])=0.164×(10^(-4))(cm^2)/min (37°C), (Subscript[d, 15])=0.133×(10^(-4))(cm^2)/min. As for p, Krogh writes, annoyingly, “p is the absorption of oxygen per (cm^3) per minute, and in the calculation given below I have taken the gas exchange of muscular tissue to be equal to that of the animal as a whole.” but without actually giving the number anywhere that I can see. However, I might be able to back it out from the calculated values.

({{□, Weight
(kg), Metabolism
cal per kg 
and hour, # capillaries 
per (mm^2) of 
striped muscle, R
(μm), Diam of red corpuscles
2r
(μm), (Subscript[T, 0])-(Subscript[T, R])
(mm Hg)}, {Cod, 1, 0.4, 400, 28, 8.5, 0.4}, {Frog, 0.04, 0.4, 400, 28, 15, 0.25}, {Horse, 500, 0.5, 1400, 15, 5.5, 0.1}, {Dog, 5, 3, 2500, 11.3, 7.2, 0.2}, {Guinea Pig, 0.5, 6, 3000, 10.3, 7.2, 0.3}})

This paper: http://web.eng.fiu.edu/~godavart/bme3032/Kroghs-Model.pdf had a derivation. He writes (13.5.1):

((Subscript[D, (Subscript[O, 2])])/r)(d/(dr))(r((d(Subscript[C, (Subscript[O, 2])]))/(dr)))=(Subscript[R, (Subscript[O, 2])])

ksol1=DSolve[(d/r)D[r D[c[r],r],r]==ro2,c,r][[1]]

(Subscript[R, (Subscript[O, 2])]) is apparently what Krogh called p. Then he gives boundary conditions (13.5.2a) and (13.5.2b):

At r=(Subscript[R, c]),       (Subscript[C, (Subscript[O, 2])])=(Subscript[C, (Subscript[R, c])])
At r=(Subscript[R, 0]),     -(Subscript[D, (Subscript[O, 2])])(((d(Subscript[C, (Subscript[O, 2])]))/(dr)))=0

His (Subscript[R, 0]) is Krogh’s R, and his (Subscript[R, c]) is Krogh’s r. (His r is Krogh’s x.)

Can I put that last boundary condition in a form that students can use?

c[r]/.ksol1

D[c[r]/.ksol1,r]/.r->r0

ksol2=Solve[(D[c[r]/.ksol1,r]/.r->r0)==0,C[1]][[1]]

c[rc]/.ksol1/.ksol2

ksol3=Solve[crc==c[rc]/.ksol1/.ksol2,C[2]][[1]]

c[r]/.ksol1/.ksol2/.ksol3//Simplify

(((c[r])/crc)/.ksol1/.ksol2/.ksol3)//Simplify

(((c[r])/crc)/.ksol1/.ksol2/.ksol3)==1+((ro2 (r0^2))/(4crc d))((((r^2)/(r0^2))-((rc^2)/(r0^2)))-2Log[(r/rc)])/.(Log[((a_)/(b_))]:>Log[a]-Log[b])//FullSimplify

Temperature gradient

Creating a radial gradient for measurement of thermotaxis. Standard scintillation vials have a diameter of 28 mm. Place one containing frozen acetic acid on the center of an upside-down 9 cm agar plate. The temp where the vial is in contact with the plate will be 16.7°C. The temp at the edge of the plate will be ambient temp. (Let’s say 25°C.) Between the temp will be linear with the log of the radius.

T(r)=({{{, ({{16.7°C, r≤14 mm}, {a+b ln(r), 14<r<45 mm}, {25°C, 45 mm ≤r}})}})

a + b Log[r]==T/.{{r->14,T->16.7},{r->45,T->25}}

subeq[
lhs1_==rhs1_,
lhs2_==rhs2_
]:=
lhs1-lhs2==rhs1-rhs2

subeq@@(a + b Log[r]==T/.{{r->14,T->16.7},{r->45,T->25}})

tsol1=Solve[a + b Log[r]==T/.{{r->14,T->16.7},{r->45,T->25}},{a,b}][[1]]

Clear[t1];
t1[
r_,
av_:a,
bv_:b,
rvial_:14.0,
rplate_:45.0,
tmin_:16.7,
tmax_:25.0
]:=
({{\[Piecewise], ({{tmin, Abs[r]≤rvial}, {a+b Log[Abs[r]], rvial<Abs[r]<rplate}, {tmax, True}})}})

t1[r]

t1[r,a,b]/.tsol1

Plot[t1[r,a,b]/.tsol1,{r,-60,60}
,AxesLabel->style/@{"r","T °C"}
,PlotRange->{All,{0,All}}
]

Root finding

Plot[(E^x)+Log[x],{x,0,1}]

f2[
x_
]:=
(E^x)+Log[x]

f2[0.5]

f2[0.25]

bisect[
{a_,b_,fv_},
f_:f2
]:=
Module[{m,fm},
m=N[((a+b)/2)];
fm=f[m];
If[fm<0,
{m,b,fm},
{a,m,fm}
]
]

bisect[{0,1,f2[0.5]}]

bisect[bisect[{0,1,f2[0.5]}]]

NestList[bisect,{0,1,f2[0.5]},10]

{((#[[1]]+#[[2]])/2),#[[3]]}&/@NestList[bisect,{0,1,f2[0.5]},10]

ListPlot[{((#[[1]]+#[[2]])/2),f2[((#[[1]]+#[[2]])/2)]}&/@NestList[bisect,{0,1,f2[0.5]},10]
,Joined->True
,Mesh->All
,PlotRange->{{0,All},All}
]

NestList[bisect,{0,1,f2[0.5]},10][[;;,3]]

ListPlot[NestList[bisect,{0,1,f2[0.5]},10][[2;;,3]]
,Joined->True
]

(NestList[bisect,{0,1,f2[0.5]},10][[;;,1]]+NestList[bisect,{0,1,f2[0.5]},10][[;;,2]])/2

f2@Last[(NestList[bisect,{0,1,f2[0.5]},10][[;;,1]]+NestList[bisect,{0,1,f2[0.5]},10][[;;,2]])/2]

ListPlot[(NestList[bisect,{0,1,f2[0.5]},10][[;;,1]]+NestList[bisect,{0,1,f2[0.5]},10][[;;,2]])/2
,Joined->True
,Mesh->All
]