% Problem 6 % Clear variables and figures. clear close all % a) % Let's use a grid in which x and y go from -1 to 1 with spacing 0.05. x = -1:0.05:1; y = -1:0.05:1; [X,Y] = meshgrid(x,y); contour(x, y, 3*Y + Y.^3 - X.^3) title 'Figure 6.1' xlabel x ylabel y pause print -deps figA6-1 % The graph is shown in Figure 6.1. The curves are nearly horizontal % near the origin, but start curving as we move away. This is because % when y is close to 0, y^3 is very small compared with 3y, and the % curves look a lot like level curves of 3y - x^3, or in other words % y = (1/3)x^3 + C. % Next let's try x and y from -10 to 10 in increments of 0.2. x = -10:0.2:10; y = -10:0.2:10; [X,Y] = meshgrid(x,y); contour(x, y, 3*Y + Y.^3 - X.^3, 20) title 'Figure 6.2' xlabel x ylabel y pause print -deps figA6-2 % The graph is shown in Figure 6.2. The curves slope upward, and % curve around the origin on either side. The curves are graphs of % 3y + y^3 - x^3 = C for various C, and when y is large, y^3 is % large compared with 3y and C. Thus the curves should tend toward % the graph of y^3 - x^3 = 0, or in other words y = x, which they do % in the lower left and upper right corners of the graph. % b) contour(x, y, 3*Y + Y.^3 - X.^3, [5 5]) title 'Figure 6.3' xlabel x ylabel y pause print -deps figA6-3 % The graph is shown in Figure 6.3. This curve lies close to the line % y = x throughout much of the region. % c) % We need to switch to a grid with positive values of x and y because % of the logarithms. Notice that f(1,1) = 0, so we graph the level % curve with value 0. x = 0.1:0.1:5; y = 0.1:0.1:5; [X,Y] = meshgrid(x,y); contour(x, y, X.*log(Y) + Y.*log(X), [0 0]) title 'Figure 6.4' xlabel x ylabel y pause print -deps figA6-4 % The graph is shown in Figure 6.4. echo off