Homework

**9A:** Write a MATLAB m-file to draw bifurcation diagrams. You can start with this file,
bifur.m, and add to it as necessary. The file's help topic describes its specifications. Here is a sample function file,
sinfun.m, that it should run on.

**(i)** Create a function file to represent the *logistic map*, and use your "bifur" function to do the first part of Problem #4.2.3 in the text. (Note: even though you have a plot, you should solve the last two parts of 4.2.3 analytically.)

**(ii)** Use your "bifur" function to plot a bifurcation diagram for the "sinfun" function provided above. Make two plots... one where parameter a ranges over [2, 4.5], and one where a ranges over [-5 5].

**(iii)** Use your result from **(ii)** to select a "familiar" looking small region, and plot a very small window in your diagram. Choose a region that demonstrates the self-similarity of this plot.

**(iv)** Use multiple plots (like that from **(iii)**) to find the a(i) values of bifurcation for this sine function for i=1,2,3,4,5,infinity. Recall that these are the 1st thru 5th bifurcations, as well as the "chaos wall" where period-doubling stops and chaos begins. Look for a-values in the 0 thru 3 range. Compute (a(4)-a(3))/(a(5)-a(4)) and compare this with the period-doubling constant 4.669.

**NOTE:** Here's what you should actually print out... the text of your "bifur.m", one plot for **(i)**, two plots for **(ii)**, one plot for **(iii)**, and none for **(iv)** (just get the values from the computer and write them down). Got it? Only 5 pages total for print-outs.

**9B:** Write a
Haiku inspired by the family of discrete dynamical systems x(k+1) = x(k)^2 + a. For further inspiration, you might look
here.

Solve 3(b) using MATLAB by utilizing the built-in "ode45" function. This will plot trajectories of continuous 2D dynaminal systems. Note that, in the example provided in "help ode45", the plot function "plot(t,y(:,1))" plots y(1) vs. time. To get a plot of y through the phase plane, use "plot(y(:,1),y(:,2))" instead. Also note that "ode45" only accepts functions that take arguments "(t,y)", where t is a scalar variable time, and y can be a vector of any length.

% CDSPLOT plots the phase space of x' = f(x) % CDSPLOT(CDSFUN,RANGE,DX,TMAX,X0) draws the phase plane of the % continuous dynamical system x'=f(x), plotting both a vector % field and specified trajectories. Here, CDSFUN is a handle % (or, if you prefer, a string with the name) of a defined f(x), % RANGE is a vector [XMIN XMAX YMIN YMAX] (see AXIS), DX is the % spacing between vectors in the vector field (so DX=1/3 gives % 9 vectors per unit square), TMAX is the max time the ODE45 % subroutine will plot trajectories to, and X0 is an Nx2 array % where each row is [x0,y0] and specifies the starting point of % one trajectory. To omit trajectories, let TMAX=0; to omit % the vector field, let DX=0.You may actually use this (plus anything else you care to add) as the help header of your M-File. The primary goal of this problem is to improve your MATLAB programming skills. You may cannibalize my VECFIELD.M however you see fit, and your function should make internal calls to QUIVER and ODE45. Test out your code by plotting the phase plane for the van der Pol equation in problem 4.1.3. As always, I'm available for help and hints if you need them. For this problem, submit a single plot and a copy of your source code.

**NOTE:** For 16-20, you may use MATLAB to find eigenvalues and/or iterate the system. In general, you may always use MATLAB (or another package) to handle tedious calculations unless I specify otherwise. For this assignment, you needn't turn in any MATLAB work... just write, "MATLAB says eigenvalues are 2 & 4" (or whatever). If you *do* want to turn in MATLAB work, it is preferred that you e-mail it to your grader
(Michael_Gratton@hmc.edu) instead of printing it.

**2A:** Do problem #10 in Section 1.1. This problem will be due with the *second* assignment, but you will be required to use MATLAB to solve it, so I wanted to give you advanced warning. This problem is primarily to get you to find MATLAB, run it, and do something simple with it. If you are uncertain about how to access or use MATLAB, start NOW so you have plenty of time to figure it out. If you have any problems, see me *early* so we can get them resolved.

Email: