<< Return to class page

Math 151 Lab 03 - 01/24/2018:

DUE: Monday, January 29, 2018 (by 4:00pm before class starts)

INSTRUCTIONS: Save this Matlab script with the filename LastName_Lab03.m (example: Lewis_Lab03.m). Complete each question (either in words or with Matlab code). When you are ready to have your assignment graded, choose the PUBLISH command from the file menu, and submit the resulting file to CANVAS.

Please make sure to leave code uncommented unless I ask for a comment. You do not need to label your steps for each problem, but I should be able to see you do each step I asked for.

Contents

#1

WRITE CODE BELOW:

Generate two separate plots: y=exp(-x) on the interval [0,1], and y=1/x on the interval [1,2]. Have the first function display as a blue line and the second display as a red line.

------------------------------------------------------------------------

#2

WRITE CODE BELOW:

Step 1: Plot the function x*e^x-cos(x) on the interval [-2,2]

Step 2: Plot the horizontal line y=0 in the same window.

Step 3: Lastly, in the same window, plot the two points where x*e^x-cos(x) crosses the x-axis with the color red (these should display as individual markers that are visible on the plot).

------------------------------------------------------------------------

#3

WRITE CODE BELOW:

Read the Number3.pdf file about Newton's method. We're going to find the zeroes of that function.

Step 1: Initialize a vector x of 50 entries. Set the first entry equal to your initial value (i.e. x(1)=1) (Note that normally we would just update the variable x, but I want you to see the convergence.)

Step 2: Fill the remaining entries of x in a loop using the last formula in m151q3.pdf

Step 3: Repeat parts 1 and 2 until you have found approximations for all 5 zeros of the function. Output these approximations to the screen individually.

------------------------------------------------------------------------

#4

WRITE CODE BELOW:

Make A into a random 3x5 matrix (using the matlab command for a random matrix). Try plotting the matrix A.

WRITE A COMMENT BELOW:

What does plot(A) do? Please explain in detail how the axes are shown and what the picture means so I know you understand.

------------------------------------------------------------------------

#5

WRITE CODE BELOW:

With -pi<x<pi and -pi<y<pi, plot the 3D function Z=sin(X)+cos(Y)-0.3*sin(4*X)+0.1*cos(5*Y)

------------------------------------------------------------------------