Clear[Evaluate[Context[]<>"*"]]

u[x_]:=Exp[x];
uinv[x_]:=Log[x];
f[u_]:=Cos[u];
a=0;
b=Log[3Pi];

Manipulate[
With[
{ugap=(u[b]-u[a])/n},
{
Show[
Plot[f[t],{t,u[a],u[b]},AxesLabel->{u,"f(u)"}],
Graphics[Join[{EdgeForm[{Thick,Blue}],Opacity[0.5],Blue},Flatten@Table[With[{max=NMaximize[{f[t],x≤t≤x+ugap},t]},{Point[{max[[2,1,2]],max[[1]]}],Rectangle[{x,0},{x+ugap,max[[1]]}]}],{x,u[a],u[b],ugap}]]]],
Show[
Plot[f[u[t]],{t,a,b},AxesLabel->{x,"f(u(x))"},ColorFunction->(Red&)],
Graphics[Join[{EdgeForm[{Thick,Red}],Opacity[0.5],Red},Flatten@Table[With[{max=NMaximize[{f[u[t]],uinv[x]≤t≤uinv[x+ugap]},t]},{Point[{max[[2,1,2]],max[[1]]}],Rectangle[{uinv[x],0},{uinv[x+ugap],max[[1]]}]}],{x,u[a],u[b],ugap}]]]],
Show[
Plot[uinv[x],{x,u[a],u[b]},AxesLabel->{x,"(u^(-1))"},PlotStyle->Thin],
Graphics[Join[
{Black,Dashed,Thin},
Flatten@Table[{Line[{{x,0},{x,uinv[x]}}],Line[{{x,uinv[x]},{0,uinv[x]}}]},{x,u[a],u[b],ugap}],
{Dashing[{}],Thick},Flatten@({Blue,Line[{#[[1]],{#[[2,1]],#[[1,2]]}}],Red,Line[{{#[[2,1]],#[[1,2]]},#[[2]]}],Orange,Line[#]}&/@Table[{#[[j-1]],#[[j]]},{j,2,Length[#]}]&@Table[{x,uinv[x]},{x,u[a],u[b],ugap}])]]
]
}],{n,1,20,1}]