\documentclass[leqno,11pt]{article}
 \setlength{\textheight}{10.4in}
 \setlength{\topmargin}{-1in}
 \setlength{\headheight}{0in}
 \setlength{\topsep}{0in}
 \setlength{\marginparwidth}{0in}
 \setlength{\marginparsep}{0in}
 \setlength{\oddsidemargin}{0in}
 \setlength{\evensidemargin}{0in}
 \setlength{\textwidth}{6.4in}
 \setlength{\parskip}{4pt}
 \setlength{\parindent}{0pt}
\usepackage{alltt}
\usepackage{email}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{quiz}
\begin{document}
\section*{Sample Quiz 9}
\rule{\textwidth}{0.5ex}

{\Large\bf Extra Credit Problem 1}. {\bf Piecewise Continuous Inputs}

Consider a passenger SUV on a one-day trip from Salt Lake City to Pine Bluffs, Wyoming, on the Nebraska border. The route is I-80 E, 471 miles through Utah and Wyoming. Google maps estimates 6 hours and 52 minutes hours driving time. The table below shows the distances, time, road segment and average speed with total trip time 7 hours and 42 minutes. Cities enroute reduce the freeway speed by 10 mph, the trip time effect not shown in the table.

%% http://www.motorists.org/speed-limits/state-chart


%Segments for Utah and Wyoming
%
%
%
%Utah
%
%
%Freeway I-80 E to Evanston is 65 mph except for some 45-55 mph segments
%
%Parley's Way Walmart to Kimball Junction, 18.1 miles, 20 min, 65 mph limit
%
%Kimball Junction to Wanship, 11.3 miles, 12 min, 55 mph limit
%
%Wanskip to Coalville, 9.1 miles, 13 min, 70 mph limit
%
%Coalville to Echo Dam interchange, 5.7 miles, 7 min, 70 mph limit
%
%Echo Dam to speed limit change sign, 16.5 miles, 18 min, 70 mph limit
%
%Speed sign to Evanston, Wyoming, 39 miles, 36 min,75 mph
%
%Wyoming
%
%Evanston to Cheyenne, I-80, 356 miles, 5 hours and 21 min, 75 mph
%
%Cheyenne to Pine Bluffs, I-80 Nebraska border, 43 miles, 37 min, 75 mph
%
%Wyoming city freeways slow to 65 mph

