## DBsubject(Algebra)
## DBchapter(Linear equations and functions)
## DBsection(Linear functions)
## Institution(W.H.Freeman)
## Author(Brian Kell)
## Level(3)
## MO(1)
## TitleText1('Calculus: Early Transcendentals')
## AuthorText1('Rogawski')
## EditionText1('2')
## Section1('1.2')
## Problem1('29')
## KEYWORDS('calculus', 'algebra', 'coordinates', 'linear equations')

DOCUMENT();
loadMacros(
  "PGstandard.pl",
  "Parser.pl",
  "freemanMacros.pl",
  "PGcourse.pl"
);

TEXT(beginproblem());

($p, $r) = list_random_multi_uniq(2, -10..10);
($q, $s, $t) = list_random_multi_uniq(3, -10..10);

$b = bkell_simplify_fraction_string(($t-$q)*($p-$r)+$p*($q-$s), $q-$s, "[");

Context()->texStrings;
BEGIN_TEXT
\{ textbook_ref_exact("Rogawski ET 2e", "1.2", "29") \}
$PAR
Find \(c\) such that \( ($p,$q) \), \( ($r,$s) \), and \( (c,$t) \) lie on a
line.
$PAR
\( c = \) \{ans_rule()\}
END_TEXT
Context()->normalStrings;

ANS(Compute($b)->cmp);

$b_frac = bkell_simplify_fraction_string(($t-$q)*($p-$r)+$p*($q-$s), $q-$s, "f");
$p_str = ($p >= 0 ? "$p" : "($p)");
$q_str = ($q >= 0 ? "$q" : "($q)");
$r_str = ($r >= 0 ? "$r" : "($r)");
$r_str_2 = ($r > 0 ? "-$r" : $r < 0 ? "+".(-$r) : "");
$s_str = ($s >= 0 ? "$s" : "($s)");
$num = $t-$s;
$num_sign = ($num >= 0 ? "" : "-");
$num_abs = abs $num;
$slope = bkell_simplify_fraction_string($s-$q, $r-$p, "f");

Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR
$SOL
$PAR
The slope of the line determined by the points \( ($p,$q) \) and \( ($r,$s) \)
is
\[ {$s-$q_str \over $r-$p_str}=$slope. \]
To lie on the same line, the slope between \( ($r,$s) \) and \( (c,$t) \) must
also be \($slope\).  Thus, we require
\[ {$t-$s_str \over c-$r_str}=$num_sign {$num_abs \over c$r_str_2}=$slope, \]
or \(c=$b_frac\).
END_SOLUTION

ENDDOCUMENT();
