Re: How to invert a function

• To: mathgroup at smc.vnet.net
• Subject: [mg81179] Re: How to invert a function
• From: Bill Rowe <readnewsciv at sbcglobal.net>
• Date: Fri, 14 Sep 2007 03:47:55 -0400 (EDT)

```On 9/13/07 at 6:24 AM, jwheeler51 at gmail.com (Teodoro) 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 !

This really shouldn't be surprising. What really should be
surprising is that you get anything other than error messages.
Consider what you are asking keeping in mind Solve is designed

=46or your first f you have m Exp[p y] which is easily inverted
using Log, i.e.,

In[26]:= Solve[m Exp[p y] == x, y]

Out[26]= {{y -> Log[x/m]/p}}

works and simply gives you a warning about using inverse functions

Now try

Solve[m Exp[p y] + n Exp[q y] + r == x, y]

and you will get an error message saying in essence there is no
symbolic solution for y possible. That is you need to use
numeric techniques here

There are a number of functions available in Mathematica to do
this, such as NSolve or FindRoot. Note FindRoot would be the
better choice for this function.
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: FrameTicks lengths
• Next by Date: Re: Re: Anomalous behaviour of Penrose Triangle Demonstration
• Previous by thread: Re: How to invert a function
• Next by thread: Joint Histogram