$$
\begin{array}{|c|c|c|l|c|}
\hline
\mbox{Miles} & \mbox{Minutes} & \mbox{Speed mph} & \mbox{Road Segment} &\mbox{Posted limit mph} \\
\hline
18.1 & 20 & 54.3 & \mbox{Parley's Walmart to Kimball} & 65 \\ \hline
11.3 & 12 & 56.3 & \mbox{Kimball to Wanship} & 65-55\\ \hline
9.1 & 13 & 42 & \mbox{Wanship to Coalville} & 70 \\ \hline
5.7 & 7 & 48.9 & \mbox{Coalville to Echo Dam} & 70 \\ \hline
16.5 & 18 & 55 & \mbox{Echo Dam to 75 mph sign} & 70 \\ \hline
39 & 36 & 65 & \mbox{75 mph sign to Evanston} & 75 \\ \hline
308 & 269 & 68.7 & \mbox{Evanston to Laramie} & 75 \\ \hline
50.6 & 50 & 61.2 & \mbox{Laramie to Cheyenne} & 75 \\ \hline
43 & 37 & 69.7 & \mbox{Cheyenne to Pine bluffs} & 75 \\ \hline
\end{array}
$$
%18.1 / (20/60);
%11.3 / (12/60);
%9.1 / (13/60);
%5.7 / (7/60);
%16.5 / (18/60);
%39. /(36/60);
%
%308./ (4+29./60);
%51.0/(50/60);
%43. / (37/60);
%
%                              54.3
%                              56.3
%                          42.00000000
%                          48.85714286
%                          55.00000000
%                          65.00000000
%                          68.69888476
%                          61.20000000
%                          69.72972973

The {\bf velocity function} for the SUV is approximated by
\def\VPC{V_{\mbox{pc}}}
$$
\VPC{}(t) = \left\{
\begin{array}{ccl}
\mbox{Speed mph} & \mbox{Time interval minutes} & \mbox{Road segment} \\
\hline \\
54.3 & 0<t<20 & \mbox{Parley's Walmart to Kimball}  \\
56.3 & 20 < t < 32 & \mbox{Kimball to Wanship}\\
42.0 & 32 < t < 45 &\mbox{Wanship to Coalville}  \\
48.9 & 45 < t < 52 &\mbox{Coalville to Echo Dam}  \\
55.0 & 52 < t < 70 & \mbox{Echo Dam to 75 mph sign}  \\
65.0 & 70 < t < 106 &\mbox{75 mph sign to Evanston}  \\
68.7 & 106 < t < 375 & \mbox{Evanston to Laramie} \\
61.2 & 375 < t < 425 & \mbox{Laramie to Cheyenne}  \\
69.7 & 425 < t < 462 & \mbox{Cheyenne to Pine bluffs}  \\
0.00  & 462 < t < \infty & \mbox{SUV stopped}
\end{array}
\right.
$$


The velocity function $\VPC{}(t)$ is piecewise continuous, because it has the general form
$$f(t) = \left\{ \begin{array}{cc}
f_1(t) & t_1 < t < t_2 \\
f_2(t) & t_2 < t < t_3 \\
 \vdots & \vdots \\
f_n(t) & t_n < t < t_{n+1} \\
\end{array}\right.
$$
where functions $f_1,f_2, \ldots, f_n$ are {\bf continuous on the whole real line $-\infty < t < \infty$}. We don't define $f(t)$ at division points, because of many possible ways to make the definition. As long as these values are not used, then it will make no difference. Both right and left hand limits exist at a division point. For Laplace theory, we like the definition $f(t_k)=\lim_{h\to 0+} f(t_k+h)$, which makes the function right-continuous.

\rule{\textwidth}{0.5ex}
{\Large\bf The Problem}. The SUV travels from $t=0$ to $t=\frac{462}{60}=7.7$ hours. The odometer {\sf trip meter reading} $x(t)$ is in miles (assume $x(0)=0$). The function $\VPC{}(t)$ is an approximation to the {\sf speedometer reading}. Laplace's method can solve the approximation model
$$\frac{dx}{dt} = \VPC{}(60t),\quad x(0)=0,\quad \mbox{$x$ in miles, $t$ in hours},$$
obtaining $x(t)=\int_0^t \VPC(60w)dw$, the same result as the method of quadrature.
Show the details. Then display the piecewise linear continuous trip meter reading $x(t)$.

{\bf Solution}.

{\bf Method of Quadrature}. The meaning of the differential equation is that $x'(t)$ is piecewise continuous.
We want $x(t)$ to be continuous, because it is the odometer trip meter reading.
But $x'(t)$ cannot be continuous, if we require $\frac{dx}{dt} = \VPC{}(60t)$,
because the right side is piecewise defined and discontinuous at division points.

{\bf Theorem} (Fundamental Theorem of Calculus)\\
{\sf If $f'(x)$ is piecewise continuous and $f(x)$ is continuous on $a\le x \le b$, then $\int_a^b f'(x)dx = f(b)-f(a)$.

The theorem implies that the method of quadrature works for the equation
$x'(t)=\VPC{}(60t)$. The quadrature method gives the correct
answer
$$x(t) = \int_0^t \VPC{}(60w)dw.$$

Another plan is to
split $x'(t)=\VPC{}(60t)$ into 10 simple equations, $x'=54.3$,
$x(0)=0$ on $0\le t <20$ being the first equation. The next equation
is $x'=56.3$, $x(20)=x_0$, on $20<t<32$. To make $x(t)$ continuous,
we must choose $x_0=1086$, which is the value at the division point
$t=20$ assumed by the first problem ($x'=54.3$, $x(0)=0$ on $0\le t
<20$). This tedious process has to be continued for all 10 segments.
The result is that $x(t)$ is {\bf piecewise linear} between division points.

{\bf Laplace's Method}. The piecewise continuous input $\VPC{}(60t)$ is of exponential order,
because it is zero after $t=462/60$. Laplace theory says it has a Laplace transform
$\L(\VPC{}(60t))$. Assuming a continuous solution $x(t)$, with $x'(t)$ piecewise continuous, then the equation to be satisfied is
$$s\L(x(t))-x(0) = \L(x'(t)) = \L(\VPC{}(60t)).$$
The {\bf Laplace integral theorem} implies
$$\L(x(t)) = \frac{1}{s}\L(\VPC{}(60t)) =  \L\left(\int_0^t \VPC{}(60w)dw\right).$$
Lerch's theorem then implies that the symbol $\L$ cancel from each side, giving the odometer
trip meter reading in terms of the integral of the piecewise continuous input $\VPC{}(60t)$:
$$ x(t) = \int_0^t \VPC{}(60w)dw.$$
We'll use technology to program and evaluate the integral, even though it can be done by hand.
The plan is to plot the trip meter reading, then comment on the slow and fast segments
of the route, by using a clever plot involving the average speed. The last display is the piecewise linear trip meter reading $x(t)$.

\subsection*{Maple}
\begin{verbatim}
 Xpc:=t->piecewise(t<0,0,
 t < 20 ,54.3, t < 32, 56.3, t < 45, 42,  t < 52, 48.9,
 t < 70 ,55, t < 106, 65, t < 375, 68.7, t < 425, 61.2,
 t < 462, 69.7, 0.0);
 X:=t->int(Xpc(60*w),w=0..t);
 plot(X(t),t=0..480/60); # Almost a straight line.
\end{verbatim}


%\includegraphics[scale=0.5]{figures/distance-x-of-t.png}

%\begin{center}
%\bf Odometer Trip Meter Reading versus Time in Hours \\
%The flat spot means the SUV is stationary.\end{center}

\subsection*{Average Speed}

Define the average value of a function $f(w)$ on $a\le w \le b$ by $\frac{1}{b-a}\int_a^b f(w)dw$.
Then the average speed in the example is
$$\frac{\int_0^{462/60} \VPC{}(60w)dw }{462/60} = 65.14956710.$$

\subsection*{A Clever Plot}

An average driver would try to maintain $65.15$ mph. The clever plot will create a graphic of $x(t)-65.15t$ on interval $0\le t \le T_1$, where $T_1$ is the $471$ mile trip time at $65.15$ mph.

\begin{verbatim}
# Maple code
 Xpc:=t->piecewise(t<0,0,
 t < 20 ,54.3, t < 32, 56.3, t < 45, 42,  t < 52, 48.9,
 t < 70 ,55, t < 106, 65, t < 375, 68.7, t < 425, 61.2,
 t < 462, 69.7, 0.0);
 X:=t->int(Xpc(60*w),w=0..t);
 AVEspeed:=X(462/60)/(462/60); # AVEspeed = 65.14956710 mph
 T1:=solve(AVEspeed*t=471,t);  # T1 = 7.229518491 hours
 plot(X(t)-AVEspeed*t,t=0..T1);
\end{verbatim}

\includegraphics[scale=0.7]{figures/clever-plot.png}

We see from the graphic that segments of the road cause a slowdown of up to 15 mph, but for a brief interval it is possible to exceed the average speed, due to a 75 mph speed limit.

\begin{verbatim}
# Maple code for piecewise linear display
X:=t->int(Xpc(60*w),w=0..t);
convert(X(t),piecewise,t):evalf(%,4);
\end{verbatim}

\bigskip

Trip meter at time $t$ = $\cases{ 0.0&$t\leq  0.0$\cr
  54.30\,t&$t\leq  0.3333$\cr
    56.30\,t- 0.6667&$t\leq  0.53$\cr
      42.0\,t+ 6.960&$t\leq  0.75$\cr
        48.90\,t+ 1.785&$t\leq  0.8667$\cr
          55.0\,t- 3.502&$t\leq  1.167$\cr
            65.0\,t- 15.17&$t\leq  1.767$\cr
              68.70\,t- 21.70&$t\leq  6.25$\cr
                61.20\,t+ 25.17&$t\leq  7.083$\cr
                  69.70\,t- 35.04&$t\leq  7.7$\cr
                    501.7&$ 7.7<t$
                    }$

%{\bf Freeway Driving}. A number of drivers exceed the speed limit on
%straight sections of the roadway, usually by 10 mph or less, to
%avoid traffic fines. This is why you will be driving 65 mph, an
%average speed in a 75 mph zone, and be passed by drivers going 85
%mph. The 20 mph differential in speed is hazardous, a fact
%recognized by the Highway Patrol and the Department of
%Transportation. Their advice for drivers it to match highway speeds
%to within 10 mph. Slow drivers should speed up and fast drivers
%should slow down, to make it so.
%
%{\bf City Driving}. Driver behavior in city streets, speed limits 30
%to 45 mph, is also predictable. Each time a driver passes another
%vehicle, they check their speedometer reading, and slow down if the
%tolerance is more than 4-7 mph. This behavior is not about avoiding
%traffic violations, but about saving transit time. Arriving at a
%light early means hit the brakes and reduce gas mileage, then
%increase the transit time, plus arrive too early at the next light,
%waste more fuel, and again increase transit time.


\end{document}
\endinput 
