Difference between revisions of "ProvingTrigIdentities1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Proving Trig Identities</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> …')
 
(add historical tag and give links to newer problems.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<h2>Proving Trig Identities</h2>
 
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Trig/ProvingTrigIdentities.html a newer version of this problem]</p>
  +
  +
<h2>Deprecated: Proving Trig Identities</h2>
   
 
[[File:ProvingTrigIdentities1.png|300px|thumb|right|Click to enlarge]]
 
[[File:ProvingTrigIdentities1.png|300px|thumb|right|Click to enlarge]]
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
+
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
This PG code shows how to ...
+
This PG code shows how to write a multi-part question in which each new part is revealed only after the previous part is answered correctly. The parts are revealed sequentially on the same html page instead of each part having its own html page. We also cleverly redefine the sine function to require students to simplify their answers when applying well-known trig identities. This example is deprecated because the <code>scaffold.pl</code> macro file provides a better solution.
 
</p>
 
</p>
* Download file: [[File:Filename.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities1.pg FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/...</code>
 
   
 
<br clear="all" />
 
<br clear="all" />
Line 45: Line 48:
 
"PGstandard.pl",
 
"PGstandard.pl",
 
"MathObjects.pl",
 
"MathObjects.pl",
"AnswerFormatHelp.pl",
 
 
);
 
);
   
 
TEXT(beginproblem());
 
TEXT(beginproblem());
  +
  +
$showPartialCorrectAnswers = 1;
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 64: Line 68:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context("Numeric");
+
Context("Numeric")->variables->are(t=>"Real");
   
$answer = Compute("1");
 
  +
#
  +
# Redefine the sin(x) to be e^(pi x)
  +
#
  +
Context()->functions->remove("sin");
  +
package NewFunc;
  +
# this next line makes the function a
  +
# function from reals to reals
  +
our @ISA = qw(Parser::Function::numeric);
  +
sub sin {
  +
shift; my $x = shift;
  +
return CORE::exp($x*3.1415926535);
  +
}
  +
package main;
  +
# Make it work on formulas as well as numbers
  +
#sub cos {Parser::Function->call('cos',@_)} # if uncommented, this line will generate error messages
  +
# Add the new functions to the Context
  +
Context()->functions->add( sin => {class => 'NewFunc', TeX => '\sin'}, );
  +
  +
  +
#
  +
# You manually define the answers
  +
#
  +
@answers = ();
  +
$answers[1] = Formula("1-cos(t)");
  +
$answers[2] = Formula("sin(t)");
  +
$answers[3] = Formula("1-(cos(t))^2");
  +
  +
  +
#
  +
# Automatic configuration for answer evaluation
  +
#
  +
@ans_eval = ();
  +
@scores = ();
  +
foreach my $i (1..$#answers) {
  +
$ans_eval[$i] = $answers[$i] ->cmp();
  +
$ans_hash[$i] = $ans_eval[$i]->evaluate($inputs_ref->{ANS_NUM_TO_NAME($i)});
  +
$scores[$i] = $ans_hash[$i]->{score};
  +
}
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 76: Line 117:
 
</tr>
 
</tr>
   
<!-- Main text section -->
 
   
 
<tr valign="top">
 
<tr valign="top">
Line 83: Line 123:
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_TEXT
 
BEGIN_TEXT
Question text
 
  +
${BBOLD}Part 1 of 3:${EBOLD}
 
$BR
 
$BR
 
$BR
 
$BR
Answer =
 
  +
In this multi-part problem, we will use algebra to verify
  +
the identity
  +
$BCENTER
  +
\( \displaystyle \frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }. \)
  +
$ECENTER
  +
$BR
  +
First, using algebra we may rewrite the equation above as
  +
$BR
  +
$BR
  +
\( \displaystyle \sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot \Big( \)
 
\{ ans_rule(20) \}
 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("formulas") \}
 
  +
\( \Big) \)
 
END_TEXT
 
END_TEXT
 
Context()->normalStrings;
 
Context()->normalStrings;
  +
  +
ANS( $ans_eval[1] );
 
</pre>
 
</pre>
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
 
<p>
 
<p>
<b>Main Text:</b>
+
<b>Main Text and Answer Evaluation Part 1:</b>
 
</p>
 
</p>
 
</td>
 
</td>
 
</tr>
 
</tr>
   
<!-- Answer evaluation section -->
 
   
 
<tr valign="top">
 
<tr valign="top">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<pre>
 
<pre>
$showPartialCorrectAnswers = 1;
 
  +
if ($scores[1]==1) {
  +
  +
Context()->texStrings;
  +
BEGIN_TEXT
  +
$PAR
  +
$HR
  +
${BBOLD}Part 2 of 3:${EBOLD}
  +
$BR
  +
$BR
  +
Then, using algebra we may rewrite the equation as
  +
$BR
  +
$BR
  +
\( \sin(t) \cdot \big( \)
  +
\{ ans_rule(20) \}
  +
\( \big) = \big(1+\cos(t)\big) \cdot \big(1-\cos(t)\big) \),
  +
END_TEXT
  +
Context()->normalStrings;
  +
  +
ANS( $ans_eval[2] );
   
ANS( $answer->cmp() );
 
  +
} # end if
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">
 
<p>
 
<p>
<b>Answer Evaluation:</b>
+
<b>Main Text and Answer Evaluation Part 2:</b>
 
</p>
 
</p>
 
</td>
 
</td>
Line 120: Line 188:
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
  +
if ( ($scores[1]==1) && ($scores[2]==1) ) {
  +
 
Context()->texStrings;
 
Context()->texStrings;
BEGIN_SOLUTION
 
  +
BEGIN_TEXT
${PAR}SOLUTION:${PAR}
 
  +
$PAR
Solution explanation goes here.
 
  +
$HR
END_SOLUTION
 
  +
${BBOLD}Part 3 of 3:${EBOLD}
  +
$BR
  +
$BR
  +
Finally, using algebra we may rewrite the equation as
  +
$BR
  +
$BR
  +
\( \sin^2(t) = \)
  +
\{ ans_rule(20) \}
  +
$BR
  +
$BR
  +
which is true since \( \cos^2(t) + \sin^2(t) = 1 \).
  +
Thus, the original identity can be derived
  +
by reversing these steps.
  +
END_TEXT
 
Context()->normalStrings;
 
Context()->normalStrings;
   
COMMENT('MathObject version.');
 
  +
ANS( $ans_eval[3] );
  +
  +
} # end if
  +
  +
  +
COMMENT("MathObject version. This is a multi-part problem
  +
in which the next part is revealed only after the previous
  +
part is correct. Prevents students from entering trivial
  +
identities (entering what they were given)");
   
 
ENDDOCUMENT();
 
ENDDOCUMENT();
Line 133: Line 224:
 
<td style="background-color:#ddddff;padding:7px;">
 
<td style="background-color:#ddddff;padding:7px;">
 
<p>
 
<p>
<b>Solution:</b>
 
  +
<b>Main Text and Answer Evaluation Part 3:</b>
 
</p>
 
</p>
 
</td>
 
</td>
Line 145: Line 236:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Latest revision as of 06:56, 18 July 2023

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

Deprecated: Proving Trig Identities

Click to enlarge

This PG code shows how to write a multi-part question in which each new part is revealed only after the previous part is answered correctly. The parts are revealed sequentially on the same html page instead of each part having its own html page. We also cleverly redefine the sine function to require students to simplify their answers when applying well-known trig identities. This example is deprecated because the scaffold.pl macro file provides a better solution.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

Initialization:

Context("Numeric")->variables->are(t=>"Real");

#
#  Redefine the sin(x) to be e^(pi x)
#
Context()->functions->remove("sin");
package NewFunc;
# this next line makes the function a 
# function from reals to reals
our @ISA = qw(Parser::Function::numeric);
sub sin {
  shift; my $x = shift;
  return CORE::exp($x*3.1415926535);
}
package main;
# Make it work on formulas as well as numbers
#sub cos {Parser::Function->call('cos',@_)} # if uncommented, this line will generate error messages
#  Add the new functions to the Context
Context()->functions->add( sin => {class => 'NewFunc', TeX => '\sin'}, );


#
#  You manually define the answers
#
@answers = ();
$answers[1] = Formula("1-cos(t)");
$answers[2] = Formula("sin(t)");
$answers[3] = Formula("1-(cos(t))^2");


#
#  Automatic configuration for answer evaluation
#
@ans_eval = ();
@scores = ();
foreach my $i (1..$#answers) {
  $ans_eval[$i] = $answers[$i] ->cmp();
  $ans_hash[$i] = $ans_eval[$i]->evaluate($inputs_ref->{ANS_NUM_TO_NAME($i)});
  $scores[$i]   = $ans_hash[$i]->{score};
}

Setup:

Context()->texStrings;
BEGIN_TEXT
${BBOLD}Part 1 of 3:${EBOLD}
$BR
$BR
In this multi-part problem, we will use algebra to verify 
the identity
$BCENTER
\( \displaystyle \frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }. \)
$ECENTER
$BR
First, using algebra we may rewrite the equation above as
$BR
$BR
\( \displaystyle \sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot \Big( \)
\{ ans_rule(20) \}
\( \Big) \) 
END_TEXT
Context()->normalStrings;

ANS( $ans_eval[1] );

Main Text and Answer Evaluation Part 1:

if ($scores[1]==1) {

Context()->texStrings;
BEGIN_TEXT
$PAR
$HR
${BBOLD}Part 2 of 3:${EBOLD} 
$BR
$BR
Then, using algebra we may rewrite the equation as
$BR
$BR
\( \sin(t) \cdot \big( \)
\{ ans_rule(20) \}
\( \big) = \big(1+\cos(t)\big) \cdot \big(1-\cos(t)\big) \),
END_TEXT
Context()->normalStrings;

ANS( $ans_eval[2] );

}  # end if

Main Text and Answer Evaluation Part 2:

if ( ($scores[1]==1) && ($scores[2]==1) ) {

Context()->texStrings;
BEGIN_TEXT
$PAR
$HR
${BBOLD}Part 3 of 3:${EBOLD} 
$BR
$BR
Finally, using algebra we may rewrite the equation as
$BR
$BR
\( \sin^2(t) = \)
\{ ans_rule(20) \}
$BR
$BR
which is true since \( \cos^2(t) + \sin^2(t) = 1 \).
Thus, the original identity can be derived 
by reversing these steps.
END_TEXT
Context()->normalStrings;

ANS( $ans_eval[3] );

}  # end if


COMMENT("MathObject version.  This is a multi-part problem 
in which the next part is revealed only after the previous 
part is correct.  Prevents students from entering trivial 
identities (entering what they were given)");

ENDDOCUMENT();

Main Text and Answer Evaluation Part 3:

Templates by Subject Area