>   

lab2.mws --- Inverse Functions

>   

>    restart;
with( plots ):

Warning, the name changecoords has been redefined

>   

Lab Overview

In this lab we will explore inverse functions with Maple. This exploration will include the graphical and symbolic relationships between a function and its inverse (when it exists) and the connection between the derivatives of a function and its derivative.

A few Maple procedures (user-defined commands) are prepared to complete some of the visualizations. These procedures need to be executed to put them in Maple's memory. You are not responsible for understanding the procedure - of course, if you like programming you might find it interesting to see how Maple works with arguments and can be extended.

You will find a few Points to Ponder in this lab. These questions are intended to help you understand the mathematical material. They are not part of the assignment. Be sure you answer all of the questions for the lab report and do not forget to submit  your answers via Blackboard.

>   

Graphical Example: y = tan(x)  

The tangent function is one of the most frequently encountered periodic functions

>    P_tan4 := plot( tan(x), x=-2*Pi..2*Pi, y=-10..10, discont=true, scaling=constrained ):
display( P_tan4, title="Four Periods of the Tangent Function" );

[Maple Plot]

>   

Graphical Relationship Between Inverse Functions

The graphs  of a function and  its inverse are reflections about the line y=x. That is, if (x,y) is a point on the graph of the function  then the point (y,x) is a point on the graph of the inverse. The transform command from Maple's plottools package can be used to implement this graphical relationship between a function and its inverse:

>    INV := plottools[transform]( (x,y) -> [y,x] ):

This can be used as follows:

>    display( INV( P_tan4 ), view=[-10..10,-10..10] );

[Maple Plot]

>   

Note that this graph cannot be the graph of a function. The problem is that each value of x  has (at least) four distinct values. The usual way to eliminate this problem is to attempt to reduce the  domain of the original function so that each x has exactly one y value. There are many ways to do this for the tangent (or any periodic) function. The standard domain for the tangent function is [-Pi/2,Pi/2].

>    P_tan := plot( tan(x), x=-Pi/2..Pi/2, y=-10..10, discont=true, scaling=constrained ):
P_tan;

[Maple Plot]

>    display( INV( P_tan ), view=[-10..10,-10..10] );

[Maple Plot]

It is very simple to plot the function and its inverse in the same graph.

>    display( [P_tan,INV(P_tan)], view=[-10..10,-10..10] );

[Maple Plot]

However, it is not so simple to combine these plots with different colors or other distinguishing marks. The following Maple procedure plots the original function, its inverse (in blue), and the line y=x. (Remember to execute this command but do not make any changes to it!)

>    plot_reflect := proc(P)
  local opts, Paxis;
  if nargs>1
    then opts := args[2..-1]
    else opts := NULL
  end if;
  Paxis := plot( x, x=-10..10, color=black ):
  plots[display]( [P, Paxis, subsop([1,2]=COLOUR(RGB,0.0,0.0,1.0), INV( P ) )], opts ):
end proc:

>   

To illustrate its use, here is a single graph showing the tangent function on the interval [-Pi/2,Pi/2],  its inverse, and the line y=x. Note how the blue curve is the mirror image of the red curve across the (black) line y=x.

>    plot_reflect( P_tan, title="The Tangent Function and Its Inverse", view=[-10..10,-10..10] );

[Maple Plot]

>   

Points to Ponder

What is the inverse of the inverse tangent function?

>   

Graphical Relationship Between Derivatives of Inverse Functions

The relationship between the derivative of a function and the derivative of its inverse is also easy to visualize. Recall that the tangent line to a curve at a point is the limit of a set of secant lines.

>    plot_secantline := proc(f,domain::name=range,x1::realcons,x2::realcons)
  local a, b, opt, Pf, Plx, Ply, Psl, Ptr, x, X, Y, y1, y2;
  if not typematch(domain,x::name=a::realcons..b::realcons)
    then error("invalid arguments")
  end if;
  if nargs>4
    then opt := args[5..-1]
    else opt := NULL
  end if;
  Pf := plot( f, domain, color=red );
  y1 := eval(f,x=x1);
  y2 := eval(f,x=x2);
  X := x1 + (x2-x1)*t;
  Y := y1 + (y2-y1)*t;
  Psl := plot( [ X, Y, t=-3..3 ], color=pink );
  Ptr := plot( [ [x1,y1], [x2,y1], [x2,y2] ], color=cyan );
  Plx := plots[textplot]( [ (x1+x2)/2, y1, "dx" ], align=BELOW );
  Ply := plots[textplot]( [ x2, (y1+y2)/2, "dy" ], align=RIGHT );
  plots[display]( [Pf, Psl, Ptr, Plx, Ply], opt );
