Difference between revisions of "VectorOperations1"
(Created page with '<h2>Vector Operations</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> This PG code shows …') |
(add historical tag and give links to newer problems.) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/VectorOperations.html a newer version of this problem]</p> |
||
+ | |||
<h2>Vector Operations</h2> |
<h2>Vector Operations</h2> |
||
− | [[File: |
+ | [[File:VectorOperations1.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 extract the components of a constant vector, take dot and cross products of vectors, find the length of a vector, construct a unit vector, and check whether the student's answer is parallel to or in the same direction as another vector. |
This PG code shows how to extract the components of a constant vector, take dot and cross products of vectors, find the length of a vector, construct a unit vector, and check whether the student's answer is parallel to or in the same direction as another vector. |
||
</p> |
</p> |
||
− | * Download file: [[File:VectorOperations1.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/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc FortLewis/Authoring/Templates/VectorCalc/VectorOperations1.pg] |
||
− | * File location in NPL: <code>FortLewis/Authoring/Templates/VectorCalc/VectorOperations1.pg</code> |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc/VectorOperations1_PGML.pg FortLewis/Authoring/Templates/VectorCalc/VectorOperations1_PGML.pg] |
||
<br clear="all" /> |
<br clear="all" /> |
||
Line 176: | Line 180: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_SOLUTION |
BEGIN_SOLUTION |
||
− | ${PAR}SOLUTION:${PAR} |
||
Solution explanation goes here. |
Solution explanation goes here. |
||
END_SOLUTION |
END_SOLUTION |
||
Line 199: | Line 202: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Latest revision as of 05:28, 18 July 2023
This problem has been replaced with a newer version of this problem
Vector Operations
This PG code shows how to extract the components of a constant vector, take dot and cross products of vectors, find the length of a vector, construct a unit vector, and check whether the student's answer is parallel to or in the same direction as another vector.
- File location in OPL: FortLewis/Authoring/Templates/VectorCalc/VectorOperations1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/VectorCalc/VectorOperations1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "unionLists.pl", ); TEXT(beginproblem()); |
Initialization:
We load |
Context("Vector"); $U = non_zero_vector3D(-9,9,1); $V = non_zero_vector3D(-9,9,1); # value works only for vectors of constants @Uarray = $U->value; $Ucomp2 = $Uarray[1]; $UdotV = $U . $V; $UcrossV = $U x $V; $Vlength = norm( $V ); $Vunit = unit($V); # # Prevent students from entering the dot and # cross products, and the vector functions # norm and unit. # Context()->operators->undefine(".","><"); Context()->functions->disable("Vector"); |
Setup:
We use |
Context()->texStrings; BEGIN_TEXT Suppose \( \vec{u} = $U \) and \( \vec{v} = $V \). \{ BeginList('OL', type=>'A') \} $ITEM The second component of \( \vec{u} \) is \{ ans_rule(20) \} $ITEMSEP $ITEM \( \vec{u} \cdot \vec{v} = \) \{ ans_rule(20) \} $ITEMSEP $ITEM \( \vec{u} \times \vec{v} = \) \{ ans_rule(20) \} $ITEMSEP $ITEM \( \left|\left| \vec{v} \right|\right| = \) \{ ans_rule(20) \} $ITEMSEP $ITEM Enter a unit vector in the direction of \( \vec{v} \). \{ ans_rule(20) \} $ITEMSEP $ITEM Enter a vector parallel to \( \vec{v} \). \{ ans_rule(20) \} $ITEMSEP $ITEM Enter a vector in the same direction as \( \vec{v} \). \{ ans_rule(20) \} \{ EndList('OL') \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $Ucomp2->cmp() ); ANS( $UdotV->cmp() ); ANS( $UcrossV->cmp() ); ANS( $Vlength->cmp() ); ANS( $Vunit->cmp() ); ANS( $V->cmp( parallel=>1 ) ); ANS( $V->cmp( parallel=>1, sameDirection=>1 ) ); |
Answer Evaluation:
In the last two answers we set flags for checking whether the student's answer is parallel to or in the same direction as the correct answer. Notice that both flags |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |