TrigFunctionsDegrees1: Difference between revisions
(Created page with '<h2>Trig Functions in Degrees</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to redefine trigonometric functions so they ev…') |
(add historical tag and give links to newer problems.) |
||
(15 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{historical}} | |||
<p style="background-color:# | <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> | ||
This PG code shows how to redefine trigonometric functions so they evaluate in degrees rather than radians. | |||
<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;"> | |||
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" /> | |||
<p style="text-align:center;"> | <p style="text-align:center;"> | ||
[[SubjectAreaTemplates|Templates by Subject Area]] | [[SubjectAreaTemplates|Templates by Subject Area]] | ||
Line 40: | Line 45: | ||
<pre> | <pre> | ||
DOCUMENT(); | DOCUMENT(); | ||
loadMacros( | loadMacros( | ||
"PGstandard.pl", | "PGstandard.pl", | ||
"MathObjects.pl", | "MathObjects.pl", | ||
"AnswerFormatHelp.pl", | |||
"contextTrigDegrees.pl", | |||
"PGcourse.pl", | |||
); | ); | ||
TEXT(beginproblem()); | TEXT(beginproblem()); | ||
</pre> | </pre> | ||
Line 50: | 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 60: | 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 261: | 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 281: | Line 96: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> | <td style="background-color:#ffdddd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
Context()->texStrings; | |||
BEGIN_TEXT | BEGIN_TEXT | ||
Enter \( \sin(30) \): \{ ans_rule(20) \} | Enter \( \sin(30) \): | ||
\{ ans_rule(20) \} | |||
\{ AnswerFormatHelp("formulas") \} | |||
$BR | $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 | END_TEXT | ||
Context()->normalStrings; | |||
</pre> | </pre> | ||
<td style="background-color:#ffcccc;padding:7px;"> | <td style="background-color:#ffcccc;padding:7px;"> | ||
Line 303: | Line 124: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> | <td style="background-color:#eeddff;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
$showPartialCorrectAnswers = 1; | |||
ANS( $ans1->cmp() ); | |||
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 331: | Line 151: | ||
Context()->normalStrings; | Context()->normalStrings; | ||
COMMENT( | COMMENT("Redefines trig functions to be in degrees (not radians)."); | ||
ENDDOCUMENT(); | ENDDOCUMENT(); | ||
Line 337: | 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 350: | Line 170: | ||
[[Category:Top]] | [[Category:Top]] | ||
[[Category: | [[Category:Sample Problems]] | ||
[[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. |