-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More cleanup of the sample problems and addition of complex samples.
- Loading branch information
Showing
72 changed files
with
1,082 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
## DESCRIPTION | ||
## This demonstrates basic operations with complex numbers. | ||
## ENDDESCRIPTION | ||
|
||
## DBsubject(WeBWorK) | ||
## DBchapter(WeBWorK tutorial) | ||
## DBsection(Problem Techniques) | ||
## Date(06/01/2023) | ||
## Institution(Fitchburg State University) | ||
## Author(Peter Staab) | ||
## MO(1) | ||
## KEYWORDS('complex','addition','subtraction','absolute value') | ||
|
||
#:% name = Basic Operations of Complex numbers | ||
#:% type = [technique] | ||
#:% subject = [complex] | ||
|
||
#:% section = preamble | ||
DOCUMENT(); | ||
|
||
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); | ||
|
||
#:% section = setup | ||
#: To use complex numbers, we need to switch context with `Context('Complex')`. | ||
#: There are many ways to create a complex number. Notice on the 4th one | ||
#: `i` is defined and can be used naturally. | ||
#: | ||
#: Also, the standard operations go through as expected. | ||
#: Notice that for the first two questions, we give the store the answer in | ||
#: a variable. | ||
Context('Complex'); | ||
|
||
$z0 = Complex(non_zero_random(-5,4), non_zero_random(-5,5)); | ||
$z1 = Complex([-1,4]); | ||
$z2 = Complex("2-4i"); | ||
$z3 = 3-4*i; | ||
|
||
$ans1 = $z0+$z1; | ||
$a0 = non_zero_random(-4,4); | ||
$a1 = random(1,5); | ||
$ans2 = Compute("$a0*$z1-$a1*$z2"); | ||
|
||
#:% section = statement | ||
#: Note that in the last three answer blanks, the correct answer is | ||
#: in the `{}` instead of stored as a variable, like the first two. | ||
#: Either method is correct and it varies on which to use. | ||
#: Recall that the perl power `**` is used in the last one. | ||
BEGIN_PGML | ||
Let [`z_0=[$z0]`], [`z_1=[$z1]`], [`z_2=[$z2]`] and [`z_3=[$z3]`]. Find | ||
|
||
[`z_0+z_1=`] [___]{$ans1} | ||
|
||
[`[$a0]z_1-[$a1]z_2=`] [_____]{$ans2} | ||
|
||
[`z_1z_2=`] [___]{$z1*$z2} | ||
|
||
[``\frac{z_3}{z_0}= ``] [___]{$z3/$z0} | ||
|
||
[`` z_2^2=``] [__]{$z2**2} | ||
END_PGML | ||
|
||
#:% section = solution | ||
BEGIN_PGML_SOLUTION | ||
Solution explanation goes here. | ||
END_PGML_SOLUTION | ||
|
||
|
||
ENDDOCUMENT(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
## DESCRIPTION | ||
## This shows the capabilities of the LimitedComplex context. | ||
## ENDDESCRIPTION | ||
|
||
## DBsubject(WeBWorK) | ||
## DBchapter(WeBWorK tutorial) | ||
## DBsection(Problem Techniques) | ||
## Date(06/01/2023) | ||
## Institution(Fitchburg State University) | ||
## Author(Peter Staab) | ||
## MO(1) | ||
## KEYWORDS('complex','addition','subtraction','absolute value') | ||
|
||
#:% name = Complex Numbers, Limited Input | ||
#:% type = [technique] | ||
#:% subject = [complex] | ||
|
||
#:% section = preamble | ||
#: This problems shows the capabilities of the `contextLimitedComplex.pl` macro | ||
#: so it must be loaded. | ||
DOCUMENT(); | ||
|
||
loadMacros('PGstandard.pl', 'PGML.pl', 'contextLimitedComplex.pl', 'PGcourse.pl'); | ||
|
||
#:% section = setup | ||
#: If we ask students to do operations with complex numbers, often we don't | ||
#: want those operations to be allowed in the answer. In this case we set the | ||
#: `Context('LimitedComplex')`. If we define complex numbers, then perl operations | ||
#: will be allowed, but not operations in `Compute` functions. | ||
#: | ||
#: `LimitedComplex` will allow a single number entered (technically only one | ||
#: value of `i`) in either cartesian or polar form. This problem gives the | ||
#: answer in polar to check that form. | ||
#: | ||
#: If you only want complex numbers to be entered in cartesian form you can use | ||
#: `Context('LimitedComplex-cartesian')` and if you only want students to | ||
#: enter numbers in polar form use `Context('LimitedComplex-polar')`. | ||
Context('LimitedComplex'); | ||
|
||
$x0 = non_zero_random(-5,5); | ||
$y0 = non_zero_random(-5,5); | ||
$x1 = non_zero_random(-5,5); | ||
$y1 = non_zero_random(-5,5); | ||
|
||
$z0 = Complex($x0,$y0); | ||
$z1 = Complex($x1,$y1); | ||
|
||
$ans1 = $z0+$z1; | ||
$ans2 = $z0*$z1; | ||
|
||
# Determine the polar form of the answer to give a hint. Since in | ||
# LimitedComplex, most functions are diasbled, so we work on the components. | ||
$arg0 = atan($y0/$x0) + ($x0 > 0 ? ($y0>0 ? 0 : 2*pi): pi); | ||
$arg1 = atan($y1/$x1) + ($x1 > 0 ? ($y1>0 ? 0 : 2*pi): pi); | ||
$abs0 = sqrt($x0**2+$y0**2); | ||
$abs1 = sqrt($x1**2+$y1**2); | ||
|
||
#:% section = statement | ||
BEGIN_PGML | ||
Let [`z_0=[$z0]`] and [`z_1=[$z1]`]. Find | ||
|
||
[`z_0+z_1=`] [___]{$ans1} | ||
|
||
[`z_0z_1=`] [___]{$ans2} | ||
|
||
You may not enter operations between numbers for these answers. However, | ||
if you want the polar form (the second answer is [`[@ $abs0*$abs1 @] e^{[@ $arg0+$arg1 @]i}`]) | ||
|
||
END_PGML | ||
|
||
#:% section = solution | ||
BEGIN_PGML_SOLUTION | ||
Solution explanation goes here. | ||
END_PGML_SOLUTION | ||
|
||
|
||
ENDDOCUMENT(); |
Oops, something went wrong.