TrigFunctionsDegrees1: Difference between revisions
Paultpearson (talk | contribs) mNo edit summary |
(add historical tag and give links to newer problems.) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{historical}} | |||
[[File: | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Trig/TrigDegrees.html a newer version of this problem]</p> | ||
<h2>Trigonometric Functions in Degrees</h2> | |||
[[File:TrigDegrees.png|300px|thumb|right|Click to enlarge]] | |||
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> | <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> | ||
This PG code shows how 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/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/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" /> | ||
Line 43: | Line 47: | ||
loadMacros( | loadMacros( | ||
"PGstandard.pl", | "PGstandard.pl", | ||
"MathObjects.pl", | "MathObjects.pl", | ||
"AnswerFormatHelp.pl", | "AnswerFormatHelp.pl", | ||
"contextTrigDegrees.pl", | |||
"PGcourse.pl", | |||
); | ); | ||
Line 54: | Line 60: | ||
<p> | <p> | ||
<b>Initialization:</b> | <b>Initialization:</b> | ||
We need to use MathObjects answer evaluators. | We need to use MathObjects answer evaluators and to load the contextTrigDegrees macro. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 64: | Line 70: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | <td style="background-color:#ffffdd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
Context(" | Context("TrigDegrees"); | ||
$ans1 = Compute("sin(30)"); | |||
$ans2 = Compute("arcsin(0.5)"); | |||
</pre> | </pre> | ||
Line 265: | Line 80: | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
WeBWorK | 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 | ||
in any formulas that appear later in the PG code and in any formulas that students | |||
enter in answer blanks. | enter in answer blanks. | ||
</p> | </p> | ||
<p> | <p> | ||
These redefined functions allow students to enter inverse functions using syntax such as | These redefined functions allow students to enter inverse functions using syntax such as | ||
<code>atan(x)</code> | <code>atan(x)</code>, or <code>arctan(x)</code>, or <code>tan^(-1)(x)</code>. | ||
You may want to | You may want to mention the syntax options in the main text section of the problem. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 294: | Line 105: | ||
\{ ans_rule(20) \} | \{ ans_rule(20) \} | ||
\{ AnswerFormatHelp("formulas") \} | \{ AnswerFormatHelp("formulas") \} | ||
$ | $PAR | ||
Remark: Enter \( \arcsin(x) \) as arcsin(x), or | |||
asin(x), or sin^(-1)(x). | |||
END_TEXT | END_TEXT | ||
Context()->normalStrings; | Context()->normalStrings; | ||
Line 315: | Line 126: | ||
$showPartialCorrectAnswers = 1; | $showPartialCorrectAnswers = 1; | ||
ANS( | ANS( $ans1->cmp() ); | ||
ANS( | ANS( $ans2->cmp() ); | ||
</pre> | </pre> | ||
<td style="background-color:#eeccff;padding:7px;"> | <td style="background-color:#eeccff;padding:7px;"> | ||
<p> | <p> | ||
<b>Answer Evaluation:</b> | <b>Answer Evaluation:</b> | ||
The answers are 0.5 and 30 (computed in degrees in the Setup section). | |||
</p> | </p> | ||
</td> | </td> | ||
Line 340: | Line 151: | ||
Context()->normalStrings; | Context()->normalStrings; | ||
COMMENT(" | COMMENT("Redefines trig functions to be in degrees (not radians)."); | ||
ENDDOCUMENT(); | ENDDOCUMENT(); | ||
Line 346: | Line 157: | ||
<td style="background-color:#ddddff;padding:7px;"> | <td style="background-color:#ddddff;padding:7px;"> | ||
<p> | <p> | ||
<b>Solution:</b> | <b>Solution:</b> Before ENDDOCUMENT, we should include a comment that warns other instructors that trig functions are in degrees instead of radians. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 361: | Line 172: | ||
[[Category:Sample Problems]] | [[Category:Sample Problems]] | ||
[[Category:Subject Area Templates]] | [[Category:Subject Area Templates]] | ||
[[Category:Problem Techniques]] |
Latest revision as of 19:20, 16 July 2023
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. |