I have the following piecewise continuous function:
myfun[a_, l1_, l2_] =
Piecewise[{{a^2, a < l1},
{a - l1 + l1^2, a >= l1 && a < l2},
{l2 - l1 + l1^2 + Log[a - l2 + 1], a >= l2}}]
The function is defined by a value $a$ and two parameters $l_1$ and $l_2$ and if I plot it, appears as:
Plot[Evaluate[myfun[a, l1, l2] /. {l1 -> 1.5, l2 -> 3.2}], {a, 0, 5}, PlotRange -> All]
Now, I would like to invert the numerical solution given by $myfun==2.0$ with respect to a, which is a function depending on $l_1$ and $l_2$. I tried to do it "in a delayed way" with
myInvFun[l1_, l2_] := x /. FindRoot[myfun[x, l1, l2] == 2.0, {l, 0}]
But this does not help me, since if I try to plot the following
Plot[Evaluate[myInvFun[l1, l2] /. {l2 -> 3.5}], {l1, 0, 3.5}]
errors appear:
How can I make the inverse function usable as an explicit function even if I use only a definition from numerical solution?
P.S. I had a look to answers like this one and this one but either way I could not find a way to solve my problem






