MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Inverse of arbitrary functions

  • To: mathgroup at
  • Subject: [mg74541] Re: Inverse of arbitrary functions
  • From: Bill Rowe <readnewsciv at>
  • Date: Sun, 25 Mar 2007 01:25:41 -0500 (EST)

On 3/23/07 at 7:06 PM, dave.rudolf at (Dave Rudolf) wrote:

>Is there some way to get Mathematica to find the symbolic inverse of
>a user-defined function? I know that I can use InverseFunction to
>find the inverse of simple functions, like so:

>InverseFunction[Log] -> Exp

>However, I would like to do something like

>f[ x_ ] = x + sin[ x + cos[ x ] ]

>InverseFunction[ f ]

There is no inverse function for the function you gave above.
So, it isn't possible for Mathematica to produce a symbolic
inverse function for this particular example.

And in general, it is quite easy to create functions for which
there is no symbolic inverse function. Consequently, it should
not be surprising Mathematica is unable to do this.

>I did run across a similar newsgroup post that said to use the Solve
>function, like so:

>inverse[f_, x_] /; PolynomialQ[f, x] && Not[FreeQ[f, x]] :=
>Module[{y}, Solve[f == y, x][[1, 1, 2]] /. y -> x]

>However, it doesn't seem to work as is, and I don't understand the
>syntax of some of the stuff. Like, what's with the -> symbol? And \;
>for that matter?

You can figure out the meaning of the various symbols by making
use of the Help Browser to look them up

The "->" defines a replacement rule. In this code segment, it
simply replaces instances of y with x.

The "/;" defines a conditional. In this code, it restricts
application of the function (Inverse) being defined to
polynomials in x. The PolynmialQ[f, x] checks f is a polynomial
in x. And the Not[FreeQ[f,x]] checks that f is an expression of x.

Since your function above isn't a polynomial of x, the result
returned will simply be what you inputed.

You can create a numerical inverse function for the function you
gave above. There are two basic approaches. One would be to
build up a table of f[x],x values and use interpolation. The
other would be to use something like FindRoot to numerically
solve for the inverse value. An example of this approach would be:

g[(x_)?NumericQ] := Block[{y},
    y /. FindRoot[x == y + Sin[y + Cos[y]], {y, 0, 2*Pi}]]

Of course, either of these approaches means creating a specific
function for each numeric inverse function you want.
To reply via email subtract one hundred and four

  • Prev by Date: Re: Re: Which Mathematica product should I get?
  • Next by Date: Re: Definite Integration in Mathematica
  • Previous by thread: Re: including part of files ?
  • Next by thread: Self-teaching snag