MATH 241 Problem Set 2: Graphing and Analyzing Functions using MATLAB, Assignments of Advanced Calculus

Instructions for problem set 2 of math 241 (laskowski) fall, 2007. Students are required to use matlab to graph functions, plot level curves, and analyze heat flux. Instructions include creating array-smart functions, using meshgrid and surf, contour plots, and quiver plots.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-u8g
koofers-user-u8g šŸ‡ŗšŸ‡ø

8 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MATH 241 (Laskowski) Fall, 2007
MATLAB Problem Set 2
Due Tuesday, October 23
Note: Matlab online help commands gives examples of meshgrid and surf.
1. Enter the function
f(x, y) = cos(x2+ 4y2).
Be sure to make it ā€œarray smartā€ (or ā€œvectorizedā€). i.e., use dots.
a) Graph fover the square D={|x| ≤ 2,|y| ≤ 2}. Hint: Use the meshgrid
command to make the set of grid points and then use surf. Label the axes.
b) Plot the level curves (contours) of fin the xy plane in the same square D.
You can use the command contour (works analogously to surf). Label the axes.
Note: You can put the plots of parts a) and b) together on the same page with
the command subplot.
2. Enter the function
u(x, y) = (āˆ’4x3+ 3x2+ 1)(yāˆ’y2).
Make sure it is ā€œarray smartā€. The function uis the temperature at a point (x, y)
in the unit square Q={0≤x≤1,0≤y≤1}. The heat flux at each point is
defined to be the negative of the gradient vector āˆ’āˆ‡u(x, y) = āˆ’[ux(x, y ), uy(x, y)].
a) Verify by hand that ux(0, y) = 0 for 0 ≤y≤1 and that u= 0 on the other
three edges of the square. (*** You do not need to turn this part in.) This means
that the left edge of the square is insulated, and that the temperature is held at
zero on the other three edges.
b) Put a 20 by 20 meshgrid on Q. Graph uover Qusing the command
surf(X,Y,u(X,Y)). Note where the temperature is greatest, and the appearance
of the surface on the edge x= 0.
c) Compute the partial derivatives uxand uy. You can either have MATLAB
do this, or you can compute the partial derivatives by hand and then enter the
functions ux and uy into MATLAB by hand. Then enter the commands
U = u(X,Y);
Ux = ux(X,Y);
Uy = uy(X,Y);
contour(X,Y,U,20)
hold on
quiver(X,Y,-Ux,-Uy)
pf2

Partial preview of the text

Download MATH 241 Problem Set 2: Graphing and Analyzing Functions using MATLAB and more Assignments Advanced Calculus in PDF only on Docsity!

MATH 241 (Laskowski) Fall, 2007 MATLAB Problem Set 2 Due Tuesday, October 23

Note: Matlab online help commands gives examples of meshgrid and surf.

  1. Enter the function f (x, y) = cos(x^2 + 4y^2 ).

Be sure to make it ā€œarray smartā€ (or ā€œvectorizedā€). i.e., use dots. a) Graph f over the square D = {|x| ≤ 2 , |y| ≤ 2 }. Hint: Use the meshgrid command to make the set of grid points and then use surf. Label the axes. b) Plot the level curves (contours) of f in the xy plane in the same square D. You can use the command contour (works analogously to surf). Label the axes.

Note: You can put the plots of parts a) and b) together on the same page with the command subplot.

  1. Enter the function

u(x, y) = (āˆ’ 4 x^3 + 3x^2 + 1)(y āˆ’ y^2 ).

Make sure it is ā€œarray smartā€. The function u is the temperature at a point (x, y) in the unit square Q = { 0 ≤ x ≤ 1 , 0 ≤ y ≤ 1 }. The heat flux at each point is defined to be the negative of the gradient vector āˆ’āˆ‡u(x, y) = āˆ’[ux(x, y), uy(x, y)]. a) Verify by hand that ux(0, y) = 0 for 0 ≤ y ≤ 1 and that u = 0 on the other three edges of the square. (*** You do not need to turn this part in.) This means that the left edge of the square is insulated, and that the temperature is held at zero on the other three edges. b) Put a 20 by 20 meshgrid on Q. Graph u over Q using the command surf(X,Y,u(X,Y)). Note where the temperature is greatest, and the appearance of the surface on the edge x = 0. c) Compute the partial derivatives ux and uy. You can either have MATLAB do this, or you can compute the partial derivatives by hand and then enter the functions ux and uy into MATLAB by hand. Then enter the commands

U = u(X,Y); Ux = ux(X,Y); Uy = uy(X,Y); contour(X,Y,U,20) hold on quiver(X,Y,-Ux,-Uy)

Note: The last command attaches arrows at each point of the meshgrid to repre- sent the vector field of the heat flux. d) Use the plot of part c) to answer the following questions.

  • What is the direction of the heat flux with respect to the level curves?
  • Where is the ā€˜hot spot’, and which way is the heat flowing?
  • What is the angle at which the level curves meet the edge x = 0?
  • What is the direction of the heat flux at that edge of the square? How do you explain this physically?
  • Why are the flux vectors perpendicular to the other edges?
  1. Let f (x, y) = x^4 āˆ’ 2 x^2 āˆ’ y^3 + 3y. This function has six critical points in the square D = {|x| ≤ 2 , |y| ≤ 2 }. a) Make a fine mesh over the square D, say 50 by 50. Then use the command contour(X,Y,f(X,Y),levels) where levels = linspace(-4,4, 21). Look at the contour map to locate the six critical points. On the printout of the contour map, indicate the location of each critical point, and indicate its nature. b) Now solve the system fx = 0, fy = 0 (either by hand or using MATLAB). Use the second derivative test at each critical point. Compare these results with your observations in part a).