Restrict Answers to a Constant

Restricting answers that should reduce to a constant.

Complete Code

Download file: RestrictingFunctions.pg

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

Preamble

These standard macros need to be loaded.
$expr  = Formula('sin(x)^2 + cos(x)^2');
$deriv = Compute(0)->cmp(showTypeWarnings => 0);

Setup

Pass the showTypeWarnings => 0 option to the cmp method to turn off type warnings in answer checking. Then if a student enters an unsimplified answer (e.g., 2 sin(x) cos(x) + 2 cos(x) (-sin(x))), it will be marked incorrect but there will not be the feedback message that says “Your answer isn’t a number (it looks like a formula that returns a number)”.

BEGIN_PGML
Find and completely simplify:

[`` \frac{d}{dx}\bigl(\sin^2 x +\cos^2 x \bigr)= ``] [__]{$deriv}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.