## DESCRIPTION ## ## ## Randomization: ## ## ## ENDDESCRIPTION ## Author('Richard G. Lynch') ################################################################################ # Initialization ################################################################################ DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl", "contextFraction.pl", "PGchoicemacros.pl", ); TEXT(beginproblem()); ################################################################################ # Problem Setup ################################################################################ Context("Fraction"); Context()->noreduce('(-x)-y'); Context()->noreduce('(-x)-y','(-x)+y'); do { $check = 1; do { @n = ((-9..-2),(2..9))[shuffle(16)]; @b = (2,4,5,2,4,5,2,4,5,2,4,5,2,4,5,2,4,5)[shuffle(18)];$cntb = 0; for ($i = 0;$i < 4; $i++) { ($n[$i],$b[$i]) = reduce($n[$i],$b[$i]);$f[$i] = Fraction($n[$i],$b[$i])->reduce;$df[$i] = dfrac($f[$i]); for ($j = 0; $j <$i; $j++) {$check = 0 if $f[$i] == $f[$j]; $cntb += 1 if$b[$i] ==$b[$j]; }$check = 0 if floor($f[$i]) == $f[$i]; } } until ($f[2] !=$f[0]); # prevent divide by zero $m1 = (($f[3]-$f[1])/($f[2]-$f[0]))->reduce; } until ($check && $m1 != floor($m1) && $cntb <= 2); sub dfrac { my ($n) = @_; my ($a,$b) = reduce($n->value); my ($pa,$pb) = (abs($a),abs($b)); my$dfrac = ($n > 0) ? "" : "-"; return$dfrac."\dfrac{$pa}{$pb}"; } $case = random(0,1); # zero slope or DNE @numsb = (1..10)[shuffle(10)]; if ($case) { @yb = (random(-1,1,2)*$numsb[0],random(-1,1,2)*$numsb[1]); $yb[1] = -sgn($yb[0])*$yb[1]; @xb = (random(-1,1,2)*$numsb[2],$numsb[2]);$xb[1] = sgn($xb[0])*$xb[1]; } else { @xb = (random(-1,1,2)*$numsb[0],$numsb[1]); $xb[1] = -sgn($xb[0])*$xb[1]; @yb = (random(-1,1,2)*$numsb[2],$numsb[2]);$yb[1] = sgn($yb[0])*$yb[1]; } Context("LimitedFraction"); Context()->flags->set(tolerance => 0, tolType => "absolute"); Context()->flags->set(showMixedNumbers=>0); Context()->parens->redefine('('); $message = "Each answer should be a reduced integer or fraction, or DNE"; Context()->{error}{msg}{"Can't use '%s' in this context"} =$message; Context()->{error}{msg}{"Can't use implied multiplication in this context"} = $message; Context()->{error}{msg}{"Unexpected character '['"} = "Brackets are not allowed";$m1 = Fraction($m1);$m2 = ($case) ? String("DNE") : Fraction("0"); ################################################################################ # Text ################################################################################ BEGIN_PGML >> *TAMU_QID:* BM_00033 [$HR]* Determine the slope of the line passing through the given points. Enter *DNE* in the blank if the slope does not exist. Enter all answers in exact, reduced form. No decimals are allowed. a. [\left([$df[0]],[$df[1]]\right)] and [\left([$df[2]],[$df[3]]\right)]: [\quad m = ] [__]{$m1} b. [\left([$xb[0]],[$yb[0]]\right)] and [\left([$xb[1]],[$yb[1]]\right)]: [\quad m = ] [__]{$m2->cmp(typeMatch => Fraction(1))} END_PGML ################################################################################ # Answers and Solutions ################################################################################ #BEGIN_HINT #END_HINT #BEGIN_PGML_SOLUTION #END_PGML_SOLUTION ENDDOCUMENT();