But now this is having problems in version 2.8.
Can you see a solution?
Many Thanks,
Problem8 ERROR caught by Translator while processing problem file:Payer/M105_HW_5/gravity_ball1.pg **************** ERRORS from evaluating PG file:
begin|||Undefined subroutine &main::reduce called at line 62 of (eval 26914) |||end
****************
------Input Read 1 ## DESCRIPTION 2 ## Rates of Change 3 ## ENDDESCRIPTION 4 5 ## Tagged by tda2d 6 7 ## DBsubject(Calculus - single variable) 8 ## DBchapter(Applications of differentiation) 9 ## DBsection(Rates of change - engineering and physics) 10 ## Institution(ASU) 11 ## Level(5) 12 ## KEYWORDS('Differentiation' 'Rates of Change') 13 14 # Library/ASU-topics/setQuadraticFunction/p4 15 # 16 # First comes some stuff that appears at the beginning of every problem 17 # 18 19 DOCUMENT(); # This should be the first executable line in the problem. 20 21 loadMacros( 22 "PG.pl", 23 "PGbasicmacros.pl", 24 "MathObjects.pl", 25 "PGanswermacros.pl", 26 "contextFraction.pl", 27 "PGcourse.pl", 28 ); 29 30 31 TEXT(beginproblem()); 32 33 # 34 # Now we do the randomization of variables, and other computations 35 # as needed for this problem. Sometimes we compute the answers here. 36 # 37 Context("Numeric"); 38 $h = random(200,400,10); 39 $b = random(10,32,2); 40 $b16 = -$b/16; 41 $bsq =$b16*$b16; 42 $b32 =-$b/32; 43 $b32p =$b/32; 44 $b32p = Compute("$b/32"); 45 $h16 = -$h/16; 46 $bt = -$bsq/4 +$h16; 47 $btp = -$bt; 48 $btpr =$btp**0.5; 49 $ta = $b/32; 50 $hmax = $h+($b**2)/64; 51 $tb = ($b+sqrt($b**2+64*$h))/32; 52 $ans3 = $btpr+$b32p; 53 $h = 32; 54 55 #Context("LimitedFraction"); 56 #$d = Compute("4 2/3"); 57 #$e = Compute("-1 1/2"); 58 #$b32p = Fraction($b,32); 59 60 Context("Fraction"); 61 62 ($br,$hr) = reduce($b,$h); 63 $frac1 =Compute("$b/$h"); 64 65 #Context("Fraction"); 66 #$b32p =$b/32; 67 #($b,32) = reduce($b,32); 68 #$frac =Compute("$m/$h"); 69 70 BEGIN_TEXT 71 A ball is thrown upward from the top of a building $h feet tall. 72 The height of the ball is described by the function 73 \( h(t) = - 16 t^2 +$b t + $h \), where \( t \) is in seconds and \( t = 0 \) 74 corresponds to the moment the ball is thrown. 75 $BR$BR 76 a) Determine for what value of \( t \) the ball reaches the maximum height and 77 determine this maximum height. 78 $BR$BR 79 \( t = \) \{ans_rule(20)\} 80 and maximum height = \{ans_rule(20)\} 81 $BR$BR 82 b) Determine when the ball reaches the ground. 83 $BR$BR 84 \( t = \) \{ans_rule(20)\} 85 END_TEXT 86 87 # 88 # Tell WeBWork how to test if answers are right. These should come in the 89 # same order as the answer blanks above. You tell WeBWork both the type of 90 # "answer evaluator" to use, and the correct answer. 91 # 92 93 ANS(num_cmp($ta)); 94 ANS(num_cmp($hmax, tolType=>"absolute",tol=>0.1)); 95 ANS(num_cmp($tb)); 96 97 98 SOLUTION(EV3(<<'END_SOLUTION')); 99 $PAR SOLUTION $PAR 100 101 To find the maximum height and the time it take to reach that height we must take the derivative of the quadratic function: \( h(t) = - 16 t^2 +$b t + $h\). By setting the derivative to zero we can solve for the critical point, `t`, the time at which the peak height occurred. Then we take the same `t` value and plug it into the original height function to determine the maximum height achieved. To determine the time when the ball reaches the ground we merely set the height function to zero and then solve for time, `t`. $BR 102 $PAR 103 ``\begin{aligned}&\\ 104 h(t) &= - 16 t^2 +$b t + $h\\ 105 h'(t) &= - 16 \left(t^2\right)' +$b t' + $h' && \text{Apply prime tics to each term. }\\ 106 h'(t) &= - 32 t +$b && \text{Apply the power rule to each term. }\\ 107 h'(t) &= - 32 t +$b = 0 && \text{Set the derivative to zero and solve for }t. \\ 108 -32 t &= - $b && \text{Isolate the term holding } t.\\ 109 t &= \frac{- $b}{-32} && \text{Divide by } -32.\\ 110 t &= $b32p && \text{The time in seconds to reach the maximum height. }\\ 111 h($frac1) &= - 16 \cdot ({$b32p})^2 +$b \cdot $b32p + $h && \text{Solve for the maximum height by inputting } h($b32p).\\ 112 h($b32p) &= $hmax && \text{The maximum height in feet. } 113 \end{aligned}`` 114 115 $BR 116 $BR 117 Now set `h(t) = 0` and then solve for `t` to find the time in seconds when the ball strikes the ground. $BR 118 $BR 119 ``\begin{aligned}&\\ 120 h(t) &= 0 \\ 121 - 16 t^2 +$b t + $h &= 0 && \text{Setting } h(t) = 0.\\ 122 \frac{-16 t^2}{-16} +\frac{$b t}{-16} + \frac{$h}{-16} &= 0 && \text{Divide each term by } -16.\\ 123 t^2 $b16 t $h16 &= 0 && \text{Prepare to complete the square. }\\ 124 t^2 $b16 t +\left(\frac{$b16}{2}\right)^2 - \left(\frac{$b16}{2}\right)^2 $h16 &= 0 && \text{Add and subtract half the middle coefficient squared.} \\ 125 t^2 $b16 t +\frac{$bsq}{4} - \frac{$bsq}{4} $h16 &= 0 && \text{Square both constants.} \\ 126 (t $b32)^2 - \frac{$bsq}{4} $h16 &= 0 && \text{Complete the square. } \\ 127 (t $b32)^2 $bt &= 0 && \text{Combine constants. } \\ 128 (t $b32)^2 &= $btp && \text{Isolate the square. } \\ 129 \sqrt{(t $b32)^2} &= \sqrt{$btp} && \text{Take the square root of both sides.} \\ 130 t $b32 &= $btpr && \text{Reduce.}\\ 131 t &= $btpr +$b32p && \text{Isolate }t.\\ 132 t &= $ans3 && \text{The time in seconds when the ball strikes the ground. } 133 \end{aligned}`` 134 $BR 135 136 137 END_SOLUTION 138 139 ENDDOCUMENT(); # This should be the last executable line in the problem.