Re: How to invert a function

*To*: mathgroup at smc.vnet.net*Subject*: [mg81163] Re: How to invert a function*From*: Teodoro <jwheeler51 at gmail.com>*Date*: Fri, 14 Sep 2007 03:39:36 -0400 (EDT)*References*: <fcb3f3$ff9$1@smc.vnet.net>

On Sep 13, 12:29 pm, Teodoro <jwheele... at gmail.com> wrote: > Hi, > this is my first post ro the Mathematica group, so, please be patient ... > The problem I'm trying to solve is a little bit more complex, but > anyway I was able to reproduce the unwanted behaviour using a "toy" example. > As far as I understand the fragment of code > > m = 7.984136668700428`*^-14; p = 38.64734299516908`; n = > 9.185777`*^-7; q = 7.729468599033817`; r = -9.18579746734159`*^-7; > f[y_] = m Exp[p y]; > g[x_] := Solve[f[y] == x, y] > h[x_] := y /. g[x] > > allows me to get y as a function of x. To check that h[x] is indeed > the inverse of f[y] (you already know the solution !) one can run > > Evaluate[f[h[z]]] > Evaluate[h[f[z]]] > > for any value of z you get again z: > > z -> h[z] -> f[h[z]=z > z -> f[z] -> h[f[z]=z > > or > > Plot[Evaluate[h[x]], {x, 1, 20}, PlotRange -> {Full}] > > and get a straight line. > However, when I try to invert > > f[y_] = m Exp[p y]+n Exp[q y]+r > > I get some result, but the result is WRONG ! > In another system I get the correct behaviour, even with more complex > functions ... > I can guess that somewhere in the answers I can get the one I need, > but the Forum is so immense ! > Thanks > Teodoro For anyone interested ... This fragment of code works perfectly. m=7.984136668700428*10^-14;p=38.64734299516908;n= 9.185777*^10-7;q=7.729468599033817;r=-9.18579746734159*^10-7; f[y_] = m Exp[p y] + n Exp[q y] + r g[x_] = Reduce[f[y] == x, y, Reals][[2]][[2]] Plot[f[y], {y, -1, 3}] Plot[g[x], {x, -1, 3}] Plot[g[f[x]], {x, -1, 3}, PlotRange -> All] Plot[f[g[x]], {x, -1, 3}, PlotRange -> All] I have to admit: it was not me to find the correct answer. Teodoro