Steven C. Chapra
Chapter 14
Linear Regression - all with Video Answers
Educators
Chapter Questions
Given the data
$$
\begin{array}{lllll}
0.90 & 1.42 & 1.30 & 1.55 & 1.63 \\
1.32 & 1.35 & 1.47 & 1.95 & 1.66 \\
1.96 & 1.47 & 1.92 & 1.35 & 1.05 \\
1.85 & 1.74 & 1.65 & 1.78 & 1.71 \\
2.29 & 1.82 & 2.06 & 2.14 & 1.27
\end{array}
$$
Determine (a) the mean, (b) median, (c) mode, (d) range, (e) standard deviation, (f) variance, and $(\mathrm{g})$ coefficient of variation.
Check back soon!
Construct a histogram from the data from Prob. 14.1. Use a range from 0.8 to 2.4 with intervals of 0.2 .
Ryan Mcalister
Numerade Educator
Given the data
$$
\begin{array}{lllllll}
29.65 & 28.55 & 28.65 & 30.15 & 29.35 & 29.75 & 29.25 \\
30.65 & 28.15 & 29.85 & 29.05 & 30.25 & 30.85 & 28.75 \\
29.65 & 30.45 & 29.15 & 30.45 & 33.65 & 29.35 & 29.75 \\
31.25 & 29.45 & 30.15 & 29.65 & 30.55 & 29.65 & 29.25
\end{array}
$$
Determine (a) the mean, (b) median, (c) mode, (d) range, (e) standard deviation, (f) variance, and $(\mathrm{g})$ coefficient of variation.
(h) Construct a histogram. Use a range from 28 to 34 with increments of 0.4 .
(i) Assuming that the distribution is normal, and that your estimate of the standard deviation is valid, compute the range (i.e., the lower and the upper values) that encompasses $68 \%$ of the readings. Determine whether this is a valid estimate for the data in this problem.
Carolyn Behr-Jerome
Numerade Educator
Using the same approach as was employed to derive Eqs. (14.15) and (14.16), derive the least-squares fit of the following model:
$$
y=a_1 x+e
$$
That is, determine the slope that results in the least-squares fit for a straight line with a zero intercept. Fit the following data with this model and display the result graphically.
$$
\begin{array}{cccccccccc}
\hline \boldsymbol{x} & 2 & 4 & 6 & 7 & 10 & 11 & 14 & 17 & 20 \\
\boldsymbol{y} & 4 & 5 & 6 & 5 & 8 & 8 & 6 & 9 & 12 \\
\hline
\end{array}
$$
Check back soon!
Use least-squares regression to fit a straight line to
$$
\begin{array}{llllllccccc}
\hline \boldsymbol{x} & 0 & 2 & 4 & 6 & 9 & 11 & 12 & 15 & 17 & 19 \\
\boldsymbol{y} & 5 & 6 & 7 & 6 & 9 & 8 & 8 & 10 & 12 & 12 \\
\hline
\end{array}
$$
Along with the slope and intercept, compute the standard error of the estimate and the correlation coefficient. Plot the data and the regression line. Then repeat the problem, but regress $x$ versus $y$-that is, switch the variables. Interpret your results.
Check back soon!
Fit a power model to the data from Table 14.1, but use natural logarithms to perform the transformations.
James Kiss
Numerade Educator
The following data were gathered to determine the relationship between pressure and temperature of a fixed volume of 1 kg of nitrogen. The volume is 10 $\mathrm{m}^3$.
$$
\begin{array}{lcccccc}
\hline \boldsymbol{T},{ }^{\circ} \mathrm{C} & -40 & 0 & 40 & 80 & 120 & 160 \\
\boldsymbol{p}, \mathbf{N} / \mathrm{m}^2 & 6900 & 8100 & 9350 & 10,500 & 11.700 & 12.800
\end{array}
$$
Employ the ideal gas law $p V=n R T$ to determine $R$ on the basis of these data. Note that for the law, $T$ must be expressed in kelvins.
Carson Merrill
Numerade Educator
Beyond the examples in Fig. 14.13, there are other models that can be page 395 linearized using transformations. For example,
$$
y=\alpha_4 e^{\beta_4 x}
$$
Linearize this model and use it to estimate $\alpha_4$ and $\beta_4$ based on the following data. Develop a plot of your fit along with the data.
$$
\begin{array}{llllllllll}
\hline \boldsymbol{x} & 0.1 & 0.2 & 0.4 & 0.6 & 0.9 & 1.3 & 1.5 & 1.7 & 1.8 \\
\boldsymbol{y} & 0.75 & 1.25 & 1.45 & 1.25 & 0.85 & 0.55 & 0.35 & 0.28 & 0.18
\end{array}
$$
Victor Salazar
Numerade Educator
The concentration of E. coli bacteria in a swimming area is monitored after a storm:
$$
\begin{array}{lcccccc}
\boldsymbol{t}(\mathbf{h r}) & 4 & 8 & 12 & 16 & 20 & 24 \\
\boldsymbol{c} \text { (CFU/ } 100 \mathrm{~mL}) & 1600 & 1320 & 1000 & 890 & 650 & 560
\end{array}
$$
The time is measured in hours following the end of the storm and the unit CFU is a "colony forming unit." Use this data to estimate (a) the concentration at the end of the storm $(t=0)$ and (b) the time at which the concentration will reach 200 $\mathrm{CFU} / 100 \mathrm{~mL}$. Note that your choice of model should be consistent with the fact that negative concentrations are impossible and that the bacteria concentration always decreases with time.
James Kiss
Numerade Educator
Rather than using the base-e exponential model [Eq. (14.22)], a common alternative is to employ a base-10 model:
$$
y=\alpha_5 10^\beta g^x
$$
When used for curve fitting, this equation yields identical results to the base-e version, but the value of the exponent parameter $\left(\beta_5\right)$ will differ from that estimated with Eq. (14.22) $\left(\beta_1\right)$. Use the base-10 version to solve Prob. 14.9. In addition, develop a formulation to relate $\beta_1$ to $\beta_5$.
Check back soon!
Determine an equation to predict metabolism rate as a function of mass based on the following data. Use it to predict the metabolism rate of a $200-\mathrm{kg}$ tiger.
$$
\begin{array}{lcc}
\text { Animal } & \text { Mass (kg) } & \text { Metabolism (watts) } \\
\hline \text { Cow } & 400 & 270 \\
\text { Human } & 70 & 82 \\
\text { Sheep } & 45 & 50 \\
\text { Hen } & 2 & 4.8 \\
\text { Rat } & 0.3 & 1.45 \\
\text { Dove } & 0.16 & 0.97
\end{array}
$$
Heather Zimmers
Numerade Educator
On average, the surface area $A$ of human beings is related to weight $W$ and height $H$. Measurements on a number of individuals of height 180 cm and different weights $(\mathrm{kg})$ give values of $A\left(\mathrm{~m}^2\right)$ in the following table:
$$
\begin{array}{ccccccccc}
\hline \boldsymbol{W}(\mathrm{kg}) & 70 & 75 & 77 & 80 & 82 & 84 & 87 & 90 \\
\boldsymbol{A}\left(\mathbf{m}^2\right) & 2.10 & 2.12 & 2.15 & 2.20 & 2.22 & 2.23 & 2.26 & 2.30 \\
\hline
\end{array}
$$
Show that a power law $A=a W^b$ fits these data reasonably well. Evaluate the constants $a$ and $b$, and predict what the surface area is for a $95-\mathrm{kg}$ person.
Breanna Ollech
Numerade Educator
Fit an exponential model to
$$
\begin{array}{ccccccc}
\hline \boldsymbol{x} & 0.4 & 0.8 & 1.2 & 1.6 & 2 & 2.3 \\
\boldsymbol{y} & 800 & 985 & 1490 & 1950 & 2850 & 3600 \\
\hline
\end{array}
$$
Plot the data and the equation on both standard and semi-logarithmic graphs with the MATLAB subplot function.
James Kiss
Numerade Educator
An investigator has reported the data tabulated below for an experiment to determine the growth rate of bacteria $k$ (per d) as a function of oxygen concentration $c(\mathrm{mg} / \mathrm{L})$. It is known that such data can be modeled by the following equation:
$$
k=\frac{k_{\max } c^2}{c_s+c^2}
$$
where $c_s$ and $k_{\text {max }}$ are parameters. Use a transformation to linearize this equation. Then use linear regression to estimate $c_s$ and $k_{\max }$ and predict the growth rate at $c=$ $2 \mathrm{mg} / \mathrm{L}$.
$$
\begin{array}{lllllc}
\hline \boldsymbol{c} & 0.5 & 0.8 & 1.5 & 2.5 & 4 \\
\boldsymbol{k} & 1.1 & 2.5 & 5.3 & 7.6 & 8.9 \\
\hline
\end{array}
$$
Check back soon!
Develop an M-file function to compute descriptive statistics for a vector of values. Have the function determine and display number of values, mean, median, mode, range, standard deviation, variance, and coefficient of variation. In addition, have it generate a histogram. Test it with the data from Prob. 14.3.
Check back soon!
Modify the linregr function in Fig. 14.15 so that it (a) computes and returns the standard error of the estimate and (b) uses the subplot function to also display a plot of the residuals (the predicted minus the measured $y$ ) versus $x$.
Test it for the data from Examples 14.2 and 14.3 .
Check back soon!
Develop an M-file function to fit a power model. Have the function return the best-fit coefficient $\alpha_2$ and power $\beta_2$ along with the $r^2$ for the untransformed model. In addition, use the subplot function to display graphs of both the transformed and untransformed equations along with the data. Test it with the data from Prob. 14.11.
Check back soon!
The following data show the relationship between the viscosity of page 396 SAE 70 oil and temperature. After taking the log of the data, use linear regression to find the equation of the line that best fits the data and the $r^2$ value.
$$
\begin{array}{lcccc}
\text { Temperature, }{ }^{\circ} \mathrm{C} & 26.67 & 93.33 & 148.89 & 315.56 \\
\text { Viscosity, } \mu, \mathbf{N} \cdot \mathrm{s} / \mathrm{m}^2 & 1.35 & 0.085 & 0.012 & 0.00075
\end{array}
$$
Varsha Aggarwal
Numerade Educator
You perform experiments and determine the following values of heat capacity $c$ at various temperatures $T$ for a gas:
$$
\begin{array}{ccccccc}
\boldsymbol{T} & -50 & -30 & 0 & 60 & 90 & 110 \\
\boldsymbol{c} & 1250 & 1280 & 1350 & 1480 & 1580 & 1700
\end{array}
$$
Use regression to determine a model to predict $c$ as a function of $T$.
Carson Merrill
Numerade Educator
It is known that the tensile strength of a plastic increases as a function of the time it is heat treated. The following data are collected:
$$
\begin{array}{lccccccccc}
\text { Time } & 10 & 15 & 20 & 25 & 40 & 50 & 55 & 60 & 75 \\
\text { Tensile Strength } & 5 & 20 & 18 & 40 & 33 & 54 & 70 & 60 & 78
\end{array}
$$
(a) Fit a straight line to these data and use the equation to determine the tensile strength at a time of 32 min .
(b) Repeat the analysis but for a straight line with a zero intercept.
Raymond Matshanda
Numerade Educator
The following data were taken from a stirred tank reactor for the reaction $A \rightarrow$ $B$. Use the data to determine the best possible estimates for $k_{01}$ and $E_1$ for the following kinetic model:
$$
-\frac{d A}{d t}=k_{01} e^{-E_1 / R T} A
$$
where $R$ is the gas constant and equals $0.00198 \mathrm{kcal} / \mathrm{mol} / \mathrm{K}$.
$$
\begin{array}{llcccc}
-\boldsymbol{d} \boldsymbol{A} / \boldsymbol{d} \boldsymbol{t} \text { (moles} / \mathbf{L} / \mathrm{s}) & 460 & 960 & 2485 & 1600 & 1245 \\
\boldsymbol{A} \text { (moles/L) } & 200 & 150 & 50 & 20 & 10 \\
\boldsymbol{T}(\mathbf{K}) & 280 & 320 & 450 & 500 & 550
\end{array}
$$
Aadit Sharma
Numerade Educator
Concentration data were collected at 15 time points for the polymerization reaction:
$$
x A+y B \rightarrow A_x B_y
$$
We assume the reaction occurs via a complex mechanism consisting of many steps. Several models have been hypothesized, and the sum of the squares of the residuals had been calculated for the fits of the models of the data. The results are shown below. Which model best describes the data (statistically)? Explain your choice.
$$
\begin{array}{lccc}
& \text { Model A } & \text { Model B } & \text { Model C } \\
\hline \boldsymbol{S}_r & 135 & 105 & 100 \\
\begin{array}{c}
\text { Number of Model } \\
\text { Parameters Fit }
\end{array} & 2 & 3 & 5
\end{array}
$$
Ramesh Singh
Numerade Educator
Below are data taken from a batch reactor of bacterial growth (after lag phase was over). The bacteria are allowed to grow as fast as possible for the first 2.5 hours, and then they are induced to produce a recombinant protein, the production of which slows the bacterial growth significantly. The theoretical growth of bacteria can be described by
$$
\frac{d X}{d t}=\mu X
$$
where $X$ is the number of bacteria, and $\mu$ is the specific growth rate of the bacteria during exponential growth. Based on the data, estimate the specific growth rate of the bacteria during the first 2 hours of growth and during the next 4 hours of growth.
$$
\begin{array}{cccccccc}
\begin{array}{c}
\text { Time, } \\
\mathbf{h}
\end{array} & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
\begin{array}{c}
\text { [Cells] } \\
\mathbf{g} / \mathbf{L}
\end{array} & 0.100 & 0.335 & 1.102 & 1.655 & 2.453 & 3.7025 .460
\end{array}
$$
Jake Rempel
Numerade Educator
A transportation engineering study was conducted to determine the proper design of bike lanes. Data were gathered on bike-lane widths and average distance between bikes and passing cars. The data from 9 streets are
$$
\begin{array}{llllllllllllll}
\hline \text { Distance, } \mathrm{m} & 2.4 & 1.5 & 2.4 & 1.8 & 1.8 & 2.9 & 1.2 & 3 & 1.2 \\
\text { Lane Width, } \mathrm{m} & 2.9 & 2.1 & 2.3 & 2.1 & 1.8 & 2.7 & 1.5 & 2.9 & 1.5
\end{array}
$$
(a) Plot the data.
(b) Fit a straight line to the data with linear regression. Add this line to the plot.
(c) If the minimum safe average distance between bikes and passing cars is considered to be 1.8 m , determine the corresponding minimum lane width.
Donald Albin
Numerade Educator
In water-resources engineering, the sizing of reservoirs depends on accurate estimates of water flow in the river that is being impounded. For some rivers, longterm historical records of such flow data are difficult to obtain. In contrast, meteorological data on precipitation are often available for many years past. Therefore, it is often useful to determine a relationship between flow and precipitation. This relationship can then be used to estimate flows for years when only precipitation measurements were made. The following data are available for a
river that is to be dammed:
table cant copy
(a) Plot the data.
(b) Fit a straight line to the data with linear regression. Superimpose this line on your plot.
(c) Use the best-fit line to predict the annual water flow if the precipitation is 120 cm .
(d) If the drainage area is $1100 \mathrm{~km}^2$, estimate what fraction of the precipitation is lost via processes such as evaporation, deep groundwater infiltration, and consumptive use.
Check back soon!
The mast of a sailboat has a cross-sectional area of $10.65 \mathrm{~cm}^2$ and is constructed of an experimental aluminum alloy. Tests were performed to define the relationship between stress and strain. The test results are
table cant copy
The stress caused by wind can be computed as $F / A_c$ where $F=$ force in the mast and $A_c=$ mast's cross-sectional area. This value can then be substituted into Hooke's law to determine the mast's deflection, $\Delta L$ strain $\times L$, where $L=$ the mast's length. If the wind force is $25,000 \mathrm{~N}$, use the data to estimate the deflection of a $9-\mathrm{m}$ mast.
Nicholas Mogoi
Numerade Educator
The following data were taken from an experiment that measured the current in a wire for various imposed voltages:
$$
\begin{array}{ccccccc}
\boldsymbol{V}, \mathbf{V} & 2 & 3 & 4 & 5 & 7 & 10 \\
\boldsymbol{i}, \mathbf{A} & 5.2 & 7.8 & 10.7 & 13 & 19.3 & 27.5
\end{array}
$$
(a) On the basis of a linear regression of this data, determine current for a voltage of 3.5 V . Plot the line and the data and evaluate the fit.
(b) Redo the regression and force the intercept to be zero.
Carson Merrill
Numerade Educator
An experiment is performed to determine the \% elongation of electrical conducting material as a function of temperature. The resulting data are listed below. Predict the $\%$ elongation for a temperature of $400^{\circ} \mathrm{C}$.
$$
\begin{array}{lccccccc}
\text { Temperature, }{ }^{\circ} \mathrm{C} & 200 & 250 & 300 & 375 & 425 & 475 & 600 \\
\text { \% Elongation } & 7.5 & 8.6 & 8.7 & 10 & 11.3 & 12.7 & 15.3
\end{array}
$$
Vishal Gupta
Numerade Educator
The population $p$ of a small community on the outskirts of a city grows rapidly over a 20 -year period:
$$
\begin{array}{cccccc}
\boldsymbol{t} & 0 & 5 & 10 & 15 & 20 \\
\boldsymbol{p} & 100 & 200 & 450 & 950 & 2000
\end{array}
$$
As an engineer working for a utility company, you must forecast the population 5 years into the future in order to anticipate the demand for power. Employ an exponential model and linear regression to make this prediction.
Bobby Barnes
University of North Texas
the velocity $u$ of air flowing past a flat surface is measured at several distances $y$ away from the surface. Fit a curve to this data assuming that the velocity is zero at the surface $(y=0)$. Use your result to determine the shear stress ( $\mu d w d y$ ) at the surface where $\mu=1.8 \times 10^{-5} \mathrm{~N} \cdot \mathrm{s} / \mathrm{m}^2$.
$$
\begin{array}{llllll}
\boldsymbol{y}, \mathrm{m} & 0.002 & 0.006 & 0.012 & 0.018 & 0.024 \\
\boldsymbol{u}, \mathrm{m} / \mathrm{s} & 0.287 & 0.899 & 1.915 & 3.048 & 4.299
\end{array}
$$
Hast Aggarwal
Numerade Educator
Andrade's equation has been proposed as a model of the effect of temperature on viscosity:
$$
\mu=D e^{B / T_a}
$$
where $\mu=$ dynamic viscosity of water $\left(10^{-3} \mathrm{~N} \cdot \mathrm{s} / \mathrm{m}^2\right), T_a=$ absolute temperature (K), and $D$ and $B$ are parameters. Fit this model to the following data for water $T$ is in ${ }^{\circ} \mathrm{C}$ and $\mu$ is in $10^{-3} \mathrm{~N} \cdot \mathrm{s} / \mathrm{m}^2$ :
$$
\begin{array}{lcccccc}
\boldsymbol{T} & 0 & 5 & 10 & 20 & 30 & 40 \\
\boldsymbol{\mu} & 1.787 & 1.519 & 1.307 & 1.002 & 0.7975 & 0.6529
\end{array}
$$
Hast Aggarwal
Numerade Educator
Perform the same computation as in Example 14.2, but in addition to the drag coefficient, also vary the mass uniformly by $\pm 10 \%$.
Chai Santi
Numerade Educator
Perform the same computation as in Example 14.3, but in addition to the drag coefficient, also vary the mass normally around its mean value with a coefficient of variation of $5.7887 \%$.
Chai Santi
Numerade Educator
Manning's formula for a rectangular channel can be written as
$$
Q=\frac{1}{n_m} \frac{(B H)^{5 / 3}}{(B+2 H)^{2 / 3}} \sqrt{S}
$$
where $Q=$ flow $\left(\mathrm{m}^3 / \mathrm{s}\right), n_m=$ a roughness coefficient, $B=$ width (m), $H=\operatorname{depth}(\mathrm{m})$, and $S=$ slope. You are applying this formula to a stream where you know that the width $=20 \mathrm{~m}$ and the depth $=0.3 \mathrm{~m}$. Unfortunately, you know the roughness and the slope to only a $\pm 10 \%$ precision. That is, you know that the roughness is about 0.03 with a range from 0.027 to 0.033 and the slope is 0.0003 with a range from 0.00027 to 0.00033 . Assuming uniform distributions, use a Monte Carlo analysis with $n=$ 10,000 to estimate the distribution of flow.
Check back soon!
A Monte Carlo analysis can be used for optimization. For example, the trajectory of a ball can be computed with
$$
y=\left(\tan \theta_0\right) x-\frac{g}{2 v_0^2 \cos ^2 \theta_0} x^2+y_0
$$
where $y=$ the height (m), $\theta_0=$ the initial angle (radians), $v_0=$ the initial velocity $(\mathrm{m} / \mathrm{s}), g=$ the gravitational constant $=9.81 \mathrm{~m} / \mathrm{s}^2$, and $y_0=$ the initial height $(\mathrm{m})$. Given $y_0=1 \mathrm{~m}, v_0=25 \mathrm{~m} / \mathrm{s}$, and $\theta_0=50^{\circ}$, determine the maximum height and the corresponding $x$ distance (a) analytically with calculus and (b) numerically with Monte Carlo simulation. For the latter, develop a script that generates a vector of 10,000 uniformly distributed values of $x$ between 0 and 60 m . Use this vector and Eq. (P14.35) to generate a vector of heights. Then, employ the max function to determine the maximum height and the associated $x$ distance.
Check back soon!
Stokes Settling Law provides a means to compute the settling velocity of spherical particles under laminar conditions
$$
v_s=\frac{g}{18} \frac{\rho_s-\rho}{\mu} d^2
$$
where $v_s=$ the terminal settling velocity $(\mathrm{m} / \mathrm{s}), g=$ gravitational acceleration $(=9.81$ $\left.\mathrm{m} / \mathrm{s}^2\right), \rho=$ the fluid density $\left(\mathrm{kg} / \mathrm{m}^3\right), \rho_s=$ the particle density $\left(\mathrm{kg} / \mathrm{m}^3\right), \mu=$ the dynamic viscosity of the fluid $\left(\mathrm{N} \mathrm{s} / \mathrm{m}^2\right)$, and $d=$ the particle diameter (m). Suppose that you conduct an experiment in which you measure the terminal settling velocities of a number of $10-\mu \mathrm{m}$ spheres having different densities,
$$
\begin{array}{lllllllllll}
\rho_s, \mathrm{~kg} / \mathrm{m}^2 & 1500 & 1600 & 1700 & 1800 & 1900 & 2000 & 2100 & 2200 & 2300 \\
v_s, 10^{-3} \mathrm{~m} / \mathrm{s} & 1.03 & 1.12 & 1.59 & 1.76 & 2.42 & 2.51 & 3.06 & 3 & 3.5
\end{array}
$$
(a) Generate a labeled plot of the data. (b) Fit a straight line to the data with linear regression (polyfit) and superimpose this line on your plot. (c) Use the model to predict the settling velocity of a $2500 \mathrm{~kg} / \mathrm{m}^3$ density sphere. (d) Use the slope and the intercept to estimate the fluid's viscosity and density.
Victor Salazar
Numerade Educator
Beyond the examples in Fig. 14.13, there are other models that can be linearized using transformations. For example, the following model applies to thirdorder chemical reactions in batch reactors
$$
c=c_0 \frac{1}{\sqrt{1+2 k c_0^2 t}}
$$
where $c=$ concentration $(\mathrm{mg} / \mathrm{L}), c_0=$ initial concentration $(\mathrm{mg} / \mathrm{L}), k=$ reaction rate $\left(\mathrm{L}^2 /\left(\mathrm{mg}^2 \mathrm{~d}\right)\right)$, and $t=$ time (d). Linearize this model and use it to estimate $k$ and $c_0$ based on the following data. Develop plots of your fit along with the data for both the transformed, linearized form and the untransformed form.
$$
\begin{array}{ccccccccc}
\boldsymbol{t} & 0 & 0.5 & 1 & 1.5 & 2 & 3 & 4 & 5 \\
\boldsymbol{c} & 3.26 & 2.09 & 1.62 & 1.48 & 1.17 & 1.06 & 0.9 & 0.85
\end{array}
$$
Vipender Yadav
Numerade Educator
In Chap. 7 we presented optimization techniques to find the optimal values of one- and multi-dimensional functions. Random numbers provide an alternative means to solve the same sorts of problems (recall Prob. 14.35). This is done by repeatedly evaluating the function at randomly selected values of the independent variable and keeping track of the one that yields the best value of the function being optimized. If a sufficient number of samples are conducted, the optimum will eventually be located. In their simplest manifestations, such approaches are not very efficient. However, they do have the advantage that they can detect global optimums for functions with lots of local optima. Develop a function that uses random numbers to locate the maximum of the humps function
$$
f(x)=\frac{1}{(x-0.3)^2+0.01}+\frac{1}{(x-0.9)^2+0.04}-6
$$
in the domain bounded by $x=0$ to 2 . Here is a script that you can use to test your function
```
clear,clc,clf, format compact
xmin=0;xmax=2;n=1000
xp=linspace(xmin,xmax,200); yp=f(xp);
plot(xp,yp)
[xopt, fopt]=RandOpt(@f,n,xmin,xmax)
```
Check back soon!
Using the same approach as described in Prob. 14.38, develop a page 399 function that uses random numbers to determine the maximum and corresponding $x$ and $y$ values of the following two-dimensional function
$$
f(x, y)=y-x-2 x^2-2 x y-y^2
$$
in the domain bounded by $x=-2$ to 2 and $y=1$ to 3. The domain is depicted in Fig. P14.39. Notice that a single maximum of 1.25 occurs at $x=-1$ and $y=1.5$. Here is a script that you can use to test your function
```
clear,clc,format compact
xint=[-2;2];y int=[1;3];n=10000;
[xopt,yopt, fopt]=RandOpt2D(@fxy,n,xint,yint)
```
Check back soon!
Suppose that a population of particles is confined to motion along a onedimensional line (Fig. P14.40). Assume that each particle has an equal likelihood of moving a distance, $\Delta x$, to either the left or right over a time step, $\Delta t$. At $t=0$ all particles are grouped at $x=0$ and are allowed to take one step in either direction. After $\Delta t$, approximately $50 \%$ will step to the right and $50 \%$ to the left. After $2 \Delta t$, $25 \%$ would be two steps to the left, $25 \%$ would be two steps to the right, and $50 \%$ would have stepped back to the origin. With additional time, the particles would spread out with the population greater near the origin and diminishing at the ends. The net result is that the distribution of the particles approaches a spreading bellshaped distribution. This process, formally called a random walk (or drunkard's walk), describes many phenomena in engineering and science with a common example being Brownian motion. Develop a MATLAB function that is given a stepsize $(\Delta x)$, and a total number of particles $(n)$ and steps $(m)$. At each step, determine the location along the $x$ axis of each particle and use these results to generate an animated histogram that displays how the distribution's shape evolves as the computation progresses.
Check back soon!
Repeat Prob. 14.40, but for a two-dimensional random walk. As depicted in Fig. P14.41, have each particle take a random step of length $\Delta$ at a random angle $\theta$ ranging from 0 to $2 \pi$. Generate an animated two-panel stacked plot with the location of all the particles displayed on the top plot (subplot $(2,1,1)$ ), and the histogram of the particles' $x$ coordinates on the bottom (subplot $(2,1,2)$ ).
Check back soon!
The table below shows the 2015 world record times and holders for outdoor running. Note that all but the 100 m and the marathon $(42,195 \mathrm{~m})$ are run on oval tracks.
Fit a power model for each gender and use it to predict the record time for a half marathon $(21,097.5 \mathrm{~m})$. Note that the actual records for the half marathon are 3503 s (Tadese) and 3909 s (Kiplagat) for men and women, respectively.
$$
\begin{array}{rrlrl}
\text { Event (m) } & \text { Time } \mathbf{( s )} & \text { Men Holder } & \text { Time } \mathbf{( s )} & \text { Women Holder } \\
\hline 100 & 9.58 & \text { Bolt } & 10.49 & \text { Griffith-Joyner } \\
200 & 19.19 & \text { Bolt } & 21.34 & \text { Griffith-Joyner } \\
400 & 43.18 & \text { Johnson } & 47.60 & \text { Koch } \\
800 & 100.90 & \text { Rudisha } & 113.28 & \text { Kratochvilova } \\
1000 & 131.96 & \text { Ngeny } & 148.98 & \text { Masterkova } \\
1500 & 206.00 & \text { El Guerrouj } & 230.07 & \text { Dibaba } \\
2000 & 284.79 & \text { El Guerrouj } & 325.35 & \text { O'Sullivan } \\
5000 & 757.40 & \text { Bekele } & 851.15 & \text { Dibaba } \\
10.000 & 1577.53 & \text { Bekele } & 1771.78 & \text { Wang } \\
20,000 & 3386.00 & \text { Gebrselassie } & 3926.60 & \text { Loroupe } \\
42.195 & 7377.00 & \text { Kimetto } & 8125.00 & \text { Radcliffe }
\end{array}
$$
Erika Bustos
Numerade Educator