====== Differences ====== This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
gibson:teaching:fall-2012:math445:pf1-solns [2012/12/11 14:13] gibson created |
gibson:teaching:fall-2012:math445:pf1-solns [2012/12/11 14:22] (current) gibson |
||
---|---|---|---|
Line 137: | Line 137: | ||
<latex> | <latex> | ||
- | m = \frac{\Delta \log_{10} y}{\Delta x} \approx \frac{-2 - 0}{10 -2} = -1/4 | + | m = (\Delta \log_{10} y)/(\Delta x) \approx (-2 - 0)/(10 - 2) = -1/4 |
</latex> | </latex> | ||
Line 194: | Line 194: | ||
<latex> | <latex> | ||
- | dv_2/dt = d^2x/dt^2 = -3 d^x/d^t2 - sin x = -3 v_2 - sin v_1 | + | dv_2/dt = d^2x/dt^2 = -3 dx/dt - \sin x = -3 v_2 - \sin v_1 |
</latex> | </latex> | ||
- | So $dv/dt = [dv_1/dt, dv_2/dt] = [v_2, -3 v_2 - sin v_1]$ | + | So $dv/dt = [dv_1/dt, dv_2/dt] = [v_2, -3 v_2 - \sin v_1]$ |
Line 219: | Line 219: | ||
$v_y$ represents the vertical velocity. Represent the two free variables | $v_y$ represents the vertical velocity. Represent the two free variables | ||
with the vector $x = [y, ~v_y]$ and reexpress the two equations above as | with the vector $x = [y, ~v_y]$ and reexpress the two equations above as | ||
- | an ODE system of the form | + | an ODE system of the form $dx/dt = f(x)$ (both sides of that equation are vectors). |
- | $dx/dt = f(x)$ | ||
- | |||
- | Note that both sides of this equation are vectors: $dx/dt = [dx_1/dt, ~dx_2/dt]$ and | ||
- | $f(x) = [f_1(x_1, x_2), ~f_2(x_1, x_2)]$. Your job is to find the functions $f_1$ and $f_2$. | ||
Line 235: | Line 231: | ||
</latex> | </latex> | ||
- | So $dx/dt = [x_2, -g - \mu x_2 |x_2|]$ | + | So $dx/dt = [x_2, ~-g - \mu x_2 |x_2|]$ |
Line 243: | Line 239: | ||
from the initial conditions $x(0) = [y(0), ~v_y(0)] = [0, 0]$. | from the initial conditions $x(0) = [y(0), ~v_y(0)] = [0, 0]$. | ||
+ | <code> | ||
g = 9.81; | g = 9.81; | ||
mu = 0.35; | mu = 0.35; | ||
f = @(x) [x(2) ; -g - mu*x(2)*abs(x(2)]; | f = @(x) [x(2) ; -g - mu*x(2)*abs(x(2)]; | ||
- | [t, x] = ode45(f, 0:100, [0 ; 0]); | + | [t, X] = ode45(f, 0:100, [0 ; 0]); |
+ | </code> | ||
Line 254: | Line 251: | ||
Label the axes. | Label the axes. | ||
- | plot(t, x(:,1)) % first column of x is 1st component of x as a function of time | + | plot(t, X(:,1)) % first column of returned X is 1st component of x as a function of time |
xlabel('t') | xlabel('t') | ||
ylabel('y = height of ball') | ylabel('y = height of ball') | ||
Line 281: | Line 278: | ||
of A. | of A. | ||
+ | <code> | ||
function y = sparse_matvec_mult(A,x) | function y = sparse_matvec_mult(A,x) | ||
K = nnz(A); | K = nnz(A); | ||
Line 292: | Line 290: | ||
end | end | ||
end | end | ||
+ | </code> |