Math 111: MATLAB Assignment 2

DUE DATE:  MARCH 12, 2013

 

 

Your Assignment

In this assignment, we will be investigating the behavior of functions of the form f(x)=x3 + ax2 + 4.

Consider the cases where a = -4, -1, 0, 1, 4.

  1. Plot these curves on the same graph on a reasonable interval. Use your name in the graph's title. (You may want to experiment with other values of a to get a feel for how the curve changes as a changes, but you need not hand in plots for values of a other than those above).

  2. Where, if at all, is the slope equal to zero for each of the curves? (Calculate using the derivative. Compare your answers to the plot.)

  3. At each of these points indicate whether there is a maximum, a minimum or and inflection at each of the points noted in step 2.

  4. Note how many roots there are and their relative locations (i.e. if x is greater than, less than or equal to zero) for the a<0, a>0 and a=0.

  5. Is there a value of a for which there are exactly 2 roots? If so, find this value and plot the curve on the same graph as the others.

In addition to your plot (with curves labeled via the legend command) and answers to the questions, please hand in your MATLAB code (either an M-file or printout of the command window).

You can find more information to help you with the MATLAB commands useful for this assignment at http://m.njit.edu/~bukiet/M111/MatlabHelp_Higley.doc

More on MATLAB can be found at Matlab Documentation.

Here are some tips on what you are expected to hand in.

1. For part 1, just hand in the plot. Make each curve a different color or otherwise make it easy to tell which curve is which.

2. For parts 2, 3 and 4 you might make a table for each value of a along the lines of: (Note, there may be more than one row for a given value of a.)

a Point(s) where slope = 0 analytically y values at these points Maximum, minimum or inflection Number of roots number of extrema
0 (0,4)        
           

 

3. For part 5, show your analytical work then plot the relevant curve on the same graph as those in part 1.

 

Here is some sample code to revise:

x = -5:0.01:5;     %This command makes a vector from -5 to 5 with

                   %increments of 0.01.  The semi-colon suppresses

                   %the output of this command from showing up in the

                   %command window. You can see what each command is

                   %doing if you remove the semi-colon from that line

                   

y = x.^3 + 2;      %This command defines the function y = x^3 +2.  The '.'

                   %gives the command to square each element of the

                   %vector x.

                   

% Create and plot the function another way

F = @(x) x.^3 +2;                      %Create a function f(x)=x^3 + 2

figure(1);

%Plot the curve.

plot(x,F(x),'red','LineWidth',1);

hold on;

F = @(x) x.^3 - 4*x + 2;         %Create a function f(x)=x^3+…

plot(x,F(x),'blue','LineWidth',1);  % Plot it on same axes

hold on;

 

grid on;

 

title('y = x^3 +ax^2 + 2','Fontsize',16);      %Display the title y = x^3.

xlabel('x','Fontsize',14);        %Display label for x-axis.

ylabel('y','Fontsize',14);        %Display label for y-axis.

xlim([-5 5]);                     %Zoom to region from x = -5 to x = 5.

ylim([-10 10]);

hold off;

 

legend('a=0','a=-4');

 

 

Last update: 2/7/13