# DESCRIPTION
# Gives a function of the form ax^2 + b or ax^2 + bx + c (factorable) and asks to find f(0) and solve
# f(x) = 0.
# ENDDESCRIPTION
## DBsubject('Algebra')
## DBchapter('Functions')
## DBsection('Evaluation and Solving')
## KEYWORDS('functions', 'function notation', 'function operations', 'function evaluation')
## Author('Rick Lynch')
## Institution('University of Missouri-Columbia')
###########################################################################
# initialization
###########################################################################
DOCUMENT();
loadMacros(
"MathObjects.pl",
"PeriodicRerandomization.pl",
"PGstandard.pl",
"fracListChecker.pl", # contains custom checker and restricts context
"MUHelp.pl",
);
TEXT(beginproblem());
PeriodicRerandomization("3");
$showPartialCorrectAnswers = 1;
###########################################################################
# setup contexts and variables
###########################################################################
Context("Numeric");
$case = random(0,1,1);
if ($case == 0) {
Context()->strings->add("no solutions"=>{}, "infinitely many"=>{}, "no solution"=>{alias=>"no solutions"}, "none"=>{alias=>"no solutions"}, "all reals"=>{alias=>"infinitely many"});
Context()->variables->are(x=>"Real", X=>"Real", f=>"Real", F=>"Real");
Context()->flags->set(reduceConstantFunctions=>0);
$a = non_zero_random(-7,7);
$n = list_random(2,3,5,7,11);
$b = -$n*$a;
$f0 = $b;
$solns = List(Formula("-sqrt($n)"), Formula("sqrt($n)"));
$dsolns = "x = -\sqrt{$n}, \sqrt{$n}";
$dispf = Formula("$a x^2 + $b")->reduce;
} else {
do {
$a = random(1,3);
$b = non_zero_random(-5,5);
$c = random(1,3);
$d = non_zero_random(-5,5);
$c1 = $a*$d + $b*$c;
} until ($c1 != 0);
$c0 = $b*$d;
$c2 = $a*$c;
$f0 = $c0;
$dispf = Formula("$c2 x^2 + $c1 x + $c0")->reduce;
setFracListFunctions(); # set up context for custom checker
Context()->strings->add("no solutions"=>{}, "infinitely many"=>{}, "no solution"=>{alias=>"no solutions"}, "none"=>{alias=>"no solutions"}, "all reals"=>{alias=>"infinitely many"});
Context()->variables->are(x=>"Real", X=>"Real", f=>"Real", F=>"Real");
$solns = List(Fraction(-$b,$a)->reduce, Fraction(-$d,$c)->reduce);
$dsolns = "\displaystyle x = $solns";
}
###########################################################################
# state the problem
###########################################################################
Context()->texStrings;
BEGIN_TEXT
Given that \(f(x) = $dispf\), find \(f(0)\) and solve \(f(x) = 0\).
$PAR
(a) \(f(0) = \) \{ans_rule(10)\} $BR
(b) \(f(x) = 0\) whenever \(x = \) \{ans_rule(20)\}
END_TEXT
Context()->normalStrings;
###########################################################################
# check the answer
###########################################################################
ANS(Compute($f0)->cmp());
if ($case == 0) {
ANS($solns->cmp())
} else {
ANS($solns->cmp(checkFracList()));
}
###########################################################################
# use PeriodicRerandomization to write the answer and generate a new
# version of the problem
###########################################################################
Context()->texStrings;
if ($attempts_modp == 0 && $actualAttempts != 0) {
BEGIN_TEXT
$PAR
${BBOLD}Answer:${EBOLD} (a) \(f(0) = $f0\), (b) \($dsolns\)
$PAR
END_TEXT
} else {
BEGIN_TEXT
$PAR
${BBOLD}Help:${EBOLD} \{ MUHelp("quadeqns") \}
$BR
END_TEXT
}
Context()->normalStrings;
PeriodicStatus();
COMMENT('Features Periodic Rerandomization. Edited and updated in 2012/2013.
$BR
Desc: Gives a function of the form ax^2 + b or ax^2 + bx + c (factorable) and asks to find f(0) and solve f(x) = 0.');
ENDDOCUMENT();