end proc:

>   

For example, here is the graph of the tangent function with the secant line through the points on y=tan(x) with x=1.3 and x=1.4.

>    P_tansec := plot_secantline( tan(x), x=-Pi/2..Pi/2, 1.3, 1.4, view=[-10..10,-10..10] ):
P_tansec;

[Maple Plot]

This secant line is very steep -- and hence the value of the derivative will be very large (and positive).

The following command produces a nice picture of the secant line for the function and the corresponding secant line for the inverse function.

>    plot_reflect( P_tansec, view=[0..6,0..6] );

[Maple Plot]

>   

>   

Points to Ponder

  • Note how the roles of dx and dy are interchanged between the function and its inverse. What does this mean about the relationship between the slopes of the two secant lines?
  • What does this picture tell you about the slope of the inverse tangent function for x near 1.3? for x near 4?
  • Find two new values for x such that the secant line for the inverse tangent function will be small (say, less than 1).
  • Can you find a secant line for the inverse tangent function with negative slope?

>   

>   

>   

>   

>   

>   

>   

>   

>   

>   

Analytic Example: Finding Explicit Formulae for Inverse Functions

It is not possible to solve the equation y=tan(x) for x without introducing new notation. To practice finding an explicit formula for the inverse function, consider

>    f := x->(5-2*x)/sqrt(x-2);

f := proc (x) options operator, arrow; (5-2*x)/sqrt(x-2) end proc

Maple and "Functions"

Note the different way in which this definition is made. The arrow operator (->) is used to define a function when you know the explicit rule used to define the function.

The benefit of this form is that we do not need to use eval to evaluate the function at a point. For example, the value at x=3 can be found with

>    f(3);

-1

A little later in this worksheet the unapply  command will be used to create another function. This method must be used when you want to create a function from a Maple result.

Regardless of how the function is defined, it is easy to evaluate a function at a specific point. For example,

>    f(3);

-1

>    f(a+b);

(5-2*a-2*b)/(a+b-2)^(1/2)

>   

Prior to doing any algebraic manipulation, we should convince ourselves that this function actually has an inverse. First, note that the denominator is defined only for x>2. A graph of the function on (2,10]

>    Pf := plot( f(x), x=2..10 ):
Pf;

[Maple Plot]

suggests that the function might be decreasing for all x>2. If so, then this function is monotone and has an inverse!

To verify that the function is decreasing for x>2, consider the derivative:

>    Df := diff( f(x), x );

Df := -2/(x-2)^(1/2)-1/2*(5-2*x)/(x-2)^(3/2)

Maple appears to have used the product rule to obtain this result. The two terms can be combined by asking Maple to simplify the expression:

>    Df := simplify( Df );

Df := -1/2*(2*x-3)/(x-2)^(3/2)

Points to Ponder

  • How would you compute this derivative by hand?
  • Which form  - if either - looks more like what you would expect to find?

>   

>   

>   

>   

>   

It still remains to verify that this derivative is negative for all x>2.

>    need_to_show := Df < 0;

need_to_show := -1/2*(2*x-3)/(x-2)^(3/2) < 0

First, for x>2, x-2 will be positive and so 2*(x-2)^(3/2) is always positive.

Second, 2*x-3 is positive for all x>3/2; therefore -(2*x-3) is negative for all x>2.

These results combine to verify that this function is monotone (decreasing) for all x>2.

>   

Additional Note about Maple's solve  Command

Note that this result could be found by asking Maple to solve the inequality

>    need_to_show;

-1/2*(2*x-3)/(x-2)^(3/2) < 0

for x as follows:

>    solve( need_to_show, x );

RealRange(Open(2),infinity)

While this works for this example, do not be surprised if Maple is unable to return such a useful result for other examples that you might consider.

>   

>   

Now that we are certain this function has an inverse, we can plot it as in the first example:

>    Pf2 := plot_reflect( Pf, view=[-6..10,-6..10] ):
Pf2;

[Maple Plot]

Points to Ponder

  • Are you concerned that the graphs of the function and its inverse intersect?

>   

>   

Let's now attempt to find an explicit formula for the inverse function

Step 1

Solve the equation y=f(x) for x in terms of y.

First, setup the equation to be solved

>    q0 := y = f(x);

q0 := y = (5-2*x)/(x-2)^(1/2)

then solve for x in terms of y

>    q1 := solve( q0, {x} );

