# 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);
> ln(1);
> log[10](10);
> sin(Pi/2);
> cos(Pi/4);
> sqrt(Pi);
# 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. 
# 
> 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 an average  cost curve.
> 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);
# As economists, we probably don't like the way Maple does this plot. 
# The scale for the vertical axis can be changed to 0 to 150 (above
# f(0)).  Note that if you click on a plot the plot will be put in a box
# and 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. If you click on a point in the plot window the
# coordinates of the point will be shown in the toolbar at the left.
#  
> 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. Again if you click the plot you get some menus at the
# top which can be used to change the appearance of the plot,
#  
> 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,orientation=[-15,45]);
# This surface is concave. Click the plot and look at the effects of
# changing the axes or the style of the plot.  When you make a change,
# the plot disappears into a white box. Click the REDRAW button marked R
# at the end of the third toolbar to see the recalculated plot.  The
# orientation of the axes can be changed on the second toolbar at the
# left or by pointing at the white box and dragging the pointer. 
# Now go back and change (1/4,1/2) to (1,3/4) or to anything where the
# sum of the 2 powers is > 1. The resulting surface is neither concave
# or convex. It is however quasiconcave.  You can check this by using
# the contourplot or implicitplot.commands on U(x,y).
# 
# If you wish to print any of your plots, execute the command below,
# then go back and reexecute your plot. The plot will appear in a
# window and can be printed by choosing PRINT in the FILE menu. Choosing
# CLOSE on the FILE menu will get you back to your worksheet. 
> plotsetup(window);
