Dear @Steve Kilner, dear @Gianluca Gorni,
in my first reply above I used interpolation only to generate some (as I said) not necessarily analytic function. (Then reversing the points here would be somewhat "pointless".) Of course there is no need to do it like so in general when an inverse is wanted. And as you input an analytic expression it is certainly not necessary here. Without having looked at the code too closely, this modification seems to point into the right direction:
ClearAll[f, g, xx];
Manipulate[
f[xx_] := Evaluate[p /. x -> xx];
inv = InverseFunction[f];
l = Min[{f'[a], f'[b]}];
u = Max[{f'[a], f'[b]}];
Plot[NIntegrate[inv[x], {x, 0, m}], {m, -.99, .99},
PlotStyle -> Directive@{Yellow, Dashed},
AxesOrigin -> {0, 0}], {{p, Cos[x],
Text[Style[TraditionalForm["f(x)= "], Blue, Italic, 18]]},
ControlType -> InputField},
Row[{Control[{{a, -1.57,
Text[Style[TraditionalForm["a= "], Blue, Italic, 12]]},
InputField, ImageSize -> Tiny}],
Control[{{b, 1.57,
Text[Style[TraditionalForm["b= "], Blue, Italic, 12]]},
ControlType -> InputField, ImageSize -> Tiny}]}],
SynchronousUpdating -> True]
The problem now basically is the invertibility of Cos[x]
- for comparison try e.g. simply x
.