#--------------------------------------------------------------------------- # M1225 First Lab Assignment Due Thursday, Jan 21, 1999 # Treibergs Logs and exponentials #--------------------------------------------------------------------------- # For those of you who are new to MAPLE, this lab assignment will give you some idea of what it # can do. We will explore graphical and numerical features of logarithms. Type in the # instructions as you see them on the assignment and see that you get the same answers that I did. # When you are ready to prepare the lab questions, modify the examples or enter new code that # answers the question. Hand in only the solutions of the lab problems. Make your papers self # contained by entering text or writing by hand on the printout enough to describe the question # and the answer. You will have to label functions on graphs and points. # Plotting functions # To plot a single function > plot(sin(t),t=-2*Pi..2*Pi); > # To plot several several functions, list them in a set (surrounded by curly braces) > plot({sin(x),sin(2*x),sin(3*x)},x=-2*Pi..2*Pi); # Scaling=constrained gets the vertical scale compatible with the horizontal scale > plot({sin(x), sin(2*x),sin(3*x)},x=-2*Pi..2*Pi,scaling=constrained); # MAPLE can efficiently make a list of objects depending on a parameter via sequence # and put them all in a set data structure by surrounding the sequence with braces. The set of # functions is given the name SetOfFns. This named set of functions may be plotted. Note that set # data structures don't keep the objects in order. > SetOfFns:={seq(t^k,k=1..9)}; 2 3 4 5 6 7 8 9 SetOfFns := {t, t , t , t , t , t , t , t , t } > plot(SetOfFns,t=-1.1..1.1,scaling=constrained); # We can increase the set by union with another set containing the constant function > plot(SetOfFns union {1},t=-1.1..1.1,scaling=constrained); # # Implicit plotting # The relationship between a function and its inverse is always if y = f(x) then x = g(y) where # g(y) is the inverse function of f. Now the inverse relation R={(x,y) : x=f(y)} # may not be a graph, but MAPLE can plot it anyway with implicitplot. You have to load in the # extra plotting routines first. > with(plots): > implicitplot(x^2 + y^2 = 4,x=-3..3,y=-3..3,scaling = constrained); # Now lets plot y=sin(x) and the inverse relation R={(x,y):x=sin(y)}. > implicitplot({y=sin(x),x=y,x=sin(y)},x=-7..7,y=-7..7,scaling=constrained); # The wiggly curves are mirror images across the 45¡ line. The relation R is not a function # because the curve has several y values for each x. By restricting to those x where y is # monotone allows us to define the principal part of the inverse function. > implicitplot({y=sin(x),x=y,x=sin(y)},x=-Pi/2..Pi/2,y=-Pi/2..Pi/2, scaling=constrained); # Of course MAPLE has the inverse sine which is a function for -1²x²1. > plot({sin(x),x,arcsin(x)},x=-1..1,scaling=constrained); # Exponentials and Logarithms # The natural logarithm and exponential are written ln(x) and exp(x). We make a sequence of # lists (a list is a data structure containing an ordered sequences of objects.) > seq([k,ln(k),exp(k)],k=1..10); [1, 0, exp(1)], [2, ln(2), exp(2)], [3, ln(3), exp(3)], [4, ln(4), exp(4)], [5, ln(5), exp(5)], [6, ln(6), exp(6)], [7, ln(7), exp(7)], [8, ln(8), exp(8)], [9, ln(9), exp(9)], [10, ln(10), exp(10)] # To get the decimal equivalents, > seq([k,evalf(ln(k)),evalf(exp(k))],k=1..10); [1, 0, 2.718281828], [2, .6931471806, 7.389056099], [3, 1.098612289, 20.08553692], [4, 1.386294361, 54.59815003], [5, 1.609437912, 148.4131591], [6, 1.791759469, 403.4287935], [7, 1.945910149, 1096.633158], [8, 2.079441542, 2980.957987], [9, 2.197224577, 8103.083928], [10, 2.302585093, 22026.46579] # To get logs and exponentials of other bases MAPLE provides the commands log[b](x), log10(x) # and a^x > seq([k,evalf(log[2](k)),evalf(2^k)],k=1..8); [1, 0, 2.], [2, 1., 4.], [3, 1.584962501, 8.], [4, 2.000000000, 16.], [5, 2.321928094, 32.], [6, 2.584962500, 64.], [7, 2.807354922, 128.], [8, 3.000000000, 256.] > # Integral for logarithm # Maple can do integrals, e.g, if f(t)=t^3 + sin(t) then ºf(t) dt from 0 to x is > int(t^3 + sin(t),t=0..x); 4 1/4 x - cos(x) + 1 # It knows about ln. > int(1/t,t=1..x); ln(x) # We replace 1/t by the function which is 1/2 for 1 < x ² 2, 1/3 for 2 < x ² 3 and so on # We can define the staircase shaped function by the command > f:= t -> 1/floor(1+t); 1 f := t -> ------------ floor(1 + t) # where floor means the greatest integer part, e.g. floor(2.4)=2, floor(3)=3, floor(-2.3) = # Ð3. Now plot. discont=true tells MAPLE to expect a discontinuous function. > plot({1/t,f(t)},t=1..8,scaling=constrained,discont=true); > # The area under the staircase is less than the area under 1/t (which is the logarithm) # To get the area from 1 ² x ² 8 we may sum Sfn(8) = 1/2 + 1/3 + ... + 1/8 or in MAPLE > sum(1/j,j=2..8); 481 --- 280 # To see the decimal equivalent, use " to represent the previous quantity. > evalf("); 1.717857143 # We can make this a function > Sfn:= m -> evalf(sum(1/j,j=2..m)); m ----- \ Sfn := m -> evalf( ) 1/j) / ----- j = 2 > > Sfn(8); 1.717857143 > # Compare to the integral from 1 to 10. Ifn(8) = int(1/t,t=1..8) > evalf(int(1/t,t=1..8)); 2.079441542 > # Laboratory Problems # 1. On the same graph, plot log[2](x), log[3](x),...,log[10](x) for 0.2 ² x ² 5. How do the # logarithms change depending on the base? Do the same for log[1/2](x),...,log[1/10](x). # 2. On the same graph, plot 2^x,3^x,...,8^x for -5² x ² 1.2 How do the exponentials change # depending on the base? Do the same for (1/2)^x,...,(1/8)^x. # 3. Does the function f(x) = x + 2*x^3 have an inverse function? Find a subdomain of the # reals for which f has an inverse function. Plot y=f(x), and y=f^(-1)(x) (the inverse # function) on the same graph. From your graph, approximate f^(-1)(5). (Read the mouse # coordinates.) # 4. Does the function y = ln(x) have an inverse for all x? For x>0? Plot the inverse relation # using implicitplot. What function is the inverse function? Verify by plotting. (for example plot # y=exp(x)) Answer the same question for y=log[3](x) and for y=log[1/4](x). # 5. Compute Ifn(n), Sfn(n) and Ifn(n) - Sfn(n) for n=2,3,4,10,100,1000,10000. This is # evidence for the fact that there is a number c such that Ifn(n)-c ² Sfn(n) ² Ifn(n) for all # n. What is your guess as to the value of c? (we will come to this eventually, page 535). This # shows that it takes a lot of terms in the sum to add up to some number. Using your c, estimate # how many terms (what n) is needed for 1/2 + 1/3 + ... + 1/n to exceed 10? Can you find # the least n by trial and error using the sum? (MAPLE is not actually summing!!!!)