# This worksheet contains the Maple commands from Chapter 8 of # Introduction to Scientific Programming by Joseph L. Zachary. # # (8.1) We record the mass, maximum power output, and drag coefficient # for the destroyer. # > mass := 4.5e6; > maxPower := 5e6; > drag := 5.5e3; # # (8.2) We define a symbolic expression that gives the position of the # destroyer in terms of t. We will be ignoring the effects of drag in # the first part of this worksheet. # > pos := .032 * t^2; # # (8.3) We plot the position of the destroyer when it is near the # origin. # > plot(pos, t=-100..100, > labels=[`time (seconds)`, `position (meters)`], > title=`Position of the destroyer`); # # (8.4) We plot the position of the destroyer for positive times. # > plot(pos, t=0..200, > labels=[`time (seconds)`, `position (meters)`], > title=`Position of the destroyer`); # # (8.6) The velocity of the destroyer is the first derivative of # position. # > vel := diff(pos, t); # # (8.7) The acceleration of the destroyer is the first derivative of # velocity. # > acc := diff(vel, t); # # (8.8) The force required to move the destroyer along its trajectory # is the product of mass and acceleration. # > force := mass * acc; # # (8.9) The power required to move the destroyer along its trajectory # is the product of force and velocity. # > pow := force * vel; # # (8.10) We plot the power required to move the destroyer when it is # close to the origin. # > plot(pow/1e6, t=-100..100, > labels=[`time (seconds)`, `power (megawatts)`], > title=`Power required for trajectory .032*t^2, no drag`); # # (8.11) We plot the absolute value of the power required to move the # destroyer when it is close to the origin. # > plot(abs(pow)/1e6, t=-100..100, > labels=[`time(seconds)`, `power (megawatts)`], > title=`Magnitude of power required for trajectory .032*t^2, no > drag`); # # (8.12) We use solve to find the two times at which the maximum power # capacity of the destroyer is reached. # > threshold := solve(abs(pow) = maxPower, t); # # (8.13) The solution to (8.12) is a sequence of two values. # > threshold; # # (8.14) We calculate the speed of the destroyer when it is at the # first power threshold. We extract the first value of the sequence by # subscripting with 1. # > .064 * threshold[1]; # # (8.15) We calculte the speed of the destroyer when it is at the # second power threshold. We extract the second value of the sequence # by subscripting with 2. # > .064 * threshold[2]; # # (8.16) We use subs to substitute a value for t into the velocity # expression. # > subs(t = threshold[1], vel); # # (8.17) We create a function makePower to calculate the power # required, in the absence of drag, at any point of time along an # arbitrary trajectory. Here, pos is the trajectory expression (which # must be a symbolic expression in t) and mass is the mass of the # destroyer. In the body of the function, we use the diff function to # determine velocity and acceleration functions. # > makePower := (pos, mass) -> mass * diff(diff(pos,t),t) * diff(pos,t); # # (8.18) We use makePower to calculate the power required to follow # trajectory pos. As expected, we get the same result as in (8.9). # > pow := makePower(pos, mass); # # (8.19) We calculate power expressions corresponding to two new # trajectories. # > pow1 := makePower(.016 * t^2, mass); > pow2 := makePower(.002 * t^2, mass); # # (8.20) We find the times at which power threshold is reached for the # first of the new trajectories. # > threshold1 := solve(abs(pow1) = maxPower, t); # # (8.21) We find the velocity corresponding to the first power # threshold for the first of the new trajectories. # > subs(t = threshold1[1], diff(.016*t^2, t)); # # (8.22) We find the times at which power threshold is reached for the # second of the new trajectories. # > solve(abs(pow2) = maxPower, t); # # (8.23) We find the power required to follow a constant-velocity # trajectory (in the absence of drag). # > makePower(v*t, mass); # # (8.24) This function computes the power expression for a destroyer of # the given mass and drag coefficient that is following the trajectory # pos (where pos must be a symbolic expression in t). For the remainder # of this worksheet, we will consider the effects of drag on power # requirements. # > makePowerDrag := (pos, mass, drag) -> (mass * diff(diff(pos,t),t) + > drag * diff(pos,t)) * diff(pos,t); # # (8.25) We calculate a power expression for a destroyer following our # original trajectory of .032*t^2. # > pow := makePowerDrag(pos, mass, drag); # # (8.26) We plot the power consumption calculated in (8.25). # > plot(pow/1e6, t=-100..100, > labels=[`time (seconds)`, `power (megawatts)`], > title=`Power required for trajectory .032*t^2, with drag`); # # (8.27) We find the power in watts required at times 100 and -100 # seconds when following the tajectory .032*t^2. # > abs(subs(t = 100, pow)); > abs(subs(t = -100, pow)); # # (8.28) We plot the power consumption calculated in (8.25) over a # different time range than we used in (8.26). # > plot(pow/1e6, t=-1000..200, > labels=[`time (seconds)`, `power(megawatts)`], > title=`Power required for trajectory .032*t^2, with drag`); # # (8.29) We determine the times at which the power threshold is reached # when following the trajectory from (8.25). # > solve(pow = maxPower, t); # # (8.30) We determine the power required to follow a constant-velocity # trajectory (in the presence of drag). # > constantPower := makePowerDrag(v*t, mass, drag); # # (8.31) We find the maximum sustainable velocities (in m/sec) for the # destroyer in the presence of drag. # > solve(constantPower = maxPower, v); # # (8.33) We define a piecewise trajectory in which the destroyer begins # at a rest, moves 10,000 meters, and ends at rest. # > move := piecewise(t < -500, -5000, > t < 500, 5000*sin(Pi*t/1000), > 5000); # # (8.34) We plot the piecewise trajectory from (8.33). # > plot(move, t=-600..600, > labels=[`time (seconds)`, `position (meters)`], > title=`A Piecewise Trajectory`); # # (8.35) We plot the power required to follow the piecewise trajectory # from (8.34). # > plot(makePowerDrag(move, mass, drag)/1e6, > t=-600..600, > labels=[`time (seconds)`, `power (megawatts)`], > title=`Power Required to Follow Piecewise Trajectory`); >