TrigFunctionsDegrees1

From WeBWorK_wiki
(Redirected from TrigFunctionsInDegrees)
Jump to navigation Jump to search
This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem


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