TrigFunctionsDegrees1
This problem has been replaced with a newer version of this problem
Trigonometric Functions in Degrees
This PG code shows how to use the context TrigDegrees to redefine trigonometric functions so they evaluate in degrees rather than radians.
- File location in OPL: https://github.com/openwebwork/webwork-open-problem-library/tree/master/Contrib/ChamplainSaintLambert/Titcombe/TrigDegrees.pg
- PGML file location in OPL: https://github.com/openwebwork/webwork-open-problem-library/tree/master/Contrib/ChamplainSaintLambert/Titcombe/TrigDegreesPGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "contextTrigDegrees.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization: We need to use MathObjects answer evaluators and to load the contextTrigDegrees macro. |
Context("TrigDegrees"); $ans1 = Compute("sin(30)"); $ans2 = Compute("arcsin(0.5)"); |
Setup: To override the WeBWorK default of evaluating trig functions in radians, use the TrigDegrees context, which redefines the standard trig functions to be in degrees, both in any formulas that appear later in the PG code and in any formulas that students enter in answer blanks.
These redefined functions allow students to enter inverse functions using syntax such as
|
Context()->texStrings; BEGIN_TEXT Enter \( \sin(30) \): \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} $BR Enter \( \arcsin(1/2) \): \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} $PAR Remark: Enter \( \arcsin(x) \) as arcsin(x), or asin(x), or sin^(-1)(x). END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $ans1->cmp() ); ANS( $ans2->cmp() ); |
Answer Evaluation: The answers are 0.5 and 30 (computed in degrees in the Setup section). |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT("Redefines trig functions to be in degrees (not radians)."); ENDDOCUMENT(); |
Solution: Before ENDDOCUMENT, we should include a comment that warns other instructors that trig functions are in degrees instead of radians. |