Difference between revisions of "TrigIdentities1"
Jump to navigation
Jump to search
(Created page with '<h2>Trig Identities 1: Cleverly Redefining Functions</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to redefine a named fu…') |
(add historical tag and give links to newer problems.) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | <h2>Trig Identities 1: Cleverly Redefining Functions</h2> |
||
+ | {{historical}} |
||
− | <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Trig/TrigIdentities.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
+ | <h2>Requiring Trig Identities be Used by Cleverly Redefining Functions</h2> |
||
+ | |||
+ | [[File:TrigIdentities1.png|300px|thumb|right|Click to enlarge]] |
||
+ | <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> |
||
This PG code shows how to redefine a named function internally so that students must apply a trig identity and simplify their answer. |
This PG code shows how to redefine a named function internally so that students must apply a trig identity and simplify their answer. |
||
− | <ul> |
||
− | <li>Download file: [[File:TrigIdentities1.txt]] (change the file extension from txt to pg when you save it)</li> |
||
− | <li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Trig/TrigIdentities.pg</code></li> |
||
− | </ul> |
||
</p> |
</p> |
||
+ | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/TrigIdentities1.pg FortLewis/Authoring/Templates/Trig/TrigIdentities1.pg] |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/TrigIdentities1_PGML.pg FortLewis/Authoring/Templates/Trig/TrigIdentities1_PGML.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 167: | Line 172: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Latest revision as of 05:00, 18 July 2023
This problem has been replaced with a newer version of this problem
Requiring Trig Identities be Used by Cleverly Redefining Functions
This PG code shows how to redefine a named function internally so that students must apply a trig identity and simplify their answer.
- File location in OPL: FortLewis/Authoring/Templates/Trig/TrigIdentities1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Trig/TrigIdentities1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "answerHints.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("Numeric"); Context()->functions->remove("tan"); package NewFunc; # this next line makes the function a # function from reals to reals our @ISA = qw(Parser::Function::numeric); sub tan { shift; my $x = shift; return CORE::exp($x*3.1415926535); } package main; # Make it work on formulas as well as numbers sub tan {Parser::Function->call('tan',@_)} # Add the new functions to the Context Context()->functions->add( tan => {class =>'NewFunc', TeX =>'\tan'}, ); |
Setup:
We redefine the function whose
name is |
Context()->texStrings; BEGIN_TEXT Simplify the expression as much as possible. $BR $BR \( \tan(x) \cos(x) \) = \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS(Formula("sin(x)")->cmp() ->withPostFilter(AnswerHints( Compute("tan(x)*cos(x)") => "No credit for entering what you were given.", )) ); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |