PHYS 220 — Lab #7 [Solution]

This lab should only take you a single lab period. The assignment is due at the beginning of lecture on Monday, 6 Apr. In this lab you'll construct a bisection method (root finder) and a golden section search (1D optimization), and apply them to various problems. Your solutions should include 2 function code listings and a table of numerical results (including respective tolerances) for each problems.


  1. Construct a MATLAB bisection method function (to find the a root of a function) that has the following inputs/outputs:
    See the code rootBiSec.m for an example of how to accomplish this. Note that I also use a version of an interpolation function, borrowed from Lab #3, to better estimate the roots. That said, I report back the final interval, midpoint & interpolated root. If your exit tolerance is sufficiently small, you should not see much of a difference in any of these.

  2. In celestial mechanics, Kepler's Equation relates the mean anomaly M to the eccentric anomaly E of an elliptical orbit of eccentricity e as: M = E - e sin(E).
    1. For M = 1 radian and e = 0.206 (Mercury), 0.0167 (Earth). Calculate the eccentric anomalies E for each planet.
    2. Are there values for the eccentric anomaly for which E = M? If so, what are they.

    See plot below and Lab #7 solution code for details. You will find it calls the function powerpointFig.m, a handy piece of code that formats figure windows for use with PowerPoint, or for display on the web. Note that the graphical roots & the ones found by the code are consistent: EE ≈ 1.0142 and EM ≈ 1.1913. For E = M, either e = 0 (the orbit is circular) or E = nπ.

  3. In neutron transport theory the critical length of a fuel rod in a reactor is determined by the roots of this equation: cot(x) = (x² - 1) / (2x). Determine the smallest positive root of this equation.

  4. See plot below and Lab #7 solution code for details. Note that the graphical root (smallest positive) & the one found by the code are consistent: x ≈ 1.3065. I had to zoom in on a plot of the function to observe the rough locale of the first positive root and use the appropriate interval.

  5. Construct a MATLAB golden section search function (to find a local minimum of a function) that has the following inputs/outputs (you'll need this for HW #6):

  6. See the code minGoldSec.m for an example of how to accomplish this. In this case, only the final interval and a midpoint are reported.

  7. Verify that your function works by finding the relative minimum of y = x³ - 2x² - 4x + 1. (If you can, compare the numerical result with the exact result.)

  8. See plot below and Lab #7 solution code for details. Note that the minimum is found at x = 2; both by eye and the plot. You can also directly verify this by noting that y' = 3x² - 4x - 4.

  9. EXTRA CREDIT The Ideal Gas Law, PV = nRT, works well for low densities since it ignores the size of molecules and assumes perfectly elastic collisions. A second-order approximation is the van der Waals (non-ideal gas) Equation of State, which corrects for finite molecular size and works fairly well even for densities that are not low. It is given by (P + a(n/V)²)(V - nb) = nRT, where a is related to the attractive force between molecules and b is related to the size of each molecule. For P = 3 MPa, T = 300 K and n = 1 mol, find the volume occupied by the two gasses shown below in both the ideal gas and van der Waals approximations.

    Substance
    a
    (J. m3/mole2)
    b
    (m3/mole)
    Nitrogen (N2) 0.1361 3.85x10-5
    Freon (CCl2F2) 1.078 9.98x10-5


See plot below and Lab #7 solution code for details. Note that on the plot I have indicated the result for the ideal gas law, no change in volume with gaseous element or molecule. We need to find V such that (P + a(n/V)²)(V - nb) - nRT = 0. For N2 we find V ≈ 8.1704e-04, very close (< 2% error) to what the ideal gas law predicts with nRT/P. For Freon, however, the ideal gas law assumption is not a very good one: V ≈ 1.4691e-04 ( > 460% error).