Skip to content

Commit

Permalink
Merge pull request #1078 from gajennings/main
Browse files Browse the repository at this point in the history
Fix bug 4775, convert to PGML
  • Loading branch information
gajennings authored Aug 26, 2023
2 parents 0cf5795 + 302b69f commit 233a1b1
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions OpenProblemLibrary/Union/setFunctionComposition/sw4_7_45.pg
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,44 @@ DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(
"PGstandard.pl",
"PGunion.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl"
);

TEXT(beginproblem());

###################################
# Setup

Context("Numeric");

$a = non_zero_random(-9,9,1);
$b = random(2,9,1);

$f=Formula("x^$b")->reduce;
$g=Formula("x+$a ")->reduce;

$f=Formula("x^$b");
$g=Formula("x+$a")->reduce;
$fcompg = $f ->substitute(x=>$g);
#$gcompf = $g ->substitute(x=>$f);

###################################
# Main text

Context()->texStrings;
BEGIN_TEXT
If the function
\( h(x)=$fcompg\) is expressed in the form \(f \circ g\) with
\(f(x)=$f,\) then find the function \(g(x)\).
$PAR
\(g(x)\)= \{ans_rule(15)\}
END_TEXT
Context()->normalStrings;

###################################
# Answers

ANS( $fcompg->cmp(
$cmp=$g->cmp(
limits => [-$a - 2, -$a + 2],
test_at => [[-$a - 1], [-$a + 1]],
checker=>sub {
my ( $correct, $student, $ansHash ) = @_;
return $correct == ($f ->substitute(x=>$student))->reduce;
my $stucomp = $f ->substitute(x=>$student);
return $fcompg == $stucomp;
}
) );

##ANS($g->cmp);
);

###################################
# Main text

BEGIN_PGML
If the function
[` h(x)=[$fcompg]`] is expressed in the form [`f \circ g`] with
[`f(x)=[$f]`], then find the function [`g(x)`].

[`g(x)`] = [_____]{$cmp}
END_PGML

;
ENDDOCUMENT();

0 comments on commit 233a1b1

Please sign in to comment.