Math 111: MATLAB Assignment 2

DUE DATE:  DECEMBER 3, 2012

 

 

Your Assignment

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

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

  1. Plot these curves on the same graph on  the where -3<x<3 and -10<y<10. 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 the points noted in step 2 indicate whether there is a maximum, a minimum or an inflection.

  4. Notice the trend in the number of roots as a varies. For each curve note the number of roots, number of local extrema and roughly their locations.

  5. Is there a value of a for which there are exactly 2 roots? (You may try this using guess and check -- hint: it's a pretty round value). Plot the curve with this value of a on the same graph as the others. Extra credit: show analytically how to find this value of a and the values of the two roots.

  6. For what values of a is f(x) always increasing?

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,2)        
           

 

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: 10/22/10