ClearAll[f, g]
f = ConditionalExpression[(1/27)*(#^4 - 6 #^3 + 12 #^2 + 19 #), 0 <= # <= 5] &;
g = InverseFunction[f];
Grid[Partition[#, 2] &[Plot[#, {x, 0, #2}, PlotLabel -> #3, ImageSize -> 300] & @@@
{{f[x], 5, "f[x]"}, {g[x], 10, "g[x]"},
{{f[x], g[x]}, 5, "{f[x], g[x]}"}, {f[x] - g[x], 5, "f[x]- g[x]"}}]]
Update: You can also use ParametricPlot
to plot f
, g
and f-g
:
ParametricPlot[{{x, f[x]}, {f[x], x}, {x, f[x] - g[x]}}, {x, -1, 5},
BaseStyle -> Thick, Frame -> True, PlotStyle -> (c = {Red, Blue, Green}),
PlotLegends -> LineLegend[c, {"f[x]", "g[x]", "f[x]-g[x]"}, BaseStyle -> Thick]]