Difference between revisions of "TrigFunctionsDegrees1"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
This PG code shows how to use the context TrigDegrees to redefine trigonometric functions so they evaluate in degrees rather than radians.
 
This PG code shows how to use the context TrigDegrees to redefine trigonometric functions so they evaluate in degrees rather than radians.
 
</p>
 
</p>
* File location in OPL: https://github.com/openwebwork/webwork-open-problem-library/Contrib/ChamplainSaintLambert/Titcombe/TrigDegrees.pg <!--[https://github.com/openwebwork/webwork-open-problem-library/FIXPATH...TrigDegrees.pg TrigDegrees.pg] -->
+
* File location in OPL: https://github.com/openwebwork/webwork-open-problem-library/tree/master/Contrib/ChamplainSaintLambert/Titcombe/TrigDegrees.pg <!--[https://github.com/openwebwork/webwork-open-problem-library/FIXPATH...TrigDegrees.pg TrigDegrees.pg] -->
* PGML file location in OPL: https://github.com/openwebwork/webwork-open-problem-library/Contrib/ChamplainSaintLambert/Titcombe/TrigDegreesPGML.pg <!--[https://github.com/openwebwork/webwork-open-problem-library/FIXPATHtopgml...TrigDegreesPGML.pg TrigDegrees.pg] -->
+
* PGML file location in OPL: https://github.com/openwebwork/webwork-open-problem-library/tree/master/Contrib/ChamplainSaintLambert/Titcombe/TrigDegreesPGML.pg <!--[https://github.com/openwebwork/webwork-open-problem-library/FIXPATHtopgml...TrigDegreesPGML.pg TrigDegrees.pg] -->
   
 
<br clear="all" />
 
<br clear="all" />

Revision as of 11:57, 24 July 2021

Trigonometric Functions in Degrees

Click to enlarge

This PG code shows how to use the context TrigDegrees to redefine trigonometric functions so they evaluate in degrees rather than radians.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

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 atan(x), or arctan(x), or tan^(-1)(x). You may want to mention the syntax options in the main text section of the problem.

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.


Templates by Subject Area