q1 := {x = -1/2*y*(-1/4*y+1/4*(y^2+8)^(1/2))+5/2}, {x = -1/2*y*(-1/4*y-1/4*(y^2+8)^(1/2))+5/2}

we see that there are two solutions. These two solutions arise from the solution of a quadratic equation. Which one -- if either -- is appropriate as the inverse function for this example? To test, let's plot both functions:

>    x1 := eval( x, q1[1] );

x1 := -1/2*y*(-1/4*y+1/4*(y^2+8)^(1/2))+5/2

>    x2 := eval( x, q1[2] );

x2 := -1/2*y*(-1/4*y-1/4*(y^2+8)^(1/2))+5/2

>   

>    plot( [x1,x2], y=-6..10, color=[blue,green] );

[Maple Plot]

Aha! Only the blue curve is the reflection of the original function.

>   

Step 2

Use f^(-1)(y) to name the resulting expression in y.

>    f_inv := unapply( x1, y );

f_inv := proc (y) options operator, arrow; -1/2*y*(-1/4*y+1/4*(y^2+8)^(1/2))+5/2 end proc

>   

Step 3

Replace y by x to get the formula for f^(-1)(x).

Note that the way in which Step 2 has been completed in Maple means this step is no longer necessary.

>    f_inv(x);

-1/2*x*(-1/4*x+1/4*(x^2+8)^(1/2))+5/2

>   

>   

If this process has been successful, the graph of this function should coincide with the relection of the original function

>    Pf_inv := plot( f_inv(x), x=-6..10, style=point, color=magenta ):
display( [Pf2,Pf_inv] );

[Maple Plot]

>   

This is good!

To conclude, let's verify the identities f^(-1)( f(x) ) = x and f( f^(-1)(y) ) = y

>    q3 := f_inv( f(x) );

q3 := -1/2*(5-2*x)/(x-2)^(1/2)*(-1/4*(5-2*x)/(x-2)^(1/2)+1/4*((5-2*x)^2/(x-2)+8)^(1/2))+5/2

>    simplify( q3 ) assuming x>2;

x

Success! One more:

>    q4 := f( f_inv(y) );

q4 := 2*y*(-1/4*y+1/4*(y^2+8)^(1/2))/(-2*y*(-1/4*y+1/4*(y^2+8)^(1/2))+2)^(1/2)

>    q5 := simplify( q4 );

q5 := y*(-y+(y^2+8)^(1/2))/(2*y^2-2*y*(y^2+8)^(1/2)+8)^(1/2)

Hmm? This is pretty complicated. To see if this has any chance of simplifying to y, let's plot this expression and see if it looks reasonable.

(Why should it look like the line through the origin with slope 1?)

>    plot( q5, y=-6..10 );

[Maple Plot]

This is good! Now, returning to the algebraic manipulations. An alternative approach is to subtract y from the expression and see if the result simplifies to zero:

>    q6 := simplify( q5 - y );

q6 := y*(-y+(y^2+8)^(1/2)-(2*y^2-2*y*(y^2+8)^(1/2)+8)^(1/2))/(2*y^2-2*y*(y^2+8)^(1/2)+8)^(1/2)

Our attention can be focused on the numerator:

>    q7 := numer( q6 );

q7 := y*(-y+(y^2+8)^(1/2)-(2*y^2-2*y*(y^2+8)^(1/2)+8)^(1/2))

>    q8 := simplify( q7 );

q8 := y*(-y+(y^2+8)^(1/2)-(2*y^2-2*y*(y^2+8)^(1/2)+8)^(1/2))

Still no luck. Let's look at another plot:

>    plot( q8, y=-6..10 );

[Maple Plot]

Noting the labels on the vertical axis are on the order of 10^(-13), we are convinced that this expression is, in fact, zero and that this identity is satisfied.

>   

Lab Questions

1. Consider the function f(x) = cos(x) . What is the largest domain containing both x = 0  and x = 1  on which this function has an inverse?

2. Consider the function f(x) = x^3-4*x . What is the largest domain containing x = 0  on which this function has an inverse?

3. Find a formula for the inverse of f(x) = (x+1)/(x-1) .

4. Explain why f(x) = Int(sqrt(1+cos(t)^2),t = 0 .. x)  has an inverse.

5. Using the function from Question 4, compute ( f^(-1) )'(0).

6. [ Essay Question] Suppose f is a function whose derivative is positive and decreasing for all real numbers. Explain why the inverse function exists and is an increasing function. Is the derivative of the inverse function increasing or decreasing? Explain how you arrived at your answers.

>   

>   

>