bookvol10.4 STTAYLOR +-> conversion

20090621.07.tpd.patch bookvol10.4 STTF +-> conversion

+20090621.08.tpd.patch +spline.input explain how to compute 2D splines

diff --git a/src/input/Makefile.pamphlet b/src/input/Makefile.pamphlet index 0b4f2bd..c471a15 100644 --- a/src/input/Makefile.pamphlet +++ b/src/input/Makefile.pamphlet @@ -362,7 +362,7 @@ REGRES= algaggr.regress algbrbf.regress algfacob.regress alist.regress \ realclos.regress reclos.regress reclos2.regress regset.regress \ repa6.regress robidoux.regress \ roman.regress roots.regress ruleset.regress rules.regress \ - sae.regress \ + sae.regress spline.regress \ schaum1.regress schaum2.regress schaum3.regress schaum4.regress \ schaum5.regress schaum6.regress schaum7.regress schaum8.regress \ schaum9.regress schaum10.regress schaum11.regress schaum12.regress \ @@ -664,7 +664,7 @@ FILES= ${OUT}/algaggr.input ${OUT}/algbrbf.input ${OUT}/algfacob.input \ ${OUT}/reclos.input ${OUT}/reclos2.input ${OUT}/regset.input \ ${OUT}/robidoux.input ${OUT}/roman.input ${OUT}/roots.input \ ${OUT}/ruleset.input ${OUT}/rules.input ${OUT}/sae.input \ - ${OUT}/schaum1.input \ + ${OUT}/spline.input ${OUT}/schaum1.input \ ${OUT}/schaum2.input ${OUT}/schaum3.input ${OUT}/schaum4.input \ ${OUT}/schaum5.input ${OUT}/schaum6.input ${OUT}/schaum7.input \ ${OUT}/schaum8.input ${OUT}/schaum9.input ${OUT}/schaum10.input \ @@ -990,7 +990,7 @@ DOCFILES= \ ${DOC}/robidoux.input.dvi ${DOC}/roman.input.dvi \ ${DOC}/romnum.as.dvi ${DOC}/roots.input.dvi \ ${DOC}/ruleset.input.dvi ${DOC}/rules.input.dvi \ - ${DOC}/sae.input.dvi \ + ${DOC}/spline.input.dvi ${DOC}/sae.input.dvi \ ${DOC}/schaum1.input.dvi ${DOC}/schaum2.input.dvi \ ${DOC}/schaum3.input.dvi ${DOC}/schaum4.input.dvi \ ${DOC}/schaum5.input.dvi ${DOC}/schaum6.input.dvi \ diff --git a/src/input/spline.input.pamphlet b/src/input/spline.input.pamphlet new file mode 100644 index 0000000..e1b710f --- /dev/null +++ b/src/input/spline.input.pamphlet @@ -0,0 +1,400 @@ +\documentclass{article} +\usepackage{axiom} +\begin{document} +\title{\$SPAD/src/input spline.input} +\author{Timothy Daly} +\maketitle +\begin{abstract} +This is a problem picked up from a youtube lecture broadcast from the +University of Southern Florida called ``Quadratic Spline Interpolation''. +\cite{1} +\end{abstract} +\newpage +\tableofcontents +\newpage +\begin{chunk}{*} +)set break resume +)sys rm -f spline.output +)spool spline.output +)set message test on +)set message auto off +)clear all + +\end{chunk} +The upward velocity of a rocket is given as a function of time. +Using quadratic splines +\begin{enumerate} +\item find the velocity at t=16 seconds +\item find the acceleration at t=16 seconds +\item find the distance covered between t=11 and t=16 seconds +\end{enumerate} +\begin{tabular}{|c|c|} +t & v(t)\\ +\hline +s & m/s\\ +\hline + 0 & 0\\ +10 & 227.04\\ +15 & 362.78\\ +20 & 517.35\\ +22.5 & 602.97\\ +30 & 901.67 +\end{tabular} + +We are using quadratic splines to approximate the trajectory and +estimate the values. There are 5 equations: +\[v(t)=a_1t^2 + b_1t +c_1\quad 0 \le t \le 10\] +\[v(t)=a_2t^2 + b_2t +c_2\quad 10 \le t \le 15\] +\[v(t)=a_3t^2 + b_3t +c_3\quad 15 \le t \le 20\] +\[v(t)=a_4t^2 + b_4t +c_4\quad 20 \le t \le 22.5\] +\[v(t)=a_5t^2 + b_5t +c_5\quad 22.5 \le t \le 30\] + +Thus, there are 15 unknowns: +\[ a_1,a_2,a_3,a_4,a_5,\; b_1,b_2,b_3,b_4,b_5,\; c_1,c_2,c_3,c_4,c_5\] + +So we need to develop 15 equations. + +We can get the first 10 equations because the splines need to go +thru the endpoints. + +From the first two data points $[0,0]$ and $[10,227.04]$ +we know that the first spline goes through both data points: +\[v(t)=a_1t^2 + b_1t +c_1\quad 0 \le t \le 10\] +\[v(0)=a_1(0)^2 + b_1(0) +c_1=0\] +\[v(0)=a_1(10)^2 + b_1(10) +c_1=0\] + +The next set of equations come from the points $[10,227.04]$ and $[15,362.78]$ +since the second spline goes thru these points: +\[v(t)=a_2t^2 + b_2t +c_2\quad 10 \le t \le 15\] +\[v(10)=a_2(10)^2 + b_2(10) +c_2=227.04\] +\[v(15)=a_2(15)^2 + b_2(15) +c_2=362.78\] + +The next set of equations come from the points $[15,362.78]$ and $[20,517.35]$ +since the third spline goes thru these points: +\[v(t)=a_3t^2 + b_3t +c_3\quad 15 \le t \le 20\] +\[v(15)=a_3(15)^2 + b_3(15) +c_3 = 362.78\] +\[v(20)=a_3(20)^2 + b_3(20) +c_3 = 517.35\] + +The next set of equations come from the points $[20,517.35]$ and +$[22.5,602.97]$ since the fourth spline goes thru these points: +\[v(t)=a_4t^2 + b_4t +c_4\quad 20 \le t \le 22.5\] +\[v(20)=a_4(20)^2 + b_4(20) +c_4 = 517.35\] +\[v(22.5)=a_4(22.5)^2 + b_4(22.5) +c_4 = 602.97\] + +The next set of equations come from the points $[22.5,602.97]$ and +$[30,901.67]$ since the fifth spline goes thru these points: +\[v(t)=a_5t^2 + b_5t +c_5\quad 22.5 \le t \le 30\] +\[v(22.5)=a_5(22.5)^2 + b_5(22.5) +c_5 = 602.97\] +\[v(30)=a_5(30)^2 + b_5(30) +c_5 = 901.67\] + +The next four equations come from the constraint that the slope of +each of these curves has to match at the point where they touch. +This means that they must have the same derivative at that point. + +We skip the endpoint 0 since this is unconstrained. The point +$x=10$ has two equations that are valid at that point: +\[v(t)=a_1t^2 + b_1t +c_1\quad 0 \le t \le 10\] +\[w(t)=a_2t^2 + b_2t +c_2\quad 10 \le t \le 15\] + +We compute the derivative of each equation, set them equal, and +evaluate the result at the common point $x=10$: +\[\frac{d}{dt}\left. (a_1t^2 + b_1t +c_1)\right|_{t=10}= + \frac{d}{dt}\left. (a_2t^2 + b_2t +c_2)\right|_{t=10}\] +\[\left.(2a_1t+b_1)\right|_{t=10} = \left.(2a_2t+b_2)\right|_{t=10}\] +\[2a_1(10)+b_1 = 2a_2(10)+b_2\] +\[20a_1+b_1-20a_2-b_2=0\] + +We do this with the second pair: +\[\frac{d}{dt}\left. (a_2t^2 + b_2t +c_2)\right|_{t=15}= + \frac{d}{dt}\left. (a_3t^2 + b_3t +c_3)\right|_{t=15}\] +\[\left.(2a_2t+b_2)\right|_{t=15} = \left.(2a_3t+b_3)\right|_{t=15}\] +\[2a_2(15)+b_2 = 2a_3(15)+b_3\] +\[30a_2+b_2-30a_3-b_3=0\] + +We do this with the third pair: +\[\frac{d}{dt}\left. (a_3t^2 + b_3t +c_3)\right|_{t=20}= + \frac{d}{dt}\left. (a_4t^2 + b_4t +c_4)\right|_{t=20}\] +\[\left.(2a_3t+b_2)\right|_{t=20} = \left.(2a_4t+b_3)\right|_{t=20}\] +\[2a_3(20)+b_3 = 2a_4(20)+b_4\] +\[40a_3+b_3-40a_4-b_4=0\] + +We do this with the fourth pair: +\[\frac{d}{dt}\left. (a_4t^2 + b_4t +c_4)\right|_{t=22.5}= + \frac{d}{dt}\left. (a_5t^2 + b_5t +c_5)\right|_{t=22.5}\] +\[\left.(2a_4t+b_4)\right|_{t=22.5} = \left.(2a_5t+b_5)\right|_{t=22.5}\] +\[2a_4(22.5)+b_4 = 2a_5(22.5)+b_5\] +\[45a_4+b_4-45a_5-b_5=0\] + +We have 14 of the 15 needed equations. + +The $t=0$ and $t=30$ points are exterior and only have 1 spline. +We create the 15th equation by assuming a linear equation at $t=0$: +\[a_1=0\] +which implies that +\[v(t)=a_1t^2+b_1+c_1=0\] +becomes +\[v(t)=(0)t^2+b_1+c_1=0\] +\[v(t)=b_1+c_1=0\] + +These can be created into a matrix equation of 15 equations and 15 unknowns. +\[\left[\begin{array}{ccccccccccccccc} + 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ +100 & 10 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 100 & 10 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 225 & 15 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 225 & 15 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 400 & 20 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 400 & 20 & 1 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 506.25 & 22.5 & 1 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 506.25 & 22.5 & 1\\ + 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 900 & 30 & 1\\ + 20 & 1 & 0 & -20 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 30 & 1 & 0 & -30 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 40 & 1 & 0 & -40 & -1 & 0 & 0 & 0 & 0\\ + 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 45 & 1 & 0 & -45 & -1 & 0\\ + 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ +\end{array}\right] +\left[\begin{array}{c} + a_1 \\ + b_1 \\ + c_1 \\ + a_2 \\ + b_2 \\ + c_2 \\ + a_3 \\ + b_3 \\ + c_3 \\ + a_4 \\ + b_4 \\ + c_4 \\ + a_5 \\ + b_5 \\ + c_5 \\ +\end{array}\right] += +\left[\begin{array}{c} + 0 \\ + 227.04 \\ + 227.04 \\ + 362.78 \\ + 362.78 \\ + 517.35 \\ + 517.35 \\ + 602.97 \\ + 602.97 \\ + 901.67 \\ + 0 \\ + 0\\ + 0 \\ + 0 \\ + 0 \\ +\end{array}\right]\] + +The coefficient matrix is: +\begin{chunk}{*} +--S 1 of 16 +incoef:=[_ +[0 , 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],_ +[100, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 100, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 225, 15, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 225, 15, 1, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 400, 20, 1, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 20, 1, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 506.25, 22.5, 1, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 506.25, 22.5, 1],_ +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 900, 30, 1],_ +[ 20, 1, 0, -20, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 30, 1, 0, -30, -1, 0, 0, 0, 0, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 40, 1, 0, -40, -1, 0, 0, 0, 0],_ +[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 1, 0, -45, -1, 0],_ +[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +--R +--R +--R (1) +--R [[0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [100.0,10.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,100.0,10.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,225.0,15.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,225.0,15.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,400.0,20.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,400.0,20.0,1.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,506.25,22.5,1.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,506.25,22.5,1.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,900.0,30.0,1.0], +--R [20.0,1.0,0.0,- 20.0,- 1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,30.0,1.0,0.0,- 30.0,- 1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,40.0,1.0,0.0,- 40.0,- 1.0,0.0,0.0,0.0,0.0], +--R [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,45.0,1.0,0.0,- 45.0,- 1.0,0.0], +--R [1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]] +--R Type: List List Float +--E 1 + +\end{chunk} +and the values are: +\begin{chunk}{*} +--S 2 of 16 +vals:Vector(Float):=_ +[0,227.04,227.04,362.78,362.78,517.35,517.35,602.97,602.97,901.67,0,0,0,0,0] +--R +--R +--R (2) +--R [0.0, 227.04, 227.04, 362.78, 362.78, 517.35, 517.35, 602.97, 602.97, +--R 901.67, 0.0, 0.0, 0.0, 0.0, 0.0] +--R Type: Vector Float +--E 2 + +--S 3 of 16 +digits(5) +--R +--R +--R (3) 20 +--R Type: PositiveInteger +--E 3 + +--S 4 of 16 +outcoef:=solve(incoef,vals) +--R +--R +--R (4) +--R [ +--R particular = +--R [0.0, 22.704, 0.0, 0.88882, 4.926, 88.888, - 0.1356, 35.66, - 141.6, +--R 1.6045, - 33.94, 554.41, 0.20905, 28.851, - 152.01] +--R , +--R basis= [[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]]] +--RType: Record(particular: Union(Vector Float,"failed"),basis: List Vector Float) +--E 4 + +--S 5 of 16 +D:=outcoef.particular +--R +--R +--R (5) +--R [0.0, 22.704, 0.0, 0.88882, 4.926, 88.888, - 0.1356, 35.66, - 141.6, 1.6045, +--R - 33.94, 554.41, 0.20905, 28.851, - 152.01] +--R Type: Union(Vector Float,...) +--E 5 + +--S 6 of 16 +s1:=D.1*t^2+D.2*t+D.3 +--R +--R +--R (6) 22.704 t +--R Type: Polynomial Float +--E 6 + +--S 7 of 16 +s2:=D.4*t^2+D.5*t+D.6 +--R +--R +--R 2 +--R (7) 0.88882 t + 4.926 t + 88.888 +--R Type: Polynomial Float +--E 7 + +--S 8 of 16 +s3:=D.7*t^2+D.8*t+D.9 +--R +--R +--R 2 +--R (8) - 0.1356 t + 35.66 t - 141.6 +--R Type: Polynomial Float +--E 8 + +--S 9 of 16 +s4:=D.10*t^2+D.11*t+D.12 +--R +--R +--R 2 +--R (9) 1.6045 t - 33.94 t + 554.41 +--R Type: Polynomial Float +--E 9 + +--S 10 of 16 +s5:=D.13*t^2+D.14*t+D.15 +--R +--R +--R 2 +--R (10) 0.20905 t + 28.851 t - 152.01 +--R Type: Polynomial Float +--E 10 + +\end{chunk} +What is the velocity at $t=16$? +\begin{chunk}{*} +--S 11 of 16 +s3(16) +--R +--R +--R (11) 394.26 +--R Type: Float +--E 11 + +\end{chunk} +What is the acceleration at $t=16$ +\begin{chunk}{*} +--S 12 of 16 +s3d:=differentiate(s3,t) +--R +--R +--R (12) - 0.27112 t + 35.66 +--R Type: Polynomial Float +--E 12 + +--S 13 of 16 +s3d(16) +--R +--R +--R (13) 31.323 +--R Type: Float +--E 13 + +\end{chunk} +Find the distance covered by the rocket from $t=11$ to $t=16$ + +Here we would want to do +\[\int_{11}^{16}\] +but this uses two spline approximations so we have to break the +integration at the interior point and compute: +\[\int_{11}^{16}=\int_{11}^{15} s2 + \int_{15}^{16} s3\] +\begin{chunk}{*} +--S 14 of 16 +s2i:=integrate(s2,t) +--R +--R +--R 3 2 +--R (14) 0.29628 t + 2.463 t + 88.888 t +--R Type: Polynomial Float +--E 14 + +--S 15 of 16 +s3i:=integrate(s3,t) +--R +--R +--R 3 2 +--R (15) - 0.045187 t + 17.83 t - 141.6 t +--R Type: Polynomial Float +--E 15 + +\end{chunk} +Now we can evaluate the difference of both of these integrals +at their endpoints and sum the results to get the answer. +\begin{chunk}{*} +--S 16 of 16 +(s2i(15)-s2i(11)) + (s3i(16)-s3i(15)) +--R +--R +--R (16) 1595.9 +--R Type: Float +--E 16 + +)spool +)lisp (bye) + +\end{chunk} +\newpage +\begin{thebibliography}{99} +\bibitem{1} {\bf http://www.youtube.com/watch?v=ES5zkgyMeAM} +\end{thebibliography} +\end{document}