Skip to content

Start a SVSU collection in Contrib #831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# DESCRIPTION
# Rewriting absolute value expressions
# written by Jan Hlavacek ([email protected])
# ENDDESCRIPTION

## DBsubject(Algebra)
## DBchapter(Algebra of real numbers and simplifying expressions)
## DBsection(Simplifying expressions)
## Institution(SVSU)
## Author(Jan Hlavacek)
## Level(2)
## TitleText1('Algebra and Trigonometry')
## AuthorText1('Swokowski, Cole')
## EditionText1('13')
## Section1('.')
## Problem1('')
## KEYWORDS('algebra,absolute value')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"contextLimitedRadical.pl",
);
Context("Numeric");

# Define variables here:

$a = list_random(2,3,5,7);
do {$b = list_random(2,3,5,7);} until ($b != $a);

$c = ceil(sqrt($a));
$d = floor(sqrt($b));

Context("LimitedRadical");
Context()->functions->disable("abs");
Context()->parens->remove("|");
Context()->{error}{convert} = sub {
my $message = shift;
$message =~ s/Unexpected character '~~|'/You cannot use absolute value/;
return $message;
};

$dif1 = Formula("$c - sqrt($a)");
$dif2 = Formula("$d - sqrt($b)");

$ans1 = Formula("$c - sqrt($a)");
$ans2 = Formula("sqrt($b) - $d");

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
Write each of the following numbers without using absolute value:

1. [`\left| [$dif1] \right| = `] [_________]{$ans1}

2. [`\left| [$dif2] \right| = `] [_________]{$ans2}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)
END_PGML

# Solution:
BEGIN_PGML_SOLUTION
1. Since [$c] is greater than [` \sqrt{[$a]} `], the difference inside the absolute value is positive, so we can just drop the absolute value:

[`\left| [$dif1] \right| = [$ans1] `]

2. Since [$d] is smaller than [` \sqrt{[$b]} `], the difference inside the absolute value is _negative_, so if we drop the absolute value, we need to change the sign:

[`\left| [$dif2] \right| = [$ans2] `]
END_PGML_SOLUTION

ENDDOCUMENT();
81 changes: 81 additions & 0 deletions Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# DESCRIPTION
# Rewrite absolute value of difference
# written by Jan Hlavacek ([email protected])
# ENDDESCRIPTION

## DBsubject(Algebra)
## DBchapter(Algebra of real numbers and simplifying expressions)
## DBsection(Simplifying expressions)
## Institution(SVSU)
## Author(Jan Hlavacek)
## Level(2)
## TitleText1('Algebra and Trigonometry')
## AuthorText1('Swokowski, Cole')
## EditionText1('13')
## Section1('.')
## Problem1('')
## KEYWORDS('algebra,absolute value')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
);
Context("Numeric");
Context()->functions->disable("abs");
Context()->parens->remove("|");
Context()->{error}{convert} = sub {
my $message = shift;
$message =~ s/Unexpected character '~~|'/You cannot use absolute value in this problem/;
return $message;
};

# Define variables here:

$a = random(1,9,1);

$dir = random(0,1,1);
$ord = random(0,1,1);

$fst = Compute("$a - x");
$snd = Compute("x - $a");

if ($dir) {
$ineq = "\le";
$ans = Compute("$a - x");
} else {
$ineq = "\ge";
$ans = Compute("x - $a");
}

if ($ord) {
$p1 = $fst;
$p2 = $snd;
} else {
$p1 = $snd;
$p2 = $fst;
}

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
Write each of the following numbers without using absolute value, given that [` x [$ineq] [$a] `]:

1. [`\left| [$p1] \right| = `] [_________]{$ans}

2. [`\left| [$p2] \right| = `] [_________]{$ans}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)
END_PGML

# Solution:
BEGIN_PGML_SOLUTION
The two absolute value expressions are actually equal, so the two answers are actually the same. They are both equal to
[`[$ans]`], which is the _non-negative_ difference.
END_PGML_SOLUTION

ENDDOCUMENT();
94 changes: 94 additions & 0 deletions Contrib/SVSU/College_Algebra/absolute_values/distance1.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# DESCRIPTION
# Absolute value of difference as distance
# written by Jan Hlavacek ([email protected])
# ENDDESCRIPTION

## DBsubject(Algebra)
## DBchapter(Algebra of real numbers and simplifying expressions)
## DBsection(Algebraic expressions)
## Institution(SVSU)
## Author(Jan Hlavacek)
## Level(2)
## TitleText1('Algebra and Trigonometry')
## AuthorText1('Swokowski, Cole')
## EditionText1('13')
## Section1('.')
## Problem1('')
## KEYWORDS('algebra,absolute value')

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"AnswerFormatHelp.pl",
"answerHints.pl",
);
Context("Numeric");

# Define variables here:

$a = random(1,9,1);
$b = random($a+1,15,1); # $a < $b

$c = random(7, 18, 1);
$d = random(2,$c-1,1); # $c > $d

$ans1 = Compute("$b - $a");
$ans2 = Compute("$c - $d");

$ans3 = Compute("x - $a");
$ans4 = Compute("$d - x");

$ans5 = Compute("|x - $b|");

# Actual problem goes here:
TEXT(beginproblem());
BEGIN_PGML
This problem is about the _distance between numbers on the number line_.

1. What is the distance between [$a] and [$b] on the number line?

[_________]{$ans1}

2. What is the distance between [$c] and [$d] on the number line?

[_________]{$ans2}

3. Write a formula giving the distance between an unknown number [`x`] and [$a] if we know that [`x > [$a]`]:

[_________]{$ans3}

4. Write a formula giving the distance between an unknown number [`x`] and [$d] if we know that [`x < [$d]`]:

[_________]{$ans4}

5. Finally, write a formula that will always give the distance between an unknown number [`x`] and [$b] if we do not have any additional
information about [`x`]:

[_________]{$ans5}

([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*)
END_PGML

# Solution:
BEGIN_PGML_SOLUTION
1. The distance between [$a] and [$b] is simply [`[$b] - [$a] = [$ans1]`].
2. The distance between [$c] and [$d] is simply [`[$c] - [$d] = [$ans2]`].
3. Since the distance between the unknown number [`x`] and [$a] must be _positive_ and [`x > [$a]`], we need to subtract [$a] from [`x`],
so the answer is [`[$ans3]`].
4. Since the distance between the unknown number [`x`] and [$d] must be _positive_ and [`x < [$d]`], we need to subtract [`x`] from [$d],
so the answer is [`[$ans4]`].
5. Since we do not know whether [`x`] is less than or larger than [$b], we do not know in which order to subtract the numbers. To make sure the
distance turns out positive, we have to use absolute value: the correct answer is [: |x - [$b]| :] or [: |[$b] - x| :]. Because of the absolute value, the order does not matter.
END_PGML_SOLUTION

#hint:
$showHint = 2;

BEGIN_PGML_HINT
Remember that *distance* between things is never negative!
END_PGML_HINT

ENDDOCUMENT();
Loading