# MAPLE ASSIGNMENT 2
# FUNCTIONS
# Maple has lots of built-in functions for you to use.  Examples of
# getting values of these functions are:
> exp(1);
> exp(1.);
> evalf(exp(1),25);
> ln(1);
> log[10](10);
> sin(Pi/2);
> cos(Pi/4);
> sqrt(Pi);
> evalf(Pi,100);
# Calculate some other values of these functions by clicking the mouse
# on the number in the expressions above, deleting the number, entering
# your own number and pressing ENTER  
# 
# The rules of logaritms can be reviewed..  The assumptions are
# necessary to make Maple stick to real numbers. The ~ is telling you
# that some assumption has been made about the variable.
> assume(x>0);
> assume(y,real);
> ln(x+y);
> simplify(%);
> ln(x*y);
> simplify(%);
> ln(x^y);
> simplify(%);
> ln(exp(y));
> exp(ln(x)); 
# 
# You can also plot these functions.  If you click on a point in the
# plot, its coordinates will appear in the bottom left corner of the
# toolbar. Use this capability to get approximately some values of the
# function being plotted.
# 
> plot(ln(x),x=.5..2);
> plot(exp(y),y=-1..3);
> plot(cos(y),y=0..4*Pi);
# 
# You can also define your own functions in Maple.  The next exercise in
# this assignment is to define and plot the average  cost curve of
# exercise 5, p. 59 of the text.
> assume(x>=0);
> f:=x->x^2-20*x+120;
> f(0);
> f(5);
# Calculating f(10), f(15) and f(20) as well should give you an idea of
# what the plot is going to look like.
> plot(f(x),x=0..20);
# Click on the mniimum AC point to get its coordinates approximately.
# As economists, we probably don't like the way Maple does this plot. 
# A scale for the vertical axis can be included in the plot command to
# improve the appearance of the plot such as y=.0..150 (above f(0)). 
# Note that  you can put the plot in its own window by clicking
# preferences on the file menu, then clicking the plotting tab and then
# choosing
# window rather than inline.
# .
# The menus at the top of the screen will change to give you some
# options in the way the plot is drawn. Check out the style and axes
# menus. Use the window menu to get back to the command file or click
# the close button to close the plot window or select close on the file
# menu. You can also access the
# plot toolbar for an Inline plot by just clicking on the plot.
# . 
> plot(f(x),x=0..20,y=0..150);
# 
# More accuracy can be obtained in getting the values of the minimum
# average cost point (by clicking on it) by reducing the range for x and
# y in the last command.
# 
# LEVEL CURVES
# The commands here illustrate the plotting of level curves , e.g.
# contour lines. As above you can do the plot either Inline (click on it
# to get the plot toolbar) or in its own Window. If you want to primt
# the plot but not the whole worksheet, the plot should be in its own
# window.
#  
> with(plots);
> contourplot(x^.25+x*y+y^.25,x=0..5,y=0..5);
> implicitplot({x^.25+x*y+y^.25=2,x^.25+x*y+y^.25=4,x^.25+x*y+y^.25=6},x
> =0..5,y=0..5);
# Using implicitplot gives more control over the levels plotted.  You
# can change the levels to be plotted by  editing and reexecuting the
# above command. You can also add more levels if you wish.
# 
# CURVATURE OF SURFACES
> U:=(x,y)->x^(1/4)*y^(1/2);
> plot3d(U(x,y),x=0..5,y=0..10-2*x);
> 
# This surface is strictly concave. Using the menus on the plot toolbar,
# the buttons on the second plot toolbar or by right clicking the plot
# you can change the axes, the style or the colour of the plot. The
# orientation of the axes can be changed  by pointing at the plot and
# dragging the pointer. 
# Now go back to the command defining U(x,y) and change (1/4,1/2) to
# (1,3/4) or to anything else where the sum of the 2 powers is > 1. The
# resulting surface is neither concave or convex. It is however strictly
# quasiconcave.  You can check this
# out by using the contourplot or implicitplot.commands above. Change
# the function in the command to U(x,y). In implicitplot, you should
# also change the levels to numbers between
# .5 and 2.
# 
