# MAPLE ASSIGNMENT 3
# INVERSE FUNCTIONS
# Graphically an inverse function is the mirror image of the original
# function across the 45 degree line..Note the use of the  notation [ ]
# to draw more than one curve in the same plot and the need to specify
# the scale on the y-axis to get this plot to look right. The line width
# option in the style
# menu in the plot toolbar which can be used to change the
# appearance of these plots.
> g:=x->x;
> plot(g(x),x=-2..2);
> plot([exp(x),g(x)],x=-2..2);
> plot([ln(x),exp(x),g(x)],x=-2..2,y=-2..2);
# The inverse function of sin(x) is called arcsin(x). Why is [-1,1] the
# largest interval about 0 that arcsin(x) can be defined on? 
# In the mirror image plot, make sure you understand which curve is
# which.
> plot(arcsin(x),x=-1..1);
> plot([sin(x),arcsin(x),g(x)],x=-Pi/2..Pi/2,y=-Pi/2..Pi/2);
# x^(1/2) is the inverse function of x^2. Go back to the last two
# commands and change arcsin(x) to x^(1/2) and sin(x) to x^2. Change the
# ranges of x and y so that they start at 0. Then you will see the
# symmetry between the graphs of the square root and square functions. 
# COMPOUNDING AND DISCOUNTING
> FV:=(n,t,r)->1000*(1+r/n)^(n*t);
> FV(2,3,.03);
# Calculate some future values of your own using different values of n,
# t, r.  You can even change the present value of $1000 if you wish. 
> FVc:=(t,r)->1000*exp(r*t);
# This is the formula for continuous compounding.
> FVc(3,.03);
# If your financial institution offered continuous compounding on your
# savings rather than annual compounding would you be better off as the
# answers above suggest?  The answer is probably yes but you should
# compare the interest rates used for the two types of compounding.  The
# next calculation shows what continuous interest rate would pay exactly
# the same amount of interest
# over one year as annual compounding at an interest rate of 3%. 
> solve(FVc(1,r)=FV(1,1,.03),r);
# In class it was claimed that as n gets larger and larger, (1+1/n)^n
# gets closer and closer to the number e.  Here are two ways to check
# this out. In the first way use PG UP & PG DN to see all the numbers or
# click on the scroll bar to move the page up and down. What pattern do
# you see in this list of values of (1+1/n)^n?
> evalf(exp(1));
> seq(evalf((1+1/n)^n),n=1..200);
> evalf(exp(1));
# The other method is to let Maple calculate the limit for you. Here
# x=(1/n)
> limit((1+x)^(1/x),x=0);
# Suppose the value of  the logs net of harvesting costs that can be
# harvested from a piece of land will be $150,000ln(..02t +.01) if the
# land is logged t years from now. The function PV defined below  gives
# the present value of the sum of money that would be received t years
# from now assuming a 4% interest rate and continuous discounting .
> PV:= t->150000*ln(.02*t+.01)*exp(-0.04*t);
> [PV(50.),PV(60.),PV(70.),PV(80.)];
# Which of these 4 choices of cutting date is best? Next, we can plot PV
# to do better than this. Click on the point on the screen where PV is
# largest.
> plot(PV(t),t=40..100);
# Modify the definition of PV so that discrete discounting is
# used rather than continuous discounting. Does this change the best
# cutting date much?
# 
# CONTINUITY AND DISCONTINUITY
# Here you can view a continuous total cost curve which is neither
# convex or concave over its whole domain. The AC curve is however, a
# nice convex U-shaped curve. From the plot, determine approximately the
# value of y which minimizes AC.
> C:=y->y^3-4*y^2+6*y;
> plot(C(y),y=0..3);
> AC:=y->C(y)/y;
> plot(AC(y),y=0..5);
# Next are two simple built-in functions with discontinuiities. However,
# Maple will produce a contiuous approximation to the plot unless it is
# told not to. The next command may help you understand what these two
# functions are as it gives the values of the frac and floor functions
# at x=2.5.
> [frac(2.5),floor(2.5)];
> plot(frac(x),x=0..5);
> plot(frac(x),x=0..5,discont=true);
> plot(floor(x),x=0..5,discont=true);
> plot(frac(x)+floor(x),x=0..5);
# f(x)=(1-exp(-1/x))^(-1) is another example of a jump discontinuity.
# Theplot looks better if you choose on the axes menu an option other
# than
# normal such as the option none (or / & change the line width).  To
# understand this example think about the limit of exp(-1/x))
# as x tends to zero from the right and from the left.  You
# can also get Maple to compute these limits for you as was illustrated
# earlier.  Add  ,right or ,left  after x=0 in the limit command.
> f:=x->1/(1-exp(-1/x));
> plot(f(x),x=-1..1,discont=true);
> 
> 
# The next example is one where the limit of f(x) as x tends to zero
# does not exist.  Why not?
> plot(sin(1/x),x=-2/Pi..2/Pi);
# A modification of the above example is continuous at x=0.
> plot(x*sin(1/x),x=-2/Pi..2/Pi);
# The last example is based on the normal curve.  It is continuous and
# shows how to get a sharp spike. Change the type of the axes (or / &
# change the line width) to see the whole curve.
> plot(exp(-x^2*1000),x=-1..1);
> 
# 
# 
