Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

finding inverses of functions

230 views
Skip to first unread message

John Accardi

unread,
May 9, 2012, 3:51:26 AM5/9/12
to
Hello, I am trying to get Mathematica to find the inverse of:

y = 3x^3 + 2e^(2x) (which I know is invertible)

InverseFunction only seems to give inverses of built-ins, like Sine.

I tried:

Solve[ y == 3x^3 + 2e^(2x), x ] but get a message that Solve does not have methods suitable. (Solve works for simpler functions, however.)

Any ideas? Thanks.

Szabolcs Horvát

unread,
May 10, 2012, 5:02:14 AM5/10/12
to
While it's easy to see that this function has an inverse on the set of
reals, the inverse function might not be expressible using elementary
functions.

This doesn't prevent Mathematica from being able to compute the inverse
function to arbitrary precision at any point.

Let's write it as a pure function:

f = Function[x, 3 x^3 + 2 E^(2 x)]

Note that Exp[1] is written as E, and not as e.

The inverse of this function is represented in Mathematica with

if = InverseFunction[f]

Since you know that the inverse exists, you can use this confidently.
You can evaluate it for machine numbers like this:

In[63]:= if[1.]
Out[63]= -0.305526

Or for exact numbers like this:

In[64]:= if[1]
Out[64]= Root[{-1 + 2 E^(2 #1) + 3 #1^3 &,
-0.305526037783858835745318654576}]

Note that this is an exact result that can be evaluated to arbitrary
precision:

In[65]:= N[%, 100]
Out[65]=
-0.3055260377838588357453186545759642671712616849155334618731589419894350889720642702908817009965973507

I recommend reading this blog post:

http://blog.wolfram.com/2008/12/18/mathematica-7-johannes-kepler-and-transcendental-roots/

--
Szabolcs Horvát
Visit Mathematica.SE: http://mathematica.stackexchange.com/

Bob Hanlon

unread,
May 10, 2012, 5:02:45 AM5/10/12
to
f[x_] = 3 x^3 + 2 E^(2 x);

g = InverseFunction[f];

Plot[f[x], {x, 0, 1},
PlotRange -> {{0, 1}, {0, 20}}]

Plot[g[x], {x, f[0], f[1]},
PlotRange -> {{0, 20}, {0, 1}}]


Bob Hanlon

On Wed, May 9, 2012 at 3:50 AM, John Accardi <acc...@accardi.com> wrote:
> Hello, I am trying to get Mathematica to find the inverse of:
>
> y = 3x^3 + 2e^(2x) (which I know is invertible)
>
> InverseFunction only seems to give inverses of built-ins, like Sine.
>
> I tried:
>
> Solve[ y == 3x^3 + 2e^(2x), x ] but get a message that Solve does not=

Peter Breitfeld

unread,
May 10, 2012, 4:56:07 AM5/10/12
to
Because your function is trancendental you can't hope for a closed form.
But InverseFunction can be used:

f[x_] = 3 x^3 + E^(2 x)
g[y_] = InverseFunction[f][y]

Plot[f[x], {x, -2, 3}]
Plot[g[y], {y, -50, 250}]

--
_________________________________________________________________
Peter Breitfeld | Bad Saulgau, Germany | http://www.pBreitfeld.de

A Retey

unread,
May 10, 2012, 4:56:38 AM5/10/12
to
Am 09.05.2012 09:51, schrieb John Accardi:
> Hello, I am trying to get Mathematica to find the inverse of:
>
> y = 3x^3 + 2e^(2x) (which I know is invertible)

but do you know a symbolic solution? I think solving equations of this
type symbolically is difficult, if not impossible in general.

> InverseFunction only seems to give inverses of built-ins, like Sine.

InverseFunction works as designed for your case, it just doesn't provide
a simple symbolic expression. But this works as expected:

finv = InverseFunction[3 #^3 + 2 E^(2 #) &]

Plot[finv[x], {x, -10, 10}]

note that the InverseFunction object represents the inverse function
without the need to actually be able to determine a symbolic expression
in general. It can be used like any other function definition in most
functions that work with functions and they will return values when
given arguments. The same is true for InterpolatingFunction and
CompiledFunction objects.

In this case InverseFunction returns Root objects for exact numbers
(e.g. finv[1]) and floating point approximations for floating point
arguments (e.g. finv[1.]). Probably that's the best a computer program
can do for a general case like this. TI consider this the true power of
Mathematica :-)

hth,

albert

DrMajorBob

unread,
May 10, 2012, 4:58:10 AM5/10/12
to
In the first place, you probably meant:

Solve[y == 3 x^3 + 2 E^(2 x), x]

(E is the euler constant whereas e is an unknown symbol.)

But, sadly... Mathematica cannot solve that equation in general, and
neither can anyone else.

If YOU do, I think you'll quickly be famous.

Bobby

On Wed, 09 May 2012 02:50:21 -0500, John Accardi <acc...@accardi.com>
wrote:

> Hello, I am trying to get Mathematica to find the inverse of:
>
> y = 3x^3 + 2e^(2x) (which I know is invertible)
>
> InverseFunction only seems to give inverses of built-ins, like Sine.
>
> I tried:
>
> Solve[ y == 3x^3 + 2e^(2x), x ] but get a message that Solve does not
> have methods suitable. (Solve works for simpler functions, however.)
>
> Any ideas? Thanks.
>


--
DrMaj...@yahoo.com

djmpark

unread,
May 10, 2012, 5:03:46 AM5/10/12
to
An interesting problem. I'm going to take your "e" to be Exp. Let's define
the y function:

Clear[x, y];
y[x_] := 3 x^3 + 2 E^(2 x);

The function looks to be monotonically increasing.

Plot[y[x], {x, -2, 2}]

And we can verify it.

ForAll[x, D[y[x], x] > 0]
Resolve[%, Reals]
...
True

We will solve a differential equation and need an initial condition:

y[0]
2

Write the inverse slope in terms of x[y] and solve the differential
equation.

Clear[x]
x'[y] == 1/(D[y[x], x] /. x -> x[y]);
xsol = DSolve[%, x, y][[1, 1]]

x -> Function[{y}, InverseFunction[2 E^(2 #1) + 3 #1^3 &][y + C[1]]]

Solve the initial condition for C[1].

x[2] == 0 /. xsol;
Solve[%, C[1]][[1, 1]]
C[1] -> 0

We can now define the x function. It is in terms of an InverseFunction but
easily evaluable.

x[y_] = x[y] /. (xsol /. C[1] -> 0)
InverseFunction[2 E^(2 #1) + 3 #1^3 &][y]

We can check numerically that the function is inverse, at least for small or
exact values of x.

x[y[x]] == x;
% /. x -> 10
True

(I wish I knew a method to show this symbolically.)

We can plot the y function, inverse x function and their composition to
check, at least numerically, the proper relation.

Show[
{Plot[y[x], {x, -2, 2}, PlotStyle -> Black],
Plot[x[y], {y, -20, 20}, PlotStyle -> Blue],
Plot[y[x[z]], {z, -10, 10}, PlotStyle -> Red]},
AspectRatio -> Automatic,
PlotRange -> 10,
Axes -> False,
Frame -> True]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/index.html

Andrzej Kozlowski

unread,
May 10, 2012, 5:04:17 AM5/10/12
to

On 9 May 2012, at 09:50, John Accardi wrote:

> Hello, I am trying to get Mathematica to find the inverse of:
>
> y = 3x^3 + 2e^(2x) (which I know is invertible)
>
> InverseFunction only seems to give inverses of built-ins, like Sine.
>
> I tried:
>
> Solve[ y == 3x^3 + 2e^(2x), x ] but get a message that Solve does
not have methods suitable. (Solve works for simpler functions,
however.)
>
> Any ideas? Thanks.

First, you have e instead of E in your definition which makes nonsense
of the entire problem as far as Mathematica is concerned.

Secondly, what do you mean by "finding the inverse"? Your function is
clearly invertible (only as a function on the real line, of course) but
there is no way to express this inverse in terms of known functions.
However, you can define the inverse yourself:

ff[y_] :=
Block[{x}, x /. NSolve[y == 3 x^3 + 2 E^(2 x), x, Reals][[1]]]

To see that this works, define:

gg[x_] := 3 x^3 + 2 E^(2 x)

and look at the graphs:

DiscretePlot[ff[gg[x]], {x, -1, 1, 1/10}]

DiscretePlot[gg[ff[x]], {x, -1, 1, 1/10}]


Andrzej Kozlowski




0 new messages