Difference between revisions of "ProvingTrigIdentities2"

From WeBWorK_wiki
Jump to navigation Jump to search
m
Line 5: Line 5:
 
This PG code shows how to have a multi-part question in which each part is revealed sequentially on its own html page.
 
This PG code shows how to have a multi-part question in which each part is revealed sequentially on its own html page.
 
</p>
 
</p>
* Download file: [[File:ProvingTrigIdentities2.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/ProvingTrigIdentities2.pg FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities2.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities2.pg</code>
 
   
 
<br clear="all" />
 
<br clear="all" />

Revision as of 22:28, 15 June 2013

Proving Trig Identites using a Compound Problem

Click to enlarge

This PG code shows how to have a multi-part question in which each part is revealed sequentially on its own html page.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"compoundProblem.pl",
"Parser.pl",
"PGunion.pl",
);

TEXT(beginproblem());

BEGIN_PROBLEM();

Initialization: We use the compoundProblem.pl macro to generate a multi-part question in which each part is sequentially revealed on its own html page.

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;
#  Add the new functions to the Context
Context()->functions->add(sin=>{class=>'NewFunc',TeX =>'\sin'});


$isProfessor = $studentLogin eq 'professor';

#
#  Set up the compound problem object.
#
$cp = new compoundProblem(
  parts => 3,
  totalAnswers => 3,
  parserValues => 1,
  allowReset   => $isProfessor,
);
$part = $cp->part;

Setup:

if ($part == 1) {

BEGIN_TEXT
${BBOLD}Part 1 of 3:${EBOLD}
$BR
$BR
${BITALIC}Instructions:${EITALIC} You will need to 
submit your answers twice for each part. The first 
time you submit your answers they will be checked 
for correctness. When your answer is correct, check
the box for ${BITALIC}Go on to next part${EITALIC}
and click the submit button.  You will not be able
to go back to previous parts.
$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

ANS( Formula("1-cos(t)")->cmp() );

}

Part 1:

if ($part == 2) {

BEGIN_TEXT
${BBOLD}Part 2 of 3:${EBOLD}
$BR
$BR
Step 0: 
\( 
\displaystyle 
\frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }.
\)
$BR
$BR
Step 1: 
\( \displaystyle
\sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot ( 1 - \cos(t) ).
\)
$BR
$HR
$BR
We may use algebra to rewrite the equation from Step 1 as
$BR
$BR
\( \sin(t) \cdot \big( \)
\{ ans_rule(20) \}
\( \big) = \big(1+\cos(t)\big) \cdot \big(1-\cos(t)\big) \).
END_TEXT

ANS( Formula("sin(t)")->cmp() );

}

Part 2:

if ($part == 3) {

BEGIN_TEXT
${BBOLD}Part 3 of 3:${EBOLD} 
$BR
$BR
Step 0: 
\( 
\displaystyle 
\frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }.
\)
$BR
$BR
Step 1: 
\( \displaystyle
\sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot ( 1 - \cos(t) ).
\)
$BR
$BR
Step 2:
\( \displaystyle 
\sin(t) \sin(t) = (1+\cos(t))(1-\cos(t))
\)
$BR
$HR
$BR
Finally, using algebra we may rewrite the equation from step 2 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

ANS( Formula("1-(cos(t))^2")->cmp() );

}


END_PROBLEM();

ENDDOCUMENT();

Part 3:

Templates by Subject Area