How to compute the integral for the inverse of a function

Axel Vogt's picture

The recipe is quite simple to understand looking at an example (and it is understood best by having paper and pencil to follow it):

f:= x -> x^2 the parabola with its inverse g:= y -> sqrt(y).

Say you want the integral of g over 0 ... 2, which (here) is the area between the graph and its horizontal axis.

That is the same as the area of the rectangle minus the area between the graph of g and the vertical axis, where the rectangle has corners 0, 2 and g(0)= f^(-1)(0) and g(2)= f^(-1)(2).

Now recall the geometric interpretation of the compositional inverse of a function: it is reflection at the diagonal.

The reflection does not change the rectangle's area. However it maps the area between graph and vertical axis to the area between the the reflected graph and the reflected axis, which now is the horizontal.

But that is the integral of f over f^(-1)(0) ... f^(-1)(2).

Thus we have:

  Int(g(y), y=0...2) = areaRectangle - Int('f'(x), x=0...sqrt(2)).

In Maple's language:

  eta0:=0; eta1:=2;  
  xi0:='g(eta0)'; xi1:='g(eta1)';

  areaRectangle:= '(eta1-eta0)*(xi1-xi0)';

  'int(g(y), y= eta0 .. eta1)': '%'=%;
  'areaRectangle' - 'int(f(x), x= xi0 .. xi1)': '%'=%;

                          eta1
                         /                  1/2
                        |                4 2
                        |      g(y) dy = ------
                        |                  3
                       /
                         eta0


                                  xi1
                                 /                 1/2
                                |               4 2
               areaRectangle -  |     f(x) dx = ------
                                |                 3
                               /
                                 xi0

Thus you only invert at the boundary and do not need the expensive (and having possible rounding errors) inverse for integration.

In good cases Maple even knows a symbolic integral for f, while it may not have a closed form for g and everything would have have to be done in a costly numerical setting otherwise.

To sketch the proof: more formally use

  Int( g(y), y ) = Int ( x*D(f)(x), x ) # change y=f(x), g°f = id
                                        #
  = x*f(x) - Int( f(x), x)              # integrating by parts

and apply the fundamental theorem of calculus.

In Maple for F and G being inverse to each other:

  with(IntegrationTools):

  Int( G(y), y )= ``;
  ``=Change(lhs(%), y=F(x), x): convert(%,D);
  ``=subs(G(F(x)) = x,rhs(%));
  ``=Parts(rhs(%),x);

                             /
                            |
                            |  G(y) dy =
                            |
                           /


                            /
                           |
                        =  |  G(F(x)) D(F)(x) dx
                           |
                          /


                               /
                              |
                           =  |  x D(F)(x) dx
                              |
                             /


                                      /
                                     |
                         = F(x) x -  |  F(x) dx
                                     |
                                    /

Actually one simply computes

                eta1                    xi1
               /                       /
              |        (-1)           |
              |      (f    )(y) dy =  |     x D(f)(x) dx
              |                       |
             /                       /
               eta0                    xi0


                                              xi1
                                             /
                                            |
               = f(xi1) xi1 - f(xi0) xi0 -  |     f(x) dx
                                            |
                                           /
                                             xi0

The appended sheet gives a more detailled motivation.

Download 102_integrate_inverse_function.mws
View file details

Comments

Robert Israel's picture

Integrating a RootOf

An indefinite-integral form of this, where g is the inverse function of f, and F an antiderivative of f, is
int(g(y),y)=y*g(y)-F(g(y))

I don't know why Maple doesn't apply this formula to integrating a transcendental RootOf with respect to a linear parameter (it can integrate RootOf a polynomial).
For example:

int(RootOf(_Z*sin(_Z)-y),y) = y*RootOf(_Z*sin(_Z)-y)-sin(RootOf(_Z*sin(_Z)-y))<br />
+RootOf(_Z*sin(_Z)-y)*cos(RootOf(_Z*sin(_Z)-y))

JacquesC's picture

My guess

It was not implemented because no one who worked on the integrator was aware of this formula [or if they were, that Maple didn't use it]. Think of it as a genuine 'oops'.

I would hope that this is now on someone's task list - but it may not be at the very top...

Axel Vogt's picture

I stumbled over it in ...

I stumbled over it re-reading something in Corless et al "On the Lambert W function",
in (3.12) they state a somewhat more general formula

But instead of just quoting (which I forgot) I wanted to have some geometric insight,
thus it became a bit longish.

Thanks to Robert Israel: in case of an antiderivative (like in the examples) his way
is even nicer (and easy to prove by differentiating).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}