diff --git a/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg b/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg new file mode 100644 index 0000000000..55e2e6d886 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg @@ -0,0 +1,76 @@ +# DESCRIPTION +# Rewriting absolute value expressions +# written by Jan Hlavacek (jhlavace@svsu.edu) +# 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(); diff --git a/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg b/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg new file mode 100644 index 0000000000..a4010ccf1b --- /dev/null +++ b/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg @@ -0,0 +1,81 @@ +# DESCRIPTION +# Rewrite absolute value of difference +# written by Jan Hlavacek (jhlavace@svsu.edu) +# 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(); diff --git a/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg b/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg new file mode 100644 index 0000000000..2c1dbd7b63 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg @@ -0,0 +1,94 @@ +# DESCRIPTION +# Absolute value of difference as distance +# written by Jan Hlavacek (jhlavace@svsu.edu) +# 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(); diff --git a/Contrib/SVSU/College_Algebra/applied_problems/interest.pg b/Contrib/SVSU/College_Algebra/applied_problems/interest.pg new file mode 100644 index 0000000000..8935d0013a --- /dev/null +++ b/Contrib/SVSU/College_Algebra/applied_problems/interest.pg @@ -0,0 +1,173 @@ +## DESCRIPTION +## Algebra: Solve mixing problems with interest rates +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Linear equations and functions) +## DBsection(Applications and models) +## Level(5) +## KEYWORDS('algebra', 'application problems', 'mixing problems') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"scaffold.pl", +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers=1; + +########################### +# Setup + +Context("Numeric")->variables->are(x=>"Real"); + +## names and pronouns: + +$sex = list_random("he","she"); + +if ($sex eq "he") { + $name = list_random("John", "Darquese", "Sven", "Deleon", "Khulai", "Timbo", "Gerain"); +} else { + $name = list_random("Tawni", "Monisha", "Angelique", "Samantha", "Grauni", "Khianna"); +} + +$p1 = random(4,16,1); +do { $p2 = random(4,16,1); } until (abs($p2 - $p1) > 1); + +$pm = min($p1,$p2); +$pM = max($p1,$p2); + +$pdiff = $pM - $pm; + +$k = random(3,20,1); + +$total = 100*$k*$pdiff; + +$f = random($pm*$k + 1, $pM*$k - 1, 1); + +$interest = $f*$pdiff; + +$x = Compute("($interest*100 - $p2*$total)/($p1 - $p2)"); + +$answer1 = Compute("$p1/100"); +$answer2 = Compute("x"); +$answer3 = Compute("$p1/100*x"); +$answer4 = Compute("$p2/100"); +$answer5 = Compute("$total - x"); +$answer6 = Compute("$p2/100*($total - x)"); +$answer7 = Compute("$total"); +$answer8 = Compute("$interest"); + +########################### +# Main text + +BEGIN_PGML +>> ----{100px} << + +>> [$name] wants to invest $[$total]. There are two different accounts in which [$sex] can invest: first one pays [$p1]% simple +interest, while the second one pays [$p2]% simple interest. How much should [$sex] invest into each account so that +the resulting annual interest will be exactly $[$interest]? << + + +>> ----{100px} << +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect" +); + +Section::Begin("Part 1: Set up the table"); + +$table1 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Account","Interest rate","Amount invested","Interest"], align=>CENTER, separation=>0). +AlignedRow(["First",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow(["Second",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow(["Total (given)"," ",ans_rule(10),ans_rule(10)], separation=>0). +EndTable(); + +$table2 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Account","Interest rate","Amount invested","Interest"], align=>CENTER, separation=>0). +AlignedRow(["First",$answer1,$answer2,$answer3], separation=>0). +AlignedRow(["Second",$answer4,$answer5,$answer6], separation=>0). +AlignedRow(["Total (given)"," ",$answer7,$answer8], separation=>0). +EndTable(); + +BEGIN_PGML +First, fill in the following table, using [`x`] for the amount invested in the first account. + +[$table1]* + +END_PGML + +############################ +# Answer evaluation + +ANS( $answer1->cmp() ); +ANS( $answer2->cmp() ); +ANS( $answer3->cmp() ); +ANS( $answer4->cmp() ); +ANS( $answer5->cmp() ); +ANS( $answer6->cmp() ); +ANS( $answer7->cmp() ); +ANS( $answer8->cmp() ); + +BEGIN_PGML_SOLUTION +The first column of the table is easy to fill in, just put down the rate of +the adult tickets and the rate of the child tickets. + +In the second column, the number of child tickets will be [`x`], and since the +total number must be [$total], the number of adult tickets will be [$answer5]. + +To get the last column, simply multiply the first and second column (revenue = +rate times quantity). + +The table will look like this: + +[$table2]* + +END_PGML_SOLUTION + +Section::End(); + +########################################### +Section::Begin("Part 2: Solve the equation"); + +BEGIN_PGML + +Using the table, set up the equation, solve it and find the answer. + +The amount invested into the first account is [__________]{$x} while +the amount invested in the second account is [__________]{$total-$x}. + +END_PGML + +BEGIN_PGML_SOLUTION +In the last column of the table, the interest from the first account plus the interest from the second account +must be equal to the total interest, which is given. From this we get the equation + +[``[$answer3] + [$answer6] = [$answer8]``] + +Solving the equation will give us [`x = [$x]`], which will be invested in the +first account. Then we subtract that from [$total] to get [$total - $x] to get the amount +invested in the second account. +END_PGML_SOLUTION + +Section::End(); + +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg b/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg new file mode 100644 index 0000000000..cb67f1e7ae --- /dev/null +++ b/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg @@ -0,0 +1,163 @@ +## DESCRIPTION +## Algebra: Solve mixing problems with interest rates +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Linear equations and functions) +## DBsection(Applications and models) +## Level(5) +## KEYWORDS('algebra', 'application problems', 'mixing problems') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"scaffold.pl", +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers=1; + +########################### +# Setup + +Context("Numeric")->variables->are(x=>"Real"); + +## chemicals + +$chem = list_random("acid", "glucose", "hydrogen peroxide", "active ingredient"); + +## units + +$unit = list_random("milliliters", "liters", "gallons", "ounces"); + +# volume of solution 1 +$x = random(7,25,1); + +$k = random(3,7,1); + +$s = random(2,5); + +$p2 = random(1,16,1); + +$d = $k*$s; +$amount = $k*$x; + +$p1 = $p2 + $d; + +$p = $s + $p2; + +$amountchem = $p*$amount/100; + +$answer2 = Compute("x"); +$answer3 = Compute("$p1/100*x"); +$answer5 = Compute("$amount - x"); +$answer6 = Compute("$p2/100*($amount - x)"); +$answer8 = Compute("$amountchem"); + +########################### +# Main text + +BEGIN_PGML +>> ----{100px} << + +>> A chemist needs [$amount] [$unit] of [$p]% [$chem] solution by volume. She +only has [$p1]% solution and [$p2]% solution. How many [$unit] of [$p1]% +solution and how many [$unit] of [$p2]% solution does she need to mix to get the +amount and concentration she needs? << + +>> ----{100px} << +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect" +); + +Section::Begin("Part 1: Set up the table"); + +$table1 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Concentration","Amount needed","Amount of pure " . $chem], align=>CENTER, separation=>0). +AlignedRow([$p1 . "%",ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow([$p2 . "%",ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow([$p . "%",$amount,ans_rule(10)], separation=>0). +EndTable(); + +$table2 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Concentration","Amount needed","Amount of pure " . $chem], align=>CENTER, separation=>0). +AlignedRow([$p1 . "%",$answer2,$answer3], separation=>0). +AlignedRow([$p2 . "%",$answer5,$answer6], separation=>0). +AlignedRow([$p . "%",$amount,$answer8], separation=>0). +EndTable(); + +BEGIN_PGML +First, fill in the following table, using [`x`] for the amount of [$p1]% solution. + +[$table1]* +>> (All amounts are in [$unit]) << + +END_PGML + +############################ +# Answer evaluation + +ANS( $answer2->cmp() ); +ANS( $answer3->cmp() ); +ANS( $answer5->cmp() ); +ANS( $answer6->cmp() ); +ANS( $answer8->cmp() ); + +BEGIN_PGML_SOLUTION +In the second column, the amount of [$p1]% solution will be [`x`], and since the +total amount of the desired solution must be [$amount], the amount of the [$p2]% solution will be [$answer5]. + +To get the last column, simply multiply the first and second column (amount of pure [$chem] = concentration times the amount of solution). + +The table will look like this: + +[$table2]* +>> (All amounts are in [$unit]) << + +END_PGML_SOLUTION + +Section::End(); + +########################################### +Section::Begin("Part 2: Solve the equation"); + +BEGIN_PGML + +Using the table, set up the equation, solve it and find the answer. + +The amount of [$p1]% solution is [__________]{$x} while +the amount of [$p2]% solution is [__________]{$amount-$x}. + +END_PGML + +BEGIN_PGML_SOLUTION +In the last column of the table, the amount of pure [$chem] in the [$p1]% solution plus the +amount of pure [$chem] in the [$p2]% solution must be equal to the amount of pure [$chem] in +the mixture of the two solutions, which is [$answer8] [$unit]. + +[``[$answer3] + [$answer6] = [$answer8]``] + +Solving the equation will give us [`x = [$x]`], which is the amount of the [$p1]% solution needed. +Then we subtract that from [$amount] to get [$amount - $x], which is the amount of [$p2]% solution needed. +END_PGML_SOLUTION + +Section::End(); + +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg b/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg new file mode 100644 index 0000000000..ab5be5ea2e --- /dev/null +++ b/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg @@ -0,0 +1,154 @@ +## DESCRIPTION +## Algebra: Solve mixing problems with prices +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Linear equations and functions) +## DBsection(Applications and models) +## Level(5) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"scaffold.pl", +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers=1; + +########################### +# Setup + +Context("Numeric")->variables->are(x=>"Real"); + +$pricelow = random(4,12,1); +$pricehigh = $pricelow + random(2,10,1); + +$numberlow = random(30,200,1); +do { $numberhigh = random(30,200,1); } until ($numberhigh != $numberlow); + +$totalnum = $numberhigh + $numberlow; +$totalrev = $pricelow*$numberlow + $pricehigh*$numberhigh; + +$answer1 = Compute("$pricehigh"); +$answer2 = Compute("$totalnum - x"); +$answer3 = Compute("$pricehigh*($totalnum - x)"); +$answer4 = Compute("$pricelow"); +$answer5 = Compute("x"); +$answer6 = Compute("$pricelow*x"); +$answer7 = Compute("$totalnum"); +$answer8 = Compute("$totalrev"); + +$ticketschild = Formula("x"); + + +########################### +# Main text + +BEGIN_PGML +>> ----{100px} << + +>> A movie theater sold [$totalnum] tickets for a show. Their revenue for the show was +$[$totalrev]. There were two types of tickets sold: adult tickets for $[$pricehigh] and child tickets +for $[$pricelow]. << + +>> How may child tickets were sold? << + +>> ----{100px} << +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect" +); +Section::Begin("Part 1: Set up the table"); + +$table1 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Ticket type","Price","Number of tickets","Revenue"], align=>CENTER, separation=>0). +AlignedRow(["Adult",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow(["Child",ans_rule(10),ans_rule(10),ans_rule(10)], separation=>0). +AlignedRow(["Total (given)"," ",ans_rule(10),ans_rule(10)], separation=>0). +EndTable(); + +$table2 = +BeginTable(border=>1, tex_border=>"1pt", spacing=>0, padding=>5,center=>1). +AlignedRow(["Ticket type","Price","Number of tickets","Revenue"], align=>CENTER, separation=>0). +AlignedRow(["Adult",$answer1,$answer2,$answer3], separation=>0). +AlignedRow(["Child",$answer4,$answer5,$answer6], separation=>0). +AlignedRow(["Total (given)"," ",$answer7,$answer8], separation=>0). +EndTable(); + +BEGIN_PGML +First, fill in the following table, using [`x`] for the number of child tickets: + +[$table1]* + +END_PGML + +############################ +# Answer evaluation + +ANS( $answer1->cmp() ); +ANS( $answer2->cmp() ); +ANS( $answer3->cmp() ); +ANS( $answer4->cmp() ); +ANS( $answer5->cmp() ); +ANS( $answer6->cmp() ); +ANS( $answer7->cmp() ); +ANS( $answer8->cmp() ); + +BEGIN_PGML_SOLUTION +The first column of the table is easy to fill in, just put down the price of +the adult tickets and the price of the child tickets. + +In the second column, the number of child tickets will be [`x`], and since the +total number must be [$totalnum], the number of adult tickets will be [$answer2]. + +To get the last column, simply multiply the first and second column (revenue = +price times quantity). + +The table will look like this: + +[$table2]* + +END_PGML_SOLUTION + +Section::End(); + +########################################### +Section::Begin("Part 2: Solve the equation"); + +BEGIN_PGML + +Using the table, set up the equation, solve it and find the answer. + +The number of child tickets is [__________]{$numberlow} + +END_PGML + +BEGIN_PGML_SOLUTION +In the last column of the table, the revenue for adult tickets plus the revenue +for the child tickets must be equal to the total revenue, which is given. From this we get the equation + +[``[$answer3] + [$answer6] = [$answer8]``] + +Solving the equation will give us [`x = [$numberlow]`]. +END_PGML_SOLUTION + +Section::End(); + +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/circles/circle1.pg b/Contrib/SVSU/College_Algebra/circles/circle1.pg new file mode 100644 index 0000000000..84a8e19ec8 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/circles/circle1.pg @@ -0,0 +1,98 @@ +# DESCRIPTION +# Identify a circle by equation +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Cartesian coordinate system) +## DBsection(Circles) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,equations,circle') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"contextFraction.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(y=>"Real"); + +# Define variables here: + +$h = non_zero_random(-10,10); +$k = non_zero_random(-10,10); +$r = random(1,9,1); + +$xb = Compute("-2*$h"); +$yb = Compute("-2*$k"); +$const = Compute("($h)^2 + ($k)^2 - ($r)^2"); +$lhs = Compute("x^2 + y^2 + $xb*x + $yb*y + $const")->reduce(); + +$rconst = Compute("-$const")->reduce(); +$h2 = Compute("($h)^2"); +$k2 = Compute("($k)^2"); +$r2 = Compute("($r)^2"); +$xpart = Compute("x^2 + $xb*x")->reduce(); +$ypart = Compute("y^2 + $yb*y")->reduce(); +$xcomp = Compute("x - $h")->reduce(); +$ycomp = Compute("y - $k")->reduce(); + +Context("Point"); +$sol = Compute("($h,$k)"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find the center and radius of the circle with the equation + +>>[`` [$lhs] = 0 ``].<< + +----- + +The center: [________________]{$sol} [@ AnswerFormatHelp("points") @]* + +The radius: [________________]{$r} [@ AnswerFormatHelp("numbers") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +To find the center and radius of the circle, we have to rewrite the given equation + +>>[`` [$lhs] = 0 ``]<< + +in the standard form + +>>[`` (x-h)^2 + (y-k)^2 = r^2 ``].<< + +Once we have the equation in that from, the center is [:(h,k):] and the radius is [:r:]. + +To get the equation in that form, we have to complete the square in both [:x:] and [:y:]. + +We start by separating the [:x:]'s and [:y:]'s, and moving the constant to the right side. + +>>[`` [$xpart] \phantom{{} + [$h2]} + [$ypart] \phantom{{} + [$k2]} = [$rconst] \phantom{{} + [$h2] + [$k2]} ``]<< + +We complete the two squares: + +>>[`` [$xpart] \color{blue}{{} + [$h2]} + [$ypart] \color{green}{{} + [$k2]} = [$rconst] \color{blue}{{} + [$h2]} \color{green}{{} + [$k2]} ``]<< + +and get + +>>[`` ([$xcomp])^2 + ([$ycomp])^2 = [$r2] ``]<< + +The center is [``[$sol]``] and the radius [``[$r]``]. + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/circles/semicircle1.pg b/Contrib/SVSU/College_Algebra/circles/semicircle1.pg new file mode 100644 index 0000000000..9a76ee4bb4 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/circles/semicircle1.pg @@ -0,0 +1,83 @@ +# DESCRIPTION +# Write an equation of semicircle +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Cartesian coordinate system) +## DBsection(Circles) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,equations,circle,semicircle') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserAssignment.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->are(x=>"Real",y=>"Real"); +parser::Assignment->Allow; + +# Define variables here: + +$h = non_zero_random(-10,10); +$k = non_zero_random(-10,10); +$r = random(1,9,1); +$which = list_random(-1,1); +$name = $which<0?"lower":"upper"; + +Context()->variables->set(x=>{limits=>[$h-($r),$h+($r)]}); + +$rhs = Formula("$k + $which*sqrt($r^2 - (x - $h)^2)")->reduce("(-x)+y" => 0, "(-x)-y" => 0); +$eq = Formula("y = $rhs"); + +$circ = Formula("(x - $h)^2 + (y - $k)^2")->reduce(); +$r2 = Compute("$r^2"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find an equation of the [$name] semicircle with center [:([$h],[$k]):] and radius [:[$r]:]. Use [:x:] and [:y:] +as variables. + +The equation: [________________]{$eq} [@ AnswerFormatHelp("equations") @]* + +END_PGML + +#hint: +$showHint = 1; + +BEGIN_PGML_HINT +You want to enter an equation in the form [:y = ...:]. +END_PGML_HINT + +$showHint = 3; + +BEGIN_PGML_HINT +Start by writing an equation for a circle, then solve for [:y:]. +END_PGML_HINT + +# Solution: +BEGIN_PGML_SOLUTION +You start by writing an equation for a circle with center [:([$h],[$k]):] and radius [:[$r]:]: + +>>[:: [$circ] = [$r2] ::]<< + +Solve this equation for [:y:]. When taking square root, choose [`+`] for +**upper** semicircle and [`-`] for **lower** semicircle. + +The answer will be [:[$eq]:]. + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/complex/equation1.pg b/Contrib/SVSU/College_Algebra/complex/equation1.pg new file mode 100644 index 0000000000..0b2fbf23d5 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/complex/equation1.pg @@ -0,0 +1,176 @@ +## DESCRIPTION +## Algebra: Complex solutions to a quadratic equation +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Complex roots) +## Level(2) +## KEYWORDS('algebra', 'complex numbers', 'quadratic equations') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"parserPopUp.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 0; + +Context("Complex"); +Context()->variables->add(x => 'Complex'); + +$re1 = random(1,8,1); +$im1 = list_random(-1,1)*random(1,8,1); + +$p1 = Complex($re1,$im1); +$q1 = Complex($re1,-$im1); + +$b1 = -($p1 + $q1); +$c1 = $p1 * $q1; + +do { $re2 = random(1,8,1); } until ( $re2 != $re1 ); +do { $im2 = list_random(-1,1)*random(1,8,1); } until ($im2 != $im1); + +$p2 = Complex(-$re2,$im2); +$q2 = Complex(-$re2,-$im2); + +$b2 = -($p2 + $q2); +$c2 = $p2 * $q2; + + +do { $re3 = random(1,8,1); } until ( $re3 != $re1 and $re3 != $re2 ); +do { $im3 = list_random(-1,1)*random(1,8,1); } until ($im3 != $im1 and $im3 != $im2); + +$p3 = Complex($re3,$im3); +$q3 = Complex($re3,-$im3); + +$h3 = $re3; +$k3s = $im3**2; + +#Context("Numeric"); + +$issol1 = list_random(0,1); +$issol2 = list_random(0,1); +$issol3 = list_random(0,1); + +if ($issol1 != 1) { + $b1 = $b1 - list_random(0,0,1); + $c1 = $c1 + 1; +} + +$eq1 = Formula("x^2 + ($b1)*x + ($c1)")->reduce; + + +if ($issol2 != 1) { + $c2 = $c2 + 1; +} + +$eq2 = Formula("x^2 + ($b2)*x + ($c2)")->reduce; + + +if ($issol3 != 1) { + $h3 = $h3 + random(-3,3,1); + $k3s = $k3s + 1; +} + +$eq3 = Formula("(x - $h3)^2")->reduce; + + +$pop1 = PopUp( + ["choose","is a solution","is not a solution"], + $issol1 ? "is a solution" : "is not a solution" +); + +$pop2 = PopUp( + ["choose","is a solution","is not a solution"], + $issol2 ? "is a solution" : "is not a solution" +); + +$pop3 = PopUp( + ["choose","is a solution","is not a solution"], + $issol3 ? "is a solution" : "is not a solution" +); + +$eq1plug = $eq1->substitute(x => "$p1"); +$eq2plug = $eq2->substitute(x => "$p2"); +$eq3plug = $eq3->substitute(x => "$p3"); + +########################### +# Main text + +BEGIN_PGML +Decide whether the given number is a solution of the given equation: + +* The number [` x = [$p1] `] [___]{$pop1} of [` [$eq1] = 0 `]. + +* The number [` x = [$p2] `] [___]{$pop2} of [` [$eq2] = 0 `]. + +* The number [` x = [$p3] `] [___]{$pop3} of [` [$eq3] = -[$k3s] `]. +END_PGML + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +What does it mean for a number to be a solution of an equation? +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +To check whether a number is a solution of an equation, we just need to plug the number in. + +### The first part ### + +[` ([$p1])^2 + [$b1]\cdot([$p1]) + [$c1] = ([$re1])^2 + 2\cdot [$re1]\cdot([$im1])i - ([$im1])^2 + [$b1]\cdot [$re1] + [$b1]\cdot([$im1])i + [$c1] `] + +Multiplying things out will give us + +[` [$re1*$re1] + [$re1*$im1*2]i - [$im1*$im1] + [$b1*$re1] + [$b1*$im1]i + [$c1] = [$eq1plug] `] + +The number [$pop1] of the eq! + +### the second part ### + +[` ([$p2])^2 + [$b2]\cdot([$p2]) + [$c2] = (-[$re2])^2 + 2\cdot (-[$re2])\cdot([$im2])i - ([$im2])^2 + [$b2]\cdot(-[$re2]) + [$b2]\cdot([$im2])i + [$c2] `] + +Multiplying things out will give us + +[` [$re2*$re2] + [$re2*$im2*(-2)]i - [$im2*$im2] + [$b2*(-$re2)] + [$b2*$im2]i + [$c2] = [$eq2plug] `] + +The number [$pop2] of the equation! + +### the third part ### + +[` ([$p3] - [$h3])^2 = ([$p3 - $h3])^2 = ([$re3 - $h3])^2 + 2\cdot([$re3-$h3])\cdot([$im3])i - ([$im3])^2 `] + +Multiplying things out will give us + +[` [$re3*$re3 - 2*$re3*$h3 + $h3*$h3] + [$im3*($re3 - $h3)*2]i - [$im3*$im3] = [$eq3plug] `] + +This is supposed to be equal to [` -[$k3s] `]. + +The number [$pop3] of the equation! + +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/complex/equation2.pg b/Contrib/SVSU/College_Algebra/complex/equation2.pg new file mode 100644 index 0000000000..8d154ce9bc --- /dev/null +++ b/Contrib/SVSU/College_Algebra/complex/equation2.pg @@ -0,0 +1,104 @@ +## DESCRIPTION +## Algebra: Quadratic equation with complex solutions +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Complex roots) +## Level(2) +## KEYWORDS('algebra', 'complex numbers', 'quadratic equations') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"answerHints.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 1; + +Context("Complex"); +Context()->variables->add(x => 'Complex'); + +$re1 = list_random(-1,1)*random(1,8,1); +$im1 = random(1,8,1); + +$p1 = Complex($re1,$im1); +$q1 = Complex($re1,-$im1); + +$b1 = -($p1 + $q1); +$c1 = $p1 * $q1; + +$eq1 = Formula("x^2 + ($b1)*x + ($c1)")->reduce; + +$solutions = List($p1, $q1); + +$squareof = Formula("x - ($re1)")->reduce; + +########################### +# Main text + +BEGIN_PGML + +Find all solutions of the equation [` [$eq1] = 0 `]. + +Enter the solutions, separated by comma. Enter NONE if there are no solutions. + +[____________________] + +END_PGML + +ANS( $solutions->cmp( + removeParens => 1, + requireParenMatch => 0, + )->withPostFilter(AnswerHints( + "(NONE)" => "There are no real answers, but there may be complex ones!" + ) + ) +); + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Try completing the square. +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION + +First complete the square to get + +[` ([$squareof])^2 = -[$im1*$im1] `] + +Using square root property: + +[` [$squareof] = \pm\sqrt{-[$im1*$im1]} `] + +Adding [$re1] to both sides and simplifying the square root: + +[` x = [$re1] \pm [$im1] i `] + +The two solutions are [` [$p1] `] and [` [$q1] `]. +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/complex/equation3.pg b/Contrib/SVSU/College_Algebra/complex/equation3.pg new file mode 100644 index 0000000000..5efd34a60b --- /dev/null +++ b/Contrib/SVSU/College_Algebra/complex/equation3.pg @@ -0,0 +1,104 @@ +## DESCRIPTION +## Algebra: Cubic equation with complex solutions +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Polynomial equations and functions) +## DBsection(Complex roots) +## Level(3) +## KEYWORDS('algebra', 'complex numbers', 'quadratic equations', 'cubic equations') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"answerHints.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 1; + +Context("Complex"); +Context()->variables->add(x => 'Complex'); + +$a = list_random(-1,1)*random(2,6,1); +$a2 = $a**2; +$a3 = $a**3; + +$s2 = Compute("-$a/2 + $a/2*sqrt(3)i")->reduce; +$s3 = Compute("-$a/2 - $a/2*sqrt(3)i")->reduce; + +$solutions = List($a, $s2, $s3); + +$cubes = Formula("x^3 - $a^3")->reduce; +$cubes1 = Formula("x - $a")->reduce; +$cubes2 = Formula("x^2 + $a*x + $a2")->reduce; + +########################### +# Main text + +BEGIN_PGML + +Find all solutions of the equation [` x^3 = [$a3] `]. + +Enter the solutions, separated by comma. Enter NONE if there are no solutions. + +[____________________] + +END_PGML + +ANS( $solutions->cmp( + removeParens => 1, + requireParenMatch => 0, + )->withPostFilter(AnswerHints( + "(NONE)" => "There are three solutions!", + "($a)" => "That's the obvious solution. There are two more!", + "$a" => "That's the obvious solution. There are two more!", + ) + ) +); + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The sum of cubes: [` x^3 + a^3 = (x+a)(x^2 - ax + a^2) `] +The difference of cubes: [` x^3 - a^3 = (x-a)(x^2 + ax + a^2) `] +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION + +First move everything to the left side: + +[` [$cubes] = 0 `] + +Factor the left side using sum of cubes or difference of cubes: + +[` ([$cubes1])([$cubes2]) = 0 `] + +From the zero product property, either [` [$cubes1] = 0 `] or [` [$cubes2] = 0 `]. + +The first equation has a single solution [` x = [$a] `], while the second is a quadratic +equation with solutions [` [$s2] `] and [` [$s3] `]. +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/coordinate_system/distance_axis.pg b/Contrib/SVSU/College_Algebra/coordinate_system/distance_axis.pg new file mode 100644 index 0000000000..3ac2736079 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/coordinate_system/distance_axis.pg @@ -0,0 +1,86 @@ +# DESCRIPTION +# Find points on an axis given distance from a point +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Cartesian coordinate system) +## DBsection(Midpoint and distance formulas) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(3) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,equations,distance formuls') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"contextLimitedPoint.pl", +"AnswerFormatHelp.pl", +"unorderedAnswer.pl", +"PGcourse.pl", +); +Context("Numeric")->variables->add(y=>"Real"); + +# Define variables here: + +# Small Pythagorean triples: + +@leg1 = (3, 5, 8, 7, 9,11, 6, 9,12,15,10,14); +@leg2 = (4,12,15,24,40,60, 8,12,16,20,24,48); +@hypo = (5,13,17,25,41,61,10,15,20,25,26,50); + +$index = random(1,$#leg1,1); +$center1 = list_random(-1,1)*$leg1[$index]; #coordinate of the point perpendicular to the axis +$axisdist = $leg2[$index]; #distance of the solution along the axis +$distance = $hypo[$index]; #given distance from the point +$center2 = non_zero_random(-10,10); #the other coordinate of the point +$axis = list_random('x', 'y'); #axis for the solution + +$sol1 = $center2 - $axisdist; +$sol2 = $center2 + $axisdist; + +Context("LimitedPoint"); + +if ($axis eq 'x'){ + $pointx = $center2; + $pointy = $center1; + $answer1 = Point($sol1,0); + $answer2 = Point($sol2,0); + $form = "(x,0)"; +} else { + $pointx = $center1; + $pointy = $center2; + $answer1 = Point(0,$sol1); + $answer2 = Point(0,$sol2); + $form = "(0,y)"; +} + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find all points on the [`[$axis]`]-axis that are distance [`[$distance]`] from the point [`P([$pointx],[$pointy])`]. + +The points are [_____________] and [_____________]. + +END_PGML + +$showPartialCorrectAnswers = 1; + +UNORDERED_ANS( +$answer1->cmp(), +$answer2->cmp(), +); + +# Solution: +BEGIN_PGML_SOLUTION + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg new file mode 100644 index 0000000000..3c23544650 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg @@ -0,0 +1,77 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Rational equations and functions) +## DBsection(Simplifying) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,rational expressions,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = random(2,7,1); +do { $b = list_random(-1,1)*random(2,9,1); } until ( $a != $b ); +do { $c = list_random(-1,1)*random(2,9,1); } until ( $c != $b ); + +$fun = Compute("$a*x^2 + $b*x + $c")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$funxphred = Compute("$a*x^2 + 2*$a*x*h + $a*h^2 + $b*x + $b*h + $c")->reduce(); +$numred = Compute("$a*x^2 + 2*$a*x*h + $a*h^2 + $b*x + $b*h + $c - $a*x^2 - $b*x - $c")->reduce(); + +$diff = Compute("2*$a*x + $a*h + $b")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Simplify the expression + +>>[:: ([$funxph] - ([$fun]))/h ::]<< + +as much as possible. + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +[``\begin{align} +\frac{[$funxph] - ([$fun])}{h} &= \frac{[$funxphred] - ([$fun])}{h} \\ +&= \frac{[$numred]}{h} \\ +&= \frac{h([$diff])}{h} \\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient2.pg b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient2.pg new file mode 100644 index 0000000000..1aebd5e4c6 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient2.pg @@ -0,0 +1,76 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Rational equations and functions) +## DBsection(Simplifying) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,rational expressions,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = non_zero_random(-8,8,1); + +$fun = Compute("1/(x-$a)")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$denom = Compute("x-$a")->reduce(); +$denomh = $denom->substitute(x => "x+h"); +$combdenom = ($denom*$denomh)->reduce(); +$numred = Compute("($denom) - ($denomh)")->reduce(); + +$diff = Compute("-1/($combdenom)")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Simplify the expression + +>>[:: ([$funxph] - [$fun])/h ::]<< + +as much as possible. + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +[``\begin{align} +\frac{[$funxph] - ([$fun])}{h} &= \frac{\frac{([$denom]) - ([$denomh])}{([$denomh])([$denom])}}{h}\\ +&= \frac{[$numred]}{([$denomh])([$denom])}\cdot\frac{1}{h}\\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient3.pg b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient3.pg new file mode 100644 index 0000000000..7f30116f0c --- /dev/null +++ b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient3.pg @@ -0,0 +1,79 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of rational exponents and radicals) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,rational expressions,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = non_zero_random(-8,8,1); + +Context()->variables->set(x=>{limits=>[-$a,100]}); + +$fun = Compute("sqrt(x-$a)")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$inside = Compute("x-$a")->reduce(); +$insideh = $inside->substitute(x => "x+h"); +$numred = Compute("($insideh) - ($inside)")->reduce(); + +$diff = Compute("1/($funxph + $fun)")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Rationalize the numerator and simplify: + +>>[:: ([$funxph] - [$fun])/h ::]<< + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +Multiply both numerator and denominator by [::[$funxph] + [$fun]::] and simplify: + +[``\begin{align} +\frac{[$funxph] - [$fun]}{h} &= \frac{[$funxph] - [$fun]}{h}\cdot\frac{[$funxph] + [$fun]}{[$funxph] + [$fun]} \\ +&= \frac{([$funxph])^2 - ([$fun])^2}{h\left([$funxph] + [$fun]\right)}\\ +&= \frac{[$numred]}{h\left([$funxph] + [$fun]\right)}\\ +&= \frac{h}{h\left([$funxph] + [$fun]\right)}\\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/exponents/simplify1.pg b/Contrib/SVSU/College_Algebra/exponents/simplify1.pg new file mode 100644 index 0000000000..a6e7a21965 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/exponents/simplify1.pg @@ -0,0 +1,159 @@ +## DESCRIPTION +## Algebra: Simplify expression with exponents +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of exponents) +## Level(2) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +Context("Numeric")->variables->are(x=>"Real",y=>"Real"); + +$coef1 = list_random(2,3,5); +do { $coef2 = list_random(2,3,5); } until ($coef2 != $coef1); + +if ( $coef1 == 2 ) { $n1 = random(2,5,1); } +elsif ( $coef1 == 3 ) { $n1 = random(2,4,1); } +else { $n1 = random(2,3,1); } + +if ( $coef2 == 2 ) { $n2 = random(2,5,1); } +elsif ( $coef2 == 3 ) { $n2 = random(2,4,1); } +else { $n2 = random(2,3,1); } + +$nx1 = random(3,9,1); +$ny1 = random(3,9,1); +do { $nx2 = random(3,9,1); } until ( $nx2 != $nx1 ); +do { $ny2 = random(3,9,1); } until ( $ny2 != $ny1 ); + +# TeX +Context()->texStrings; +$expression = "\left( $coef1 x^{$nx1} y^{$ny1} \right)^{$n1} \left( $coef2 x^{$nx2} y^{$ny2} \right)^{$n2}"; +Context()->normalStrings; + +# MathObjects +$coef = Compute("$coef1^($n1)*$coef2^($n2)"); +$nx = Compute("$nx1*$n1 + $nx2*$n2"); +$ny = Compute("$ny1*$n1 + $ny2*$n2"); + +$c1n1 = Compute("$coef1^($n1)"); +$c2n2 = Compute("$coef2^($n2)"); + +$nx11 = Compute("$nx1*$n1"); +$nx22 = Compute("$nx2*$n2"); +$ny11 = Compute("$ny1*$n1"); +$ny22 = Compute("$ny2*$n2"); + +# +# Display exponents nicely +# +$w1 = 10; # width of 1st answer blank +$w2 = 10; # width of 2nd answer blank +$w3 = 10; # width of 3rd answer blank +Context()->texStrings; +if ($displayMode eq 'TeX') { + $showpower = + "\( \displaystyle $expression = (" . ans_rule($w1) . ")x^{" . ans_rule($w2) . "}y^{" . ans_rule($w3) . "}\)"; +} else { + $showpower = + ColumnTable($BR. + "\( \displaystyle $expression = \)" . ans_rule($w1), + BeginTable(border=>0, spacing=>0, padding=>0). + AlignedRow(["",ans_rule($w2),"",ans_rule($w3)], align=>LEFT, separation=>0). + AlignedRow(["\( x\)", + "", + " \(y\)", + ""], + align=>LEFT, separation=>0). + EndTable(), + indent=>0, separation=>0, valign=>"BOTTOM") +} +Context()->normalStrings; + + +########################### +# Main text + +BEGIN_PGML +Simplify the following expression: + +[$showpower]*** + +[@ knowlLink( +"Quick hint", value => "Start by distributing powers over products.") +@]* +END_PGML + + +############################ +# Answer evaluation + +$showPartialCorrectAnswers = 1; + +ANS( $coef->cmp() ); +ANS( $nx->cmp() ); +ANS( $ny->cmp() ); + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +You want to use the following three rules: + +* Distributive property for powers and products: [: (a b)^n = a^n b^n :]. +* First law of exponents: [: a^n a^m = a^(m+n) :]. +* Second law of exponents: [: (a^n)^m = a^(mn) :]. + +Also, don't forget to distribute powers to the coefficients as well: + +[:: (2xy)^n = 2^n x^n y^n ::], not [:: 2x^n y^n ::]! +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +You start by distributing the powers over products: + +[:: ([$coef1]x^[$nx1]y^[$ny1])^[$n1] ([$coef2]x^[$nx2]y^[$ny2])^[$n2] = +[$coef1]^[$n1](x^[$nx1])^[$n1](y^[$ny1])^[$n1] [$coef2]^[$n2](x^[$nx2])^[$n2](y^[$ny2])^[$n2] ::] + +Then calculating the power of the coefficients and using the second law of exponents: + +[:: [$c1n1]x^([$nx1] [$n1])y^([$ny1] [$n1]) [$c2n2]x^([$nx2] [$n2])y^([$ny2] [$n2]) = + [$c1n1]x^[$nx11] y^[$ny11] [$c2n2]x^[$nx22] y^[$ny22] ::] + +Then, using commutative property of multiplication, we get + +[:: [$c1n1] [$c2n2]*x^[$nx11]*x^[$nx22]*y^[$ny11]*y^[$ny22] ::] + +Finally, multiplying [: [$c1n1] [$c2n2] :] and using the first law of exponents: + +[:: [$coef]*x^([$nx11]+[$nx22])*y^([$ny11]+[$ny22]) = [$coef]*x^[$nx]*y^[$ny] ::] +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/exponents/simplify2.pg b/Contrib/SVSU/College_Algebra/exponents/simplify2.pg new file mode 100644 index 0000000000..7dbda1e5b6 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/exponents/simplify2.pg @@ -0,0 +1,177 @@ +## DESCRIPTION +## Algebra: Simplify expression with exponents +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of exponents) +## Level(2) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"contextFraction.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +Context("Numeric")->variables->are(p=>"Real",q=>"Real"); + +$coef1 = list_random(-2,-3,-5,2,2,3,3,5,5); +do { $coef2 = list_random(-2,-3,-5,2,2,3,3,5,5); } until ($coef2 != $coef1); + +if ( abs($coef1) == 2 ) { $n1 = random(2,5,1); } +elsif ( abs($coef1) == 3 ) { $n1 = random(2,4,1); } +else { $n1 = random(2,3,1); } + +$n1 = list_random(-1,1)*$n1; + +if ( $coef2 == 2 ) { $n2 = random(2,5,1); } +elsif ( $coef2 == 3 ) { $n2 = random(2,4,1); } +else { $n2 = random(2,3,1); } + +$n2 = list_random(-1,1)*$n2; + +$nx1 = list_random(-1,1)*random(3,9,1); +$ny1 = list_random(-1,1)*random(3,9,1); +do { $nx2 = list_random(-1,1)*random(3,9,1); } until ( $nx2 != $nx1 ); +do { $ny2 = list_random(-1,1)*random(3,9,1); } until ( $ny2 != $ny1 ); + +# TeX +Context()->texStrings; +$expression = "\left( $coef1 p^{$nx1} q^{$ny1} \right)^{$n1} \left( $coef2 p^{$nx2} q^{$ny2} \right)^{$n2}"; +Context()->normalStrings; + +# MathObjects +Context("Fraction-NoDecimals"); +if ($n1 > 0) { + $c1n1 = Compute("($coef1)^($n1)"); +} else { + $c1n1 = Compute("1/($coef1)^(|$n1|)"); +} +if ($n2 > 0) { + $c2n2 = Compute("($coef2)^($n2)"); +} else { + $c2n2 = Compute("1/($coef2)^(|$n2|)"); +} +$coef = Compute("$c1n1*$c2n2"); +Context("Numeric")->variables->are(p=>"Real",q=>"Real"); + +$nx = Compute("($nx1)*($n1) + ($nx2)*($n2)"); +$ny = Compute("($ny1)*($n1) + ($ny2)*($n2)"); + + +$nx11 = Compute("($nx1)*($n1)"); +$nx22 = Compute("($nx2)*($n2)"); +$ny11 = Compute("($ny1)*($n1)"); +$ny22 = Compute("($ny2)*($n2)"); + +# +# Display exponents nicely +# +$w1 = 10; # width of 1st answer blank +$w2 = 10; # width of 2nd answer blank +$w3 = 10; # width of 3rd answer blank +Context()->texStrings; +if ($displayMode eq 'TeX') { + $showpower = + "\( \displaystyle $expression = (" . ans_rule($w1) . ")p^{" . ans_rule($w2) . "}q^{" . ans_rule($w3) . "}\)"; +} else { + $showpower = + ColumnTable($BR. + "\( \displaystyle $expression = \)" . ans_rule($w1), + BeginTable(border=>0, spacing=>0, padding=>0). + AlignedRow(["",ans_rule($w2),"",ans_rule($w3)], align=>LEFT, separation=>0). + AlignedRow(["\( p\)", + "", + " \(q\)", + ""], + align=>LEFT, separation=>0). + EndTable(), + indent=>0, separation=>0, valign=>"BOTTOM") +} +Context()->normalStrings; + + +########################### +# Main text + +BEGIN_PGML +Simplify the following expression. Use negative or zero exponents when necessary. + +[$showpower]*** + +[@ knowlLink( +"Quick hint", value => "Start by distributing powers over products.") +@]* +END_PGML + + +############################ +# Answer evaluation + +$showPartialCorrectAnswers = 1; + +ANS( $coef->cmp() ); +ANS( $nx->cmp() ); +ANS( $ny->cmp() ); + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +You want to use the following three rules: + +* Distributive property for powers and products: [: (a b)^n = a^n b^n :]. +* First law of exponents: [: a^n a^m = a^(m+n) :]. +* Second law of exponents: [: (a^n)^m = a^(mn) :]. + +Also, don't forget to distribute powers to the coefficients as well: + +[:: (2xy)^n = 2^n x^n y^n ::], not [:: 2x^n y^n ::]! + +Finally, remember that even powers of negative numbers are positive! +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +You start by distributing the powers over products: + +[:: ([$coef1]p^[$nx1]q^[$ny1])^[$n1] ([$coef2]p^[$nx2]q^[$ny2])^[$n2] = +[$coef1]^[$n1](p^[$nx1])^[$n1](q^[$ny1])^[$n1] [$coef2]^[$n2](p^[$nx2])^[$n2](q^[$ny2])^[$n2] ::] + +Then calculating the power of the coefficients and using the second law of exponents: + +[:: ([$c1n1])p^(([$nx1])([$n1]))q^(([$ny1])([$n1])) ([$c2n2])p^(([$nx2])([$n2]))q^(([$ny2])([$n2])) = + ([$c1n1])p^[$nx11] q^[$ny11] ([$c2n2])p^[$nx22] q^[$ny22] ::] + +Then, using commutative property of multiplication, we get + +[:: ([$c1n1]) ([$c2n2])*p^[$nx11]*p^[$nx22]*q^[$ny11]*q^[$ny22] ::] + +Finally, multiplying [: ([$c1n1]) ([$c2n2]) :] and using the first law of exponents: + +[:: [$coef]*p^([$nx11]+[$nx22])*q^([$ny11]+[$ny22]) = [$coef]*p^[$nx]*q^[$ny] ::] +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/exponents/simplify3.pg b/Contrib/SVSU/College_Algebra/exponents/simplify3.pg new file mode 100644 index 0000000000..75bee60951 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/exponents/simplify3.pg @@ -0,0 +1,145 @@ +## DESCRIPTION +## Algebra: Simplify expression with exponents and fractions +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of exponents) +## Level(2) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"AnswerFormatHelp.pl", +"contextLimitedPolynomial.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +Context("Numeric"); + +$coef1 = list_random(2,3,5,7); +do { $coef2 = list_random(2,3,5,7); } until ($coef2 != $coef1); + +if ( $coef1 <= 3 and $coef2 <= 3 ) { $n = list_random(3,4); } +elsif ( $coef1 <= 5 and $coef2 <= 5 ) { $n = list_random(2,3); } +else { $n = 2; } + +$nx = random(3,9,1); +do { $ny = random(3,9,1); } until ( $ny != $nx ); + +# TeX +Context()->texStrings; +$expression = "\left( \frac{$coef1 a^{$nx}}{$coef2 b^{$ny}} \right)^{$n}"; +Context()->normalStrings; + +# MathObjects +$topcoef = Compute("($coef1)^($n)"); +$botcoef = Compute("($coef2)^($n)"); +$ntop = Compute("($nx)*($n)"); +$nbot = Compute("($ny)*($n)"); + +Context("LimitedPolynomial-Strict")->variables->are(a=>"Real",b=>"Real"); + +$numerator = Compute("$topcoef*a^$ntop"); +$denominator = Compute("$botcoef*b^$nbot"); + +Context("Numeric"); +# +$w1 = 10; # width of 1st answer blank +$w2 = 10; # width of 2nd answer blank +Context()->texStrings; +if ($displayMode eq 'TeX') { + $showpower = + "\( \displaystyle $expression = \frac{" . ans_rule($w1) . "}{" . ans_rule($w2) . "}\)"; +} else { + $showpower = + ColumnTable("\( \displaystyle $expression = \)", + BeginTable(border=>0, spacing=>0, padding=>0). + AlignedRow([ans_rule($w1)], align=>CENTER, separation=>0). + AlignedRow([$HR], align=>CENTER, separation=>0). + AlignedRow([ans_rule($w1)], align=>CENTER, separation=>0). + EndTable(), + indent=>0, separation=>0, valign=>"CENTER") +} +Context()->normalStrings; + + +########################### +# Main text + +BEGIN_PGML +Simplify the following expression as much as possible. Use only positive exponents. + +[$showpower]*** + +[@ AnswerFormatHelp("formulas") @]* +[@ AnswerFormatHelp("exponents") @]* + +[@ knowlLink( +"Quick hint", value => "Start by distributing powers over fractions and products.") +@]* +END_PGML + + +############################ +# Answer evaluation + +$showPartialCorrectAnswers = 1; + +ANS( $numerator->cmp() ); +ANS( $denominator->cmp() ); + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +You want to use the following three rules: + +* Distributive property for powers and fractions: [: (a/b)^n = (a^n)/(b^n) :]. +* Distributive property for powers and products: [: (a b)^n = a^n b^n :]. +* Second law of exponents: [: (a^n)^m = a^(mn) :]. + +Also, don't forget to distribute powers to the coefficients as well: + +[:: (2xy)^n = 2^n x^n y^n ::], not [:: 2x^n y^n ::]! + +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +You start by distributing the powers over the fraction: + +[`` [$expression] ``] = [:: ([$coef1]a^[$nx])^[$n]/([$coef2]b^[$ny])^[$n] ::] + +Distribute the power over the product in the numerator and in the denominator: + +[:: ([$coef1]a^[$nx])^[$n]/([$coef2]b^[$ny])^[$n] = ([$coef1]^[$n](a^[$nx])^[$n])/([$coef2]^[$n](b^[$ny])^[$n]) ::] + +Simplify the numerator and the denominator using the second law of exponents: + +[:: ([$coef1]^[$n](a^[$nx])^[$n])/([$coef2]^[$n](b^[$ny])^[$n]) = ([$numerator])/([$denominator]) ::] + +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/exponents/simplify4.pg b/Contrib/SVSU/College_Algebra/exponents/simplify4.pg new file mode 100644 index 0000000000..b9f07bd74d --- /dev/null +++ b/Contrib/SVSU/College_Algebra/exponents/simplify4.pg @@ -0,0 +1,179 @@ +## DESCRIPTION +## Algebra: Simplify expression with exponents and fractions +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of exponents) +## Level(1) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"unionTables.pl", +"PGML.pl", +"AnswerFormatHelp.pl", +"contextLimitedPolynomial.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +Context("Numeric"); + +$common = random(2,10,1); + +$coef1 = list_random(2,3,5,7); +do { $coef2 = list_random(2,3,5,7); } until ($coef2 != $coef1); + +if ( $coef1 <= 3 and $coef2 <= 3 ) { $n = list_random(3,4); } +elsif ( $coef1 <= 5 and $coef2 <= 5 ) { $n = list_random(2,3); } +else { $n = 2; } + +$c1 = $coef1*$common; +$c2 = $coef2*$common; + +$nxt = list_random(-1,1)*random(3,9,1); +do { $nxb = list_random(-1,1)*random(3,9,1); } until ( $nxb != $nxt ); +$nyt = list_random(-1,1)*random(3,9,1); +do { $nyb = list_random(-1,1)*random(3,9,1); } until ( $nyb != $nyt ); + +$nx = $nxt - $nxb; +$ny = $nyt - $nyb; + +# TeX +Context()->texStrings; +$expression = "\left( \frac{$c1 x^{$nxt} y^{$nyt}}{$c2 x^{$nxb} y^{$nyb}} \right)^{$n}"; +Context()->normalStrings; + +# MathObjects +$topcoef = Compute("($coef1)^($n)"); +$botcoef = Compute("($coef2)^($n)"); +$xpow = Compute("|($nx)*($n)|"); +$ypow = Compute("|($ny)*($n)|"); + +Context("LimitedPolynomial-Strict")->variables->are(x=>"Real",y=>"Real"); + +if ($nx > 0) { + if ($ny > 0) { + $numerator = Compute("$topcoef*x^$xpow*y^$ypow"); + $denominator = Compute("$botcoef"); + } else { + $numerator = Compute("$topcoef*x^$xpow"); + $denominator = Compute("$botcoef*y^$ypow"); + } +} else { + if ($ny > 0) { + $numerator = Compute("$topcoef*y^$ypow"); + $denominator = Compute("$botcoef*x^$xpow"); + } else { + $numerator = Compute("$topcoef"); + $denominator = Compute("$botcoef*x^$xpow*y^$ypow"); + } +} + +Context("Numeric"); +# +$w1 = 15; # width of 1st answer blank +$w2 = 15; # width of 2nd answer blank +Context()->texStrings; +if ($displayMode eq 'TeX') { + $showpower = + "\( \displaystyle $expression = \frac{" . ans_rule($w1) . "}{" . ans_rule($w2) . "}\)"; +} else { + $showpower = + ColumnTable("\( \displaystyle $expression = \)", + BeginTable(border=>0, spacing=>0, padding=>0). + AlignedRow([ans_rule($w1)], align=>CENTER, separation=>0). + AlignedRow([$HR], align=>CENTER, separation=>0). + AlignedRow([ans_rule($w1)], align=>CENTER, separation=>0). + EndTable(), + indent=>0, separation=>0, valign=>"CENTER") +} +Context()->normalStrings; + + +########################### +# Main text + +BEGIN_PGML +Simplify the following expression as much as possible. Each of the numerator and denominator should be a simple expression with no fractions and no negative exponents. + +[$showpower]*** + +[@ AnswerFormatHelp("formulas") @]* +[@ AnswerFormatHelp("exponents") @]* + +[@ knowlLink( +"Quick hint", value => "Start by simplifying the expression in parentheses.") +@]* +END_PGML + + +############################ +# Answer evaluation + +$showPartialCorrectAnswers = 1; + +ANS( $numerator->cmp() ); +ANS( $denominator->cmp() ); + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +First simplify the expression in the parentheses. Cancel any common factors of [$c1] and [$c2], +and use the following rules for powers of [: x :] and [: y :]: + +* [: (a^n)/(a^m) = a^(n-m) :]. +* [: a^(-n) = 1/a^n :] + +Then simplify the result using the following rules: + +* Distributive property for powers and fractions: [: (a/b)^n = (a^n)/(b^n) :]. +* Distributive property for powers and products: [: (a b)^n = a^n b^n :]. +* Second law of exponents: [: (a^n)^m = a^(mn) :]. + +Also, don't forget to distribute powers to the coefficients as well: + +[:: (2xy)^n = 2^n x^n y^n ::], not [:: 2x^n y^n ::]! + +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +Start by simplifying the fraction inside the parenthesis. The coefficients [$c1] and [$c2] have +a common factor [$common] which you can cancel. You then split the fraction into a product of several fractions, one with each of the variables, and simplify each of those: + +[`` [$expression] ``] = +[:: ((([$coef1] [$common])/([$coef2] [$common])) ((x^[$nxt])/(x^[$nxb])) ((y^[$nyt])/(y^[$nyb])))^[$n] ::] + +That will simplify to + +[:: (([$coef1]/[$coef2]) (x^([$nxt] - ([$nxb]))) (y^([$nyt] - ([$nyb]))))^[$n] = +(([$coef1]/[$coef2]) x^[$nx] y^[$ny])^[$n] ::] + +Distribute the power over the product and place powers with negative exponents into the denominator: + +[::([$numerator])/([$denominator]) ::] + +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/factor_product_rule/factor_1.pg b/Contrib/SVSU/College_Algebra/factor_product_rule/factor_1.pg new file mode 100644 index 0000000000..cb457012d3 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/factor_product_rule/factor_1.pg @@ -0,0 +1,110 @@ +# DESCRIPTION +# Simplify result of product rule +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Properties of exponents, rational exponents and radicals) +## DBsection(Properties of exponents) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(3) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,rational expressions,product rule') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"unionTables.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +); + +# Define variables here: +Context("Numeric"); + +$a = random(2,9,2); +$b = list_random(-1,1)*random(1,9,2); +do { $c = random(3,10,3); } until ( $c != $a ); +$d = list_random(-1,1)*(random(1,10,3) + list_random(0,1)); + +$e2 = random(3,9,1); +$e2d = $e2 - 1; +$f1 = Compute("$a*x + $b")->reduce(); +$f2 = Compute("$c*x + $d")->reduce(); + +$a2 = Compute("$a/2"); +$ce2 = Compute("$c*$e2"); + +$g = Compute("$a/2*$c + $c*$e2*$a"); +$h = Compute("$a/2*$d + $c*$e2*$b"); + +$ans = Compute("$g*x + $h")->reduce(); + +$w1 = 15; # width of 1st answer blank +Context()->texStrings; +if ($displayMode eq 'TeX') { + $simplified = + "\( \displaystyle \frac{($f2)^{$e2d}" . ans_rule($w1) . "}{($f1)^{\frac{1}{2}}\)"; +} else { + $simplified = + ColumnTable("", + BeginTable(border=>0, spacing=>0, padding=>0). + AlignedRow(["\(\displaystyle ($f2)^{$e2d}\big(\)",ans_rule($w1),"\(\displaystyle\big)\)"], align=>CENTER, separation=>0). + AlignedRow([$HR,$HR,$HR], align=>CENTER, separation=>0). + AlignedRow(["","\(\displaystyle ($f1)^{\frac{1}{2}}\)",""], align=>LEFT, separation=>0). + EndTable(), + indent=>0, separation=>0, valign=>"CENTER") +} +Context()->normalStrings; + + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +The expression + +>>[:: (1/2)*([$f1])^(- 1/2)*[$a]*([$f2])^[$e2] + ([$f1])^(1/2)*[$e2]*([$f2])^([$e2d])*[$c] ::]<< + +can be simplified as + +>>[$simplified]***<< + +Fill in the missing factor. + +END_PGML + +ANS( $ans->cmp() ); + +# Solution: +BEGIN_PGML_SOLUTION +First we start by simplifying the expression a bit: + +>>[:: [$a2]*([$f1])^(- 1/2)*([$f2])^[$e2] + [$ce2]*([$f1])^(1/2)*([$f2])^([$e2d]) ::]<< + +We can factor out [:: ([$f1])^(- 1/2) ::] and [:: ([$f2])^([$e2d]) ::] and simplify the rest: + +[``\begin{align} +[$a2]([$f1])^{-\frac{1}{2}}([$f2])^{[$e2]} + [$ce2]([$f1])^{\frac{1}{2}}([$f2])^{[$e2d]} +&= ([$f1])^{-\frac{1}{2}}([$f2])^{[$e2d]}{\color{green}{\left([$a2]([$f2]) + [$ce2]([$f1])\right)}}\\ +&= ([$f1])^{-\frac{1}{2}}([$f2])^{[$e2d]}{\color{green}{\left([$ans]\right)}}\\ +\end{align}``] + +so the answer is [:: [$ans] ::]. + +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Factor out the **lowest power** or each of the common factors. +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/arrows1.pg b/Contrib/SVSU/College_Algebra/functions/arrows1.pg new file mode 100644 index 0000000000..f2c68f5d05 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/arrows1.pg @@ -0,0 +1,151 @@ +# DESCRIPTION +# Arrow diagrams for functions +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Definition, concept) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,diagram,function') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"PGgraphmacros.pl", +); + +$showPartialAnswers = 1; + +Context("Numeric"); + +# Create a new function to scale + +$to0 = random(5,9,1); +$to1 = random(5,9,1); +$to2 = random(5,9,1); +$to3 = random(5,9,1); +$to4 = random(5,9,1); + +Context("Interval"); + +$domain = Compute("{0,1,2,3,4}"); +$range = Set($to0, $to1, $to2, $to3, $to4); + +# Create a graph and add the function to the graph + +$graph = init_graph(0,0,100,100); + +$xfunc1 = sub { my $t = shift(); + return 25 + 15*cos($t); }; +$xfunc2 = sub { my $t = shift(); + return 75 + 15*cos($t); }; +$yfunc = sub { my $t = shift(); + return 50 + 45*sin($t); }; +$fn1 = new Fun( $xfunc1, $yfunc, $graph ); +$fn2 = new Fun( $xfunc2, $yfunc, $graph ); +$fn1->domain(0,6.2832); +$fn2->domain(0,6.2832); + +$graph->stamps( + closed_circle(25, 20, "blue"), + closed_circle(25, 35, "blue"), + closed_circle(25, 50, "blue"), + closed_circle(25, 65, "blue"), + closed_circle(25, 80, "blue"), + closed_circle(75, 20, "blue"), + closed_circle(75, 35, "blue"), + closed_circle(75, 50, "blue"), + closed_circle(75, 65, "blue"), + closed_circle(75, 80, "blue"), +); + +$l4 = new Label(23,20,'4', 'blue','right','middle','giant'); +$l3 = new Label(23,35,'3', 'blue','right','middle','giant'); +$l2 = new Label(23,50,'2', 'blue','right','middle','giant'); +$l1 = new Label(23,65,'1', 'blue','right','middle','giant'); +$l0 = new Label(23,80,'0', 'blue','right','middle','giant'); +$graph->lb($l0, $l1, $l2, $l3, $l4); + +$l9 = new Label(77,20,'9', 'blue','left','middle','giant'); +$l8 = new Label(77,35,'8', 'blue','left','middle','giant'); +$l7 = new Label(77,50,'7', 'blue','left','middle','giant'); +$l6 = new Label(77,65,'6', 'blue','left','middle','giant'); +$l5 = new Label(77,80,'5', 'blue','left','middle','giant'); +$graph->lb($l5, $l6, $l7, $l8, $l9); + +$graph->moveTo(25,80); +$graph->arrowTo(75, 155 - 15*$to0); +$graph->moveTo(25,65); +$graph->arrowTo(75, 155 - 15*$to1); +$graph->moveTo(25,50); +$graph->arrowTo(75, 155 - 15*$to2); +$graph->moveTo(25,35); +$graph->arrowTo(75, 155 - 15*$to3); +$graph->moveTo(25,20); +$graph->arrowTo(75, 155 - 15*$to4); + +TEXT(beginproblem()); +BEGIN_PGML +The following arrow diagram represents a function [`f`]: + +[@ image(insertGraph($graph),tex_size => 300, width=> 300, height=> 300) @]* + +The domain of the set is [_______________________]{$domain} + +The range of the set is [_______________________]{$range} + +The function values are: + +[`f(0) = `][_____]{$to0} + +[`f(1) = `][_____]{$to1} + +[`f(2) = `][_____]{$to2} + +[`f(3) = `][_____]{$to3} + +[`f(4) = `][_____]{$to4} + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +An arrow going from [`a`] to [`b`] means that [`f(a) = b`]. +END_PGML_HINT + +# Solution: +BEGIN_PGML_SOLUTION +**Domain:** All the points in the left set have arrows starting at them, so all of them are in the domain. The points correspond to +numbers 0, 1, 2, 3 and 4, so the domain is [`[$domain]`]. + +**Range:** The range is a set of all the possible outputs, in other words, all the numbers that correspond to points that have an +arrow ending at them. The range is [`[$range]`]. + +**Values:** The following are the function values: + +[`f(0) = [$to0]`] + +[`f(1) = [$to1]`] + +[`f(2) = [$to2]`] + +[`f(3) = [$to3]`] + +[`f(4) = [$to4]`] + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/diff_quotient1.pg b/Contrib/SVSU/College_Algebra/functions/diff_quotient1.pg new file mode 100644 index 0000000000..5bfb45211b --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/diff_quotient1.pg @@ -0,0 +1,78 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Difference quotient) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,function,functional notation,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = random(2,7,1); +do { $b = list_random(-1,1)*random(2,9,1); } until ( $a != $b ); +do { $c = list_random(-1,1)*random(2,9,1); } until ( $c != $b ); + +$fun = Compute("$a*x^2 + $b*x + $c")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$funxphred = Compute("$a*x^2 + 2*$a*x*h + $a*h^2 + $b*x + $b*h + $c")->reduce(); +$numred = Compute("$a*x^2 + 2*$a*x*h + $a*h^2 + $b*x + $b*h + $c - $a*x^2 - $b*x - $c")->reduce(); + +$diff = Compute("2*$a*x + $a*h + $b")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Given [:: f(x) = [$fun] ::], simplify the difference quotient + +>>[:: (f(x+h) - f(x))/h ::]<< + +as much as possible. + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +[``\begin{align} +\frac{f(x+h) - f(x)}{h} &= \frac{[$funxph] - ([$fun])}{h} \\ +&= \frac{[$funxphred] - ([$fun])}{h} \\ +&= \frac{[$numred]}{h} \\ +&= \frac{h([$diff])}{h} \\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/diff_quotient2.pg b/Contrib/SVSU/College_Algebra/functions/diff_quotient2.pg new file mode 100644 index 0000000000..cc177d7358 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/diff_quotient2.pg @@ -0,0 +1,77 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Difference quotient) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,function,functional notation,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = non_zero_random(-8,8,1); + +$fun = Compute("1/(x-$a)")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$denom = Compute("x-$a")->reduce(); +$denomh = $denom->substitute(x => "x+h"); +$combdenom = ($denom*$denomh)->reduce(); +$numred = Compute("($denom) - ($denomh)")->reduce(); + +$diff = Compute("-1/($combdenom)")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Given [:: f(x) = [$fun] ::], simplify the difference quotient + +>>[:: (f(x+h) - f(x))/h ::]<< + +as much as possible. + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +[``\begin{align} +\frac{f(x+h) - f(x)}{h} &= \frac{[$funxph] - ([$fun])}{h} \\ +&= \frac{\frac{([$denom]) - ([$denomh])}{([$denomh])([$denom])}}{h}\\ +&= \frac{[$numred]}{([$denomh])([$denom])}\cdot\frac{1}{h}\\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/diff_quotient3.pg b/Contrib/SVSU/College_Algebra/functions/diff_quotient3.pg new file mode 100644 index 0000000000..660ff1e1d3 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/diff_quotient3.pg @@ -0,0 +1,78 @@ +# DESCRIPTION +# Difference quotients +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Difference quotient) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,function,functional notation,difference quotients') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"parserDifferenceQuotient.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->add(h=>"Real"); + +# Define variables here: + +$a = non_zero_random(-8,8,1); + +Context()->variables->set(x=>{limits=>[$a,$a+5]}); + +$fun = Compute("sqrt(x-$a)")->reduce(); +$funxph = $fun->substitute(x => "x+h"); +$inside = Compute("x-$a")->reduce(); +$insideh = $inside->substitute(x => "x+h"); +$numred = Compute("($insideh) - ($inside)")->reduce(); + +$diff = Compute("1/($funxph + $fun)")->reduce(); + +$answer = DifferenceQuotient($diff,"h"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Given [:: f(x) = [$fun] ::], simplify the difference quotient + +>>[:: (f(x+h) - f(x))/h ::]<< + +as much as possible. + +----- + +The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +[``\begin{align} +\frac{f(x+h) - f(x)}{h} &= \frac{[$funxph] - [$fun]}{h} \\ +&= \frac{[$funxph] - [$fun]}{h}\cdot\frac{[$funxph] + [$fun]}{[$funxph] + [$fun]} \\ +&= \frac{[$numred]}{h\left([$funxph] + [$fun]\right)}\\ +&= [$diff] +\end{align}``] +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Make sure that your **signs** and **parentheses** are correct! Make sure you fully simplify your answer! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/domain1.pg b/Contrib/SVSU/College_Algebra/functions/domain1.pg new file mode 100644 index 0000000000..ad653af747 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/domain1.pg @@ -0,0 +1,87 @@ +# DESCRIPTION +# Domains of functions +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Domain and range) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,function,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"contextFraction.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = random(2,9,1); +do { $b = random(2,9,1); } until ( $a != $b ); +$d = random(1,20,1); + +Context("Fraction-NoDecimals"); +$c = Compute("-$b/$a"); + +Context("Interval"); +$sol = Compute("[$c,Infinity)"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find the domain of the function + +>>[``f(x) = \sqrt{[$a] x + [$b]} + [$d] ``]<< + +Write the answer using *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$sol} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "In these problems, we want outputs of functions to be real numbers!") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +When looking for a domain of a function, we are always asking the question "What can go wrong while calculating the +output of the function from a given input?" We are looking for operations that are not always defined, or that do not always +produce a real number. + +In this function, such operation is the square root. The number inside the radical symbol cannot be negative. + +In this case, it means [: [$a] x + [$b] :] must be greater or equal to 0. So the domain will consist of all solutions of the +inequality + +>>[`` [$a] x + [$b] \ge 0 ``]<< + +Subtracting [$b] from both sides and dividing by [$a] will give us + +>>[`` x \ge [$c] ``]<< + +In interval notation, this is written as [: x in [[$c], Infinity) :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Is [` \sqrt{[$a] x + [$b]} `] always defined? Is it always a real number? +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/domain2.pg b/Contrib/SVSU/College_Algebra/functions/domain2.pg new file mode 100644 index 0000000000..fa6369c3da --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/domain2.pg @@ -0,0 +1,82 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Domain and range) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,function,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = non_zero_random(-5,9,1); +$diff = random(2,9+$a,1); +$c = Compute("-$a"); +$b = Compute("$c + $diff"); + +$denom = Compute("x - $b")->reduce(); + +Context("Interval"); +$sol = Compute("[$c,$b) U ($b,Infinity)"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find the domain of the function + +>>[``f(x) = \frac{\sqrt{x + [$a]}}{[$denom]} ``]<< + +Write the answer using *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$sol} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "In these problems, we want outputs of functions to be real numbers!") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +When looking for a domain of a function, we are always asking the question "What can go wrong while calculating the +output of the function from a given input?" We are looking for operations that are not always defined, or that do not always +produce a real number. + +In this function, there are two such operations: square root and division. The number inside the radical symbol cannot be negative. The number in the denominator of a fraction cannot be 0. + +In this case, it means [: x + [$a] :] must be greater or equal to 0 **and** [: x - [$b] :] must be **different** from 0. +So the domain will consist of all solutions of the inequality [` x + [$a] \ge 0 `] such that [` [$denom] \neq 0 `]. + +That will be all numbers greater than or equal to [$c] **except** [$b]. + +In interval notation, this is written as [: x in [[$c],[$b]) U ([$b],Infinity) :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Is [` \sqrt{[$a] x + [$b]} `] always defined? Is it always a real number? +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/domain3.pg b/Contrib/SVSU/College_Algebra/functions/domain3.pg new file mode 100644 index 0000000000..29f16225ac --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/domain3.pg @@ -0,0 +1,94 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Domain and range) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,function,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = non_zero_random(-3,6,1); +$pdiff = random(2,6+$a,1); +$ndiff = random(2,7,1); +$c = Compute("-$a"); +$b = Compute("$c + $pdiff"); +$d = Compute("$c - $ndiff"); +$p = Compute("-$b - $d"); +$q = Compute("$b*$d"); + +$denom = Compute("x^2 + $p*x + $q")->reduce(); +$facb = Compute("x - $b")->reduce(); +$facd = Compute("x - $d")->reduce(); + +Context("Interval"); +$sol = Compute("[$c,$b) U ($b,Infinity)"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find the domain of the function + +>>[``f(x) = \frac{\sqrt{x + [$a]}}{[$denom]} ``]<< + +Write the answer using *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$sol} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "In these problems, we want outputs of functions to be real numbers!") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +When looking for a domain of a function, we are always asking the question "What can go wrong while calculating the +output of the function from a given input?" We are looking for operations that are not always defined, or that do not always +produce a real number. + +In this function, there are two such operations: square root and division. The number inside the radical symbol cannot be negative. The number in the denominator of a fraction cannot be 0. + +In this case, it means [: x + [$a] :] must be greater or equal to 0 **and** [: [$denom] :] must be **different** from 0. +So the domain will consist of all solutions of the inequality [` x + [$a] \ge 0 `] such that [` [$denom] \neq 0 `]. + +In order for the square root to be defined, [`x`] has to be greater than or equal to [$c]. + +In order for the division to work, [` [$denom] \neq 0 `]. To find when [` [$denom] = 0 `], we factor the denominator as +[` ([$facb])([$facd]) `]. That is equal to zero when [` x = [$b] `] or when [` x = [$d] `]. Since [$d] is already ruled out by the requirement that [` x \ge [$c] `], all we need to do is make sure [` x \neq [$b] `]. + +In interval notation, this is written as [: x in [[$c],[$b]) U ([$b],Infinity) :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Is [` \sqrt{[$a] x + [$b]} `] always defined? Is it always a real number? +END_PGML_HINT +BEGIN_PGML_HINT +When is the denominator equal to zero? +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/domain_composition.pg b/Contrib/SVSU/College_Algebra/functions/domain_composition.pg new file mode 100644 index 0000000000..e58d3cc05e --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/domain_composition.pg @@ -0,0 +1,107 @@ +# DESCRIPTION +# Domains of composition of functions +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Compositions and combinations of functions) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(3) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,function,composition,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric"); + +# Define variables here: + +$closed = list_random(0,1); +$rightdomf = list_random(0,1); + +$a = list_random(-1,1)*random(1,5,1) + 1; # can be anything except 1 +$b = random(-8,8,1); +$k = list_random(-1,1)*random(1,3,1); +$c = $b - $k*(1 - $a); +$d = $c + $k; + +if($k < 0) { + $left = $d; + $left_included = $closed; + $right = $c; + $right_included = 0; +} else { + $left = $c; + $left_included = 0; + $right = $d; + $right_included = $closed; +} + +Context("Interval"); + +if(($a < 1) xor $rightdomf){ + $int = ($left_included?"[":"(") . "${left}, ${right}" . ($right_included?"]":")"); +} else { + $int = "(-inf, ${left}" . ($left_included?"]":")") . "U" . ($right_included?"[":"(") . "${right}, inf)"; +} + +$sol = Compute($int); + +if($rightdomf){ + $domf = Compute(($closed?"[":"(") . "$a, inf)"); +} else { + $domf = Compute("(-inf, $a" . ($closed?"]":")")); +} + +Context("Numeric"); + +$gfun = Compute("(x - $b)/(x - $c)")->reduce(); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +The function [`f`] has domain [`[$domf]`], and the function [`g`] is given by + +>>[``g(x) = [$gfun]``]<< + +Find the domain of [`f \circ g`]. Write your answer in *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$sol} [@ AnswerFormatHelp("intervals") @]* + +END_PGML + +# Solution: +#BEGIN_PGML_SOLUTION +#When looking for a domain of a function, we are always asking the question "What can go wrong while calculating the +#output of the function from a given input?" We are looking for operations that are not always defined, or that do not always +#produce a real number. +# +#In this function, such operation is the square root. The number inside the radical symbol cannot be negative. +# +#In this case, it means [: [$a] x + [$b] :] must be greater or equal to 0. So the domain will consist of all solutions of the +#inequality +# +#>>[`` [$a] x + [$b] \ge 0 ``]<< +# +#Subtracting [$b] from both sides and dividing by [$a] will give us +# +#>>[`` x \ge [$c] ``]<< +# +#In interval notation, this is written as [: x in [[$c], Infinity) :]. +#END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/graph1.pg b/Contrib/SVSU/College_Algebra/functions/graph1.pg new file mode 100644 index 0000000000..2e1e76df51 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/graph1.pg @@ -0,0 +1,102 @@ +# DESCRIPTION +# Graph transformations +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Graphs) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,graph,function') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"PGgraphmacros.pl", +"parserFunction.pl", +); + +$showPartialAnswers = 1; + +Context("Numeric"); + +# Create a new function to scale + +$p = non_zero_random(-4,4,2); +$q = non_zero_random(-3,3,1); +$fa = 3*$q/($p**4); +$fb = -8*$q/($p**3); +$fc = 6*$q/($p**2); +$fd = ($q > 0?-1:1)*random(1,2,1); +$hs = ($p > 0?-1:1)*random(-1,2,1); + +parserFunction(f => "$fa*(x-$hs)^4 + $fb*(x-$hs)^3 + $fc*(x-$hs)^2 + $fd"); + +# Create a graph and add the function to the graph + +$graph = init_graph(-6,-6,6,6,'axes'=>[0,0],'grid'=>[12,12],'ticks'=>[4,4]); + +add_functions($graph, "f(x) for x in <-6,6> using color:black and weight:2"); +($graph->fn)[0]->steps(200); + +# Create a transformed function +$vflip = list_random(-1,1); + +$hshift = ($p > 0?-1:1)*non_zero_random(-2,3,1); +$vshift = ($q > 0?1:-1)*non_zero_random(-2,3,1)*$vflip; + +$g = Formula("$vflip*f(x - $hshift) + $vshift")->reduce(); + +$horiz = ($hshift > 0)?"right":"left"; +$vert = ($vshift > 0)?"up":"down"; +$ahs = abs($hshift); +$avs = abs($vshift); + +$hunits = ($ahs == 1)?"unit":"units"; +$vunits = ($avs == 1)?"unit":"units"; + +$vfstr = ($vflip < 0)?"flipped vertically upside down and ":""; + +# Add the transformed function to the graph + +add_functions($graph, "$vflip*f(x - $hshift) + $vshift for x in <-6,6> using color:orange and weight:3"); +($graph->fn)[1]->steps(200); + +TEXT(beginproblem()); +BEGIN_PGML +The plot below shows the function [` f `] with thinner black graph, and the function +[` \color{orange}{g} `] with thicker orange graph: + +>>[@ image(insertGraph($graph),tex_size => 300, width=> 300, height=> 300) @]*<< + +Write a formula for the orange function [`\color{orange}{g}`] using the function [`f`]: [____________________]{$g} +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The [`\color{orange}{g}`] can be obtained from [`f`] by horizontal and vertical shifting and possibly a +vertical flip! +END_PGML_HINT + + +# Solution: +BEGIN_PGML_SOLUTION +The orange function is shifted [`[$ahs]`] [$hunits] to the [$horiz]. It is +also [$vfstr] shifted [`[$avs]`] [$vunits] [$vert]. + +The formula for [`\color{orange}{g}`] is [`g(x) = [$g]`]. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/quadratic_vertex.pg b/Contrib/SVSU/College_Algebra/functions/quadratic_vertex.pg new file mode 100644 index 0000000000..66283ac3a4 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/quadratic_vertex.pg @@ -0,0 +1,86 @@ +# DESCRIPTION +# Vertex of parabola +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Graphs) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,function,quadratic,interval') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"contextFraction.pl", +"AnswerFormatHelp.pl", +"parserPopUp.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = list_random(-1,1)*random(2,9,1); +do { $b = random(2,9,1); } until ( $a != $b ); +$c = random(-15,15,1); + +Context("Fraction-NoDecimals"); +$h = Compute("-$b/(2*$a)")->reduce(); +$k = Compute("$a*($h)^2 + $b*$h + $c")->reduce(); + +Context("Point"); +$sol = Compute("($h,$k)"); + +$popup = PopUp( + ["choose","maximum","minimum"], ($a < 0?"maximum":"minimum") +); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Given the quadratic function + +>>[``f(x) = [$a]x^2 + [$b]x + [$c] ``]<< + +find the coordinates of the vertex. Write your answer as a point with integer or fractional coordinates. + +----- + +The vertex: [________________]{$sol} [@ AnswerFormatHelp("points") @]* + +----- + +Is the vertex a maximum or minimum of the function? [__]{$popup} + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +There are two ways to find the vertex of a parabola. You can complete the square, or you can +use the formula. + +Using the formula, the vertex is [:(h,k):], where + +[``h = -\frac{b}{2a} = -\frac{[$b]}{2([$a])} = [$h]``] + +and + +[``k = f(h) = f\left([$h]\right) = [$k]``]. + +----- +If [:a > 0:], the parabola opens up and the vertex is the __minimum__ of the function. If [:a < 0:], +the parabola opens down and the vertex is the __maximum__. In this case, [:a = [$a]:] and so the +vertex is the [@ $popup->correct_ans() @]*. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/functions/table_single.pg b/Contrib/SVSU/College_Algebra/functions/table_single.pg new file mode 100644 index 0000000000..53d35ed005 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/functions/table_single.pg @@ -0,0 +1,145 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Functions) +## DBsection(Definition, concept) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,domain,function,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"PGchoicemacros.pl", +"AnswerFormatHelp.pl", +"niceTables.pl", +); + +$showPartialCorrectAnswers = 1; + +Context("Numeric")->strings->add(undefined=>{}); + +# Define variables here: + +@ind = NchooseK(40,10); +@xs = PGsort( sub {$_[0] < $_[1]}, map {$_ - 20} @ind); + +@ys = map {random(-20,20,1)} @xs; + +# Find three values of x, two of them in the domain, one of them outside the +# domain, and the corresponding answers: + +$undef = random(1,3,1); +@chosen = NchooseK(10,3); + +if ($undef == 1) { + do { $x1 = random(-20,20); } while ( grep {$x1 eq $_} @xs ); + $a1 = Compute("undefined"); + $a1str = 'undefined'; +} else { + $x1 = @xs[$chosen[0]]; + $a1 = @ys[$chosen[0]]; + $a1str = '[:[$a1]:]'; +} +if ($undef == 2) { + do { $x2 = random(-20,20); } while ( grep {$x2 eq $_} @xs ); + $a2 = Compute("undefined"); + $a2str = 'undefined'; +} else { + $x2 = @xs[$chosen[1]]; + $a2 = @ys[$chosen[1]]; + $a2str = '[:[$a2]:]'; +} +if ($undef == 3) { + do { $x3 = random(-20,20); } while ( grep {$x3 eq $_} @xs ); + $a3 = Compute("undefined"); + $a3str = 'undefined'; +} else { + $x3 = @xs[$chosen[2]]; + $a3 = @ys[$chosen[2]]; + $a3str = '[:[$a3]:]'; +} + +Context()->texStrings; +$table = +DataTable([ +[['\(x\) ',midrule => 1],@xs], +['\(f(x)\)',@ys], +], +align=>'r|cccccccccc', +allcellcss => 'vertical-align:top; horizontal-padding: 6pt; ' +); +Context()->normalStrings; + +Context("Interval"); + +# Turn xs and ys into sets. Strip duplicates from ys, otherwise correct answer +# will have the duplicates, possibly confusing students: +$domain = Compute("{" . join(', ', @xs) . "}"); +%rangeref = map { $_ => 1 } @ys; +@rangeuniq = keys %rangeref; +$range = Compute("{" . join(', ', @rangeuniq) . "}"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +The function [: f :] is defined by the table + +[$table]*** + +Find the following values of [: f(x) :]. Use the word "undefined" when appropriate. +----- + +* [: f([$x1]) :] is [________________]{$a1} +* [: f([$x2]) :] is [________________]{$a2} +* [: f([$x3]) :] is [________________]{$a3} + +----- +Find the domain and range of the function [:f:]. Write each **as a set** of real numbers, with proper set notation! + +* Domain: [____________________]{$domain} +* Range: [____________________]{$range} + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +If the given input is in the "[:x:]" row in the table, find the corresponding output in the "[:f(x):]" row. +If the input is not in the "[:x:]" row, there is no corresponding output, and [:f(x):] is *undefined*. + +* [: f([$x1]) :] is [$a1str]** +* [: f([$x2]) :] is [$a2str]** +* [: f([$x3]) :] is [$a3str]** + +----- + +The domain is simply a set containing all the input, while the range is the set containing all the outputs. + +Note that sets are denoted using curly brackets, entries are separated with commas, there should be no duplicate +elements, and the elements *do not* have to be in order: + +* Domain: [:[$domain]:] +* Range: [:[$range]:] + +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Set notation uses curly brackets: [: {1, 4, -3} :]. +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater.pg b/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater.pg new file mode 100644 index 0000000000..8a63272bf7 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater.pg @@ -0,0 +1,87 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Absolute value expressions and functions) +## DBsection(Absolute value inequalities) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(1) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,inequality,absolute value,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +"answerHints.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = random(1,9,1); +$sol = Union(Interval("(-Inf,-$a)"),Interval("($a,Inf)")); + +$answer = $sol->cmp()->withPostFilter(AnswerHints( + Union(Interval("(-Inf,-$a]"),Interval("[$a,Inf)")) => "The inequality is sharp, the endpoints should not be included!", + Interval("(-$a,$a)") => "Not quite right. The inequality is \(>\), not \(<\)!", + Interval("[-$a,$a]") => "Not quite right. The inequality is \(>\), not \(<\)! Also, the inequality is sharp!", +)); + + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Write the solution of the inequality + +>>[::|x| > [$a]::]<< + +using *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$answer} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "Absolute value of a number is the *distance* of the number from zero") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +Since [: |x| :] is the *distance* of [: x :] from 0, the inequality + +>>[:: |x| > [$a] ::]<< + +is satisfied by the numbers that are _*more* than_ [$a] units away from 0. + +That means [: x :] must either be _further than [$a] units to the left_, in other words, [: x < -[$a] :], +_or_, [: x :] must be _*further than* [$a] units to the right_: [: x > [$a] :]. So [: x < -[$a] quad :] _or_ +[: quad x > [$a] :]. That *cannot* be written as a single continuing inequality, so we have to write it as + +>>[:: x < -[$a] quad ::] *or* [:: quad [$a] < x ::].<< + +In words, [: x :] must be either left of [: -[$a] :] or right of [: [$a] :]. + +In interval notation, this is written as [: x in [$sol] :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The inequality says that the *distance* of [: x :] from 0 is *larger* than [$a]. +That is, [: x :] must be either far enough to the left, *or* far enough to the right. +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater_or_equal.pg b/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater_or_equal.pg new file mode 100644 index 0000000000..00c2e8026e --- /dev/null +++ b/Contrib/SVSU/College_Algebra/inequalities/av_simple_greater_or_equal.pg @@ -0,0 +1,85 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Absolute value expressions and functions) +## DBsection(Absolute value inequalities) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(1) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,inequality,absolute value,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +"answerHints.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = random(1,9,1); +$sol = Union(Interval("(-Inf,-$a]"),Interval("[$a,Inf)")); + +$answer = $sol->cmp()->withPostFilter(AnswerHints( + Union(Interval("(-Inf,-$a)"),Interval("($a,Inf)")) => "The inequality is not sharp, the endpoints should be included!", + Interval("[-$a,$a]") => "Not quite right. The inequality is \(\ge\), not \(\le\)!", + Interval("(-$a,$a)") => "Not quite right. The inequality is \(\ge\), not \(\le\)! Also, the inequality is not sharp!", +)); + + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Write the solution of the inequality + +>>[::|x| >=[$a]::]<< + +using *interval notation*. + +----- + +The solution: [` x \in `] [________________]{$answer} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "Absolute value of a number is the *distance* of the number from zero") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +Since [: |x| :] is the *distance* of [: x :] from 0, the inequality + +>>[:: |x| >= [$a] ::]<< + +is satisfied by the numbers that are *at least* [$a] units away from 0. + +That means [: x :] must either be _at least [$a] units to the left_, in other words, [: x <= -[$a] :], +_or_, [: x :] must be _at least [$a] units to the right_: [: x >= [$a] :]. So [: x <= -[$a] quad :] _or_ +[: quad x >= [$a] :]. That *cannot* be written as a single continuing inequality, so we have to write it as + +>>[:: x <= -[$a] quad ::] *or* [:: quad [$a] <= x ::].<< + +In interval notation, this is written as [: x in [$sol] :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The inequality says that the *distance* of [: x :] from 0 is *at least* [$a]. +That is, [: x :] must be either far enough to the left, *or* far enough to the right. +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/inequalities/av_simple_less.pg b/Contrib/SVSU/College_Algebra/inequalities/av_simple_less.pg new file mode 100644 index 0000000000..a65e402026 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/inequalities/av_simple_less.pg @@ -0,0 +1,85 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Absolute value expressions and functions) +## DBsection(Absolute value inequalities) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(1) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,inequality,absolute value,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +"answerHints.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = random(1,9,1); +$sol = Interval("(-$a,$a)"); + +$answer = $sol->cmp()->withPostFilter(AnswerHints( + Interval("[-$a,$a]") => "The inequality is sharp, the endpoints should not be included!", +)); + + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Write the solution of the inequality + +>>[::|x| < [$a]::]<< + +using *interval notation*. + +----- + +The solution: [` x \in `] [________]{$answer} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "Absolute value of a number is the *distance* of the number from zero") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +Since [: |x| :] is the *distance* of [: x :] from 0, the inequality + +>>[:: |x| < [$a] ::]<< + +is satisfied by the numbers that are _less than_ [$a] units away from 0. + +That means [: x :] must _not be too far to the left_, in other words, [: x > -[$a] :]. +At the same time, [: x :] must _not be to far to the right_: [: x < [$a] :]. So [: x > -[$a] :] *and* +[: x < [$a] :]. That can be written as a single continuing inequality: + +>>[:: -[$a] < x < [$a]. ::]<< + +In words, [: x :] must be _strictly between_ [: -[$a] :] and [: [$a] :]. + +In interval notation, this is written as [: x in [$sol] :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The inequality says that the *distance* of [: x :] from 0 is not too large. That is, [: x :] cannot be too far to the +left, but *at the same time*, [: x :] cannot be too far to the right! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/inequalities/av_simple_less_or_eq.pg b/Contrib/SVSU/College_Algebra/inequalities/av_simple_less_or_eq.pg new file mode 100644 index 0000000000..7406463769 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/inequalities/av_simple_less_or_eq.pg @@ -0,0 +1,86 @@ +# DESCRIPTION +# Absolute value inequalities (simple, less then) +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Absolute value expressions and functions) +## DBsection(Absolute value inequalities) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(1) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,inequality,absolute value,intervals') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +"answerHints.pl", +); +Context("Numeric"); + +# Define variables here: + +$a = random(0.5,9.5,1); +$sol = Interval("[-$a,$a]"); + +$answer = $sol->cmp()->withPostFilter(AnswerHints( + Interval("(-$a,$a)") => "The inequality is not sharp, the endpoints should be included!", +)); + + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Write the solution of the inequality + +>>[::|x| <= [$a]::]<< + +using *interval notation*. + +----- + +The solution: [` x \in `] [________]{$answer} [@ AnswerFormatHelp("intervals") @]* + +[@ knowlLink( +"Reminder", value => "Absolute value of a number is the *distance* of the number from zero") +@]* +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +Since [: |x| :] is the *distance* of [: x :] from 0, the inequality + +>>[:: |x| <= [$a] ::]<< + +is satisfied by the numbers that are _less than_ [$a] units away from 0. + +That means [: x :] must _at most [$a] units to the left_, in other words, [: x >= -[$a] :]. +At the same time, [: x :] must _at most [$a] units to the right_: [: x <= [$a] :]. +So [: x >= -[$a] :] *and* [: x <= [$a] :]. +That can be written as a single continuing inequality: + +>>[:: -[$a] <= x <= [$a]. ::]<< + +In words, [: x :] must be _between_ [: -[$a] :] and [: [$a] :], including the endpoints. + +In interval notation, this is written as [: x in [$sol] :]. +END_PGML_SOLUTION + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The inequality says that the *distance* of [: x :] from 0 is not too large. That is, [: x :] cannot be too far to the +left, but *at the same time*, [: x :] cannot be too far to the right! +END_PGML_HINT + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/intervals/intervals1.pg b/Contrib/SVSU/College_Algebra/intervals/intervals1.pg new file mode 100644 index 0000000000..06983260a2 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/intervals/intervals1.pg @@ -0,0 +1,142 @@ +## DESCRIPTION +## Algebra: Write a set in interval notation +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Algebra of real numbers and simplifying expressions) +## DBsection(Inequalities and intervals) +## Level(1) +## KEYWORDS('algebra', 'intervals') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"PGgraphmacros.pl", +"AnswerFormatHelp.pl", +"PGchoicemacros.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +Context("Interval"); + +# Create number line: + +$gr = init_graph(-6,-1,6,1, +size=>[600,100]); + +$gr->moveTo(-6,0); +$gr->lineTo(6,0,"black"); + +for (my $i=-5; $i < 6; $i++) { + $gr->moveTo($i,.15); + $gr->lineTo($i,-.15); + $gr->lb( new Label($i,-.35,"$i", + 'black','center','middle')); +} + +# create random intervals: + +@ind = NchooseK(13,6); +@ints = -6..6; +@endpoints = num_sort(@ints [@ind]); + +# -6 is -Infinity: + +if ($endpoints[0] == -6) { + $l1 = "("; # just for completeness + $r1 = list_random(")", "]"); + $i1 = Interval("(-Infinity,$endpoints[1]" . $r1); + $gr->moveTo($endpoints[1],0); + $gr->arrowTo(-6,0,'blue',3); + $gr->stamps( ($r1 eq ")")? open_circle($endpoints[1],0,'blue') : closed_circle($endpoints[1],0,'blue') ); +} else { + $l1 = list_random("(", "["); + $r1 = list_random(")", "]"); + $i1 = Interval($l1 . "$endpoints[0],$endpoints[1]" . $r1); + $gr->moveTo($endpoints[0],0); + $gr->lineTo($endpoints[1],0,'blue',3); + $gr->stamps( ($l1 eq "(")? open_circle($endpoints[0],0,'blue') : closed_circle($endpoints[0],0,'blue') ); + $gr->stamps( ($r1 eq ")")? open_circle($endpoints[1],0,'blue') : closed_circle($endpoints[1],0,'blue') ); +} + +$l2 = list_random("(", "["); +$r2 = list_random(")", "]"); +$i2 = Interval($l2 . "$endpoints[2],$endpoints[3]" . $r2); +$gr->moveTo($endpoints[2],0); +$gr->lineTo($endpoints[3],0,'blue',3); +$gr->stamps( ($l2 eq "(")? open_circle($endpoints[2],0,'blue') : closed_circle($endpoints[2],0,'blue') ); +$gr->stamps( ($r2 eq ")")? open_circle($endpoints[3],0,'blue') : closed_circle($endpoints[3],0,'blue') ); + +# 6 is Infinity: + +if ($endpoints[5] == 6) { + $l3 = list_random("(", "["); + $r3 = ")"; # just for completeness + $i3 = Interval($l3 . "$endpoints[4],Infinity" . $r3); + $gr->moveTo($endpoints[4],0); + $gr->arrowTo(6,0,'blue',3); + $gr->stamps( ($l3 eq "(")? open_circle($endpoints[4],0,'blue') : closed_circle($endpoints[4],0,'blue') ); +} else { + $l3 = list_random("(", "["); + $r3 = list_random(")", "]"); + $i3 = Interval($l3 . "$endpoints[4],$endpoints[5]" . $r3); + $gr->moveTo($endpoints[4],0); + $gr->lineTo($endpoints[5],0,'blue',3); + $gr->stamps( ($l3 eq "(")? open_circle($endpoints[4],0,'blue') : closed_circle($endpoints[4],0,'blue') ); + $gr->stamps( ($r3 eq ")")? open_circle($endpoints[5],0,'blue') : closed_circle($endpoints[5],0,'blue') ); +} + +$showPartialCorrectAnswers = 1; + +$answer = Union($i1, $i2, $i3); + +########################### +# Main text + +BEGIN_PGML + +Write the set pictured below using interval notation: + +>> [@ image(insertGraph($gr), width=>$pixels, height=>$pixels, tex_size=>900) @]* << + +>> [______________________________]{$answer} [@ AnswerFormatHelp("intervals") @]* << + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Interval notation is trying to give you the same information as the picture. +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +The set consist of three intervals, [` [$i1] `], [` [$i2] `] and [` [$i3] `]. Using the union notation +it will be written as + +[` [$answer] `] + +You type in [$answer]. +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/intervals/intervals2.pg b/Contrib/SVSU/College_Algebra/intervals/intervals2.pg new file mode 100644 index 0000000000..d4becc23d3 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/intervals/intervals2.pg @@ -0,0 +1,186 @@ +## DESCRIPTION +## Algebra: Write a set in interval notation +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Algebra of real numbers and simplifying expressions) +## DBsection(Inequalities and intervals) +## Level(1) +## KEYWORDS('algebra', 'intervals') + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"PGgraphmacros.pl", +"AnswerFormatHelp.pl", +"PGchoicemacros.pl", +); + +TEXT(beginproblem()); + +########################### +# Setup + +Context("Interval"); + +# Create number line: + +$gr = init_graph(-6,-1,6,1, +size=>[600,100]); + +$gr->moveTo(-6,0); +$gr->lineTo(6,0,"black"); + +for (my $i=-5; $i < 6; $i++) { + $gr->moveTo($i,.15); + $gr->lineTo($i,-.15); + $gr->lb( new Label($i,-.35,"$i", + 'black','center','middle')); +} + +# create random intervals: + +@ind = NchooseK(13,8); +@ints = -6..6; +@endpoints = num_sort(@ints [@ind]); + +# Choose which point is isolated: + +$isol = random(0,1,1); + +# -6 is -Infinity: + +if ($endpoints[0] == -6) { + $l1 = "("; # just for completeness + if ($isol == 1) { + $r1 = ")"; + } else { + $r1 = list_random(")", "]"); + } + $i1 = Interval("(-Infinity,$endpoints[1]" . $r1); + $gr->moveTo($endpoints[1],0); + $gr->arrowTo(-6,0,'blue',3); + $gr->stamps( ($r1 eq ")")? open_circle($endpoints[1],0,'blue') : closed_circle($endpoints[1],0,'blue') ); +} else { + $l1 = list_random("(", "["); + if ($isol == 1) { + $r1 = ")"; + } else { + $r1 = list_random(")", "]"); + } + $i1 = Interval($l1 . "$endpoints[0],$endpoints[1]" . $r1); + $gr->moveTo($endpoints[0],0); + $gr->lineTo($endpoints[1],0,'blue',3); + $gr->stamps( ($l1 eq "(")? open_circle($endpoints[0],0,'blue') : closed_circle($endpoints[0],0,'blue') ); + $gr->stamps( ($r1 eq ")")? open_circle($endpoints[1],0,'blue') : closed_circle($endpoints[1],0,'blue') ); +} + +if ($isol == 1) { + $l2 = "("; + $r2 = list_random(")", "]"); + $i2 = Interval($l2 . "$endpoints[1],$endpoints[2]" . $r2); + $gr->moveTo($endpoints[1],0); + $gr->lineTo($endpoints[2],0,'blue',3); + $gr->stamps( ($r2 eq ")")? open_circle($endpoints[2],0,'blue') : closed_circle($endpoints[2],0,'blue') ); + + $i3 = Set("{$endpoints[3]}"); + $gr->stamps(closed_circle($endpoints[3],0,'blue')); +} else { + $i2 = Set("{$endpoints[2]}"); + $gr->stamps(closed_circle($endpoints[2],0,'blue')); + + $l3 = list_random("(", "["); + $r3 = ")"; + $i3 = Interval($l3 . "$endpoints[3],$endpoints[4]" . $r3); + $gr->moveTo($endpoints[3],0); + $gr->lineTo($endpoints[4],0,'blue',3); + $gr->stamps( ($l3 eq "(")? open_circle($endpoints[3],0,'blue') : closed_circle($endpoints[3],0,'blue') ); +} + +# 6 is Infinity: + +if ($endpoints[5] == 6) { + if ($isol == 0) { + $l4 = "("; + } else { + $l4 = list_random("(", "["); + } + $r4 = ")"; # just for completeness + $i4 = Interval($l4 . "$endpoints[4],Infinity" . $r4); + $gr->moveTo($endpoints[4],0); + $gr->arrowTo(6,0,'blue',3); + $gr->stamps( ($l4 eq "(")? open_circle($endpoints[4],0,'blue') : closed_circle($endpoints[4],0,'blue') ); +} else { + if ($isol == 0) { + $l4 = "("; + } else { + $l4 = list_random("(", "["); + } + $r4 = list_random(")", "]"); + $i4 = Interval($l4 . "$endpoints[4],$endpoints[5]" . $r4); + $gr->moveTo($endpoints[4],0); + $gr->lineTo($endpoints[5],0,'blue',3); + $gr->stamps( ($l4 eq "(")? open_circle($endpoints[4],0,'blue') : closed_circle($endpoints[4],0,'blue') ); + $gr->stamps( ($r4 eq ")")? open_circle($endpoints[5],0,'blue') : closed_circle($endpoints[5],0,'blue') ); +} + +# This is for solution +if ($isol == 0) { + $isolated_point = $endpoints[2]; + $hole = $endpoints[4]; +} else { + $isolated_point = $endpoints[3]; + $hole = $endpoints[1]; +} + +$showPartialCorrectAnswers = 1; + +$answer = Union($i1, $i2, $i3, $i4); + +########################### +# Main text + +BEGIN_PGML + +Write the set pictured below using interval notation: + +>> [@ image(insertGraph($gr), width=>$pixels, height=>$pixels, tex_size=>900) @]* << + +>> [______________________________]{$answer} [@ AnswerFormatHelp("intervals") @]* << + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Interval notation is trying to give you the same information as the picture. Remember how to enter +intervals that consist of a single point. +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION +Note that there is a single point interval at [` [$isolated_point] `] and also a "hole" between two adjacent intervals +at [` [$hole] `]. + +The set consist of four intervals, [` [$i1] `], [` [$i2] `], [` [$i3] `] and [` [$i4] `]. Using the union notation +it will be written as + +[` [$answer] `] + +You can enter this as [$answer]. +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/lines/perp_line.pg b/Contrib/SVSU/College_Algebra/lines/perp_line.pg new file mode 100644 index 0000000000..c7cb655b30 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/lines/perp_line.pg @@ -0,0 +1,89 @@ +# DESCRIPTION +# Identify a circle by equation +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Linear equations and functions) +## DBsection(Parallel and perpendicular lines) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra,equations,circle') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"contextFraction.pl", +"parserImplicitPlane.pl", +"AnswerFormatHelp.pl", +); +Context("Numeric")->variables->are(x=>"Real", y=>"Real"); + +# Define variables here: + +$a = non_zero_random(-10,10); +do {$b = non_zero_random(-10,10);} until ( $a != $b ); +do {$c = non_zero_random(-10,10,1);} until ( gcd($a,$c) != 1 or gcd($b,$c) != 1 ); + +$left = Compute("$a*x + $b*y")->reduce("(-x)-y" => 0); + +$h = non_zero_random(-8,8); +$k = non_zero_random(-8,8); + +$d = Compute("$b*$h - $a*$k"); + +$xmh = Compute("x - $h")->reduce(); +$ymk = Compute("y - $k")->reduce(); + +Context("Fraction-NoDecimals"); +$slope = Compute("-$a/$b"); +$slope1 = Compute("$b/$a"); + +Context("ImplicitPlane")->variables->are(x=>"Real", y=>"Real"); +$line = ImplicitPlane("$b*x - $a*y = $d"); + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find an equation of the line that passes through [:([$h],[$k]):] and is perpendicular to + +>>[:: [$left] = [$c] ::].<< + +----- + +The equation: [________________]{$line} [@ AnswerFormatHelp("equations") @]* + +END_PGML + +# Solution: +BEGIN_PGML_SOLUTION +There are two ways to solve this problem. One is very fast an easy, the other one is little bit slower. + +The slow one goes like this: + +We already know a **point** the line must pass through. If we can figure out the slope of the line, we can use the +**point-slope form** [`y - k = m(x-h)`] to find the equation of the line. + +Slopes of two perpendicular lines must give us [`-1`] when multiplied: [`m_1 m_2 = -1`]. That means [`m_2 = -\frac{1}{m_1}`]. + +One way to find the slope of the given line is to solve for [:y:] to get the line in the slope-intercept form. Doing so will give us [`m_1 = [$slope]`]. From that, + +>>[`` m_2 = -\frac{1}{m_1} = -\frac{1}{[$slope]} = [$slope1]``]<< + +Then the equation we are looking for is + +>>[`` [$ymk] = [$slope1]\left([$xmh]\right) ``]<< + +which can be simplified to [`[$line]`]. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/polynomials/end_behavior1.pg b/Contrib/SVSU/College_Algebra/polynomials/end_behavior1.pg new file mode 100644 index 0000000000..f16982b72b --- /dev/null +++ b/Contrib/SVSU/College_Algebra/polynomials/end_behavior1.pg @@ -0,0 +1,103 @@ +## DESCRIPTION +## Algebra: End behavior of a polynomial. +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Polynomial equations and functions) +## DBsection(Graphs of polynomials) +## Level(2) +## KEYWORDS('Algebra', 'Functions','Polynomial') +## Institution(SVSU) +## Author(Jan Hlavacek) + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"AnswerFormatHelp.pl", +"parserPopUp.pl", +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + +Context("Numeric"); + +$a = non_zero_random(-20,20,1); +$b = non_zero_random(-20,20,1); +$c = non_zero_random(-20,20,1); +$const = random(-10,10,1); +$xdeg = random(1,4,1); +$xdegadd = random(2,10,2); +$xdegmid = $xdeg + random(1,$xdegadd - 1,1); + +$poly = Compute("$a*x^($xdeg+$xdegadd) + $b*x^$xdegmid + $c*x^$xdeg + $const")->reduce("(-x)+y" => 0, "(-x)-y" => 0); + +if ($xdeg % 2) { # odd degree + $left = ($a > 0)?"down":"up"; +} else { # even degree + $left = ($a > 0)?"up":"down"; +} + +$right = ($a > 0)?"up":"down"; + +$popup_left = PopUp( + ["choose", "up", "down"], + $left, +); + +$popup_right = PopUp( + ["choose", "up", "down"], + $right, +); + +if ($const) { +$const_str = "The constant term of the polynomial \(p(x)\) is \($const\)." +} else { +$const_str = "The polynomial \(p(x)\) does not have a explicit constant term, which means that the constant term is \(0\)." +} + +$leading = Compute("$a*x^($xdeg+$xdegadd)")->reduce(); + +$parity = "**" . (($xdeg % 2)?"odd":"even") . "**"; +$sign = "**" . (($a > 0)?"positive":"negative") . "**"; + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +For the polynomial [` p(x) = [$poly] `], answer the following questions: + +1. What is the [:y:]-coordinate of the [:y:]-intercept of [:p(x):]? [:y = :] [______________]{$const} + +2. What is the end behavior of the polynomial? + + a. As [`x \to -\infty`], [`p(x)`] goes [__]{$popup_left}. + b. As [`x \to \infty`], [`p(x)`] goes [__]{$popup_right}. + +END_PGML +# +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +You may want to consider the constant term and the leading term. +END_PGML_HINT + +# Solution: +BEGIN_PGML_SOLUTION +1. The [:y:]-intercept of a polynomial function is its constant term. [$const_str]*** + + The [:y:]-intercept is the point [:(0,[$const]):], with [:y:]-coordinate [:[$const]:]. + +2. The end behavior of a polynomial is determined by the end behavior of its leading term. + The leading term of [:p(x):] is [:[$leading]:]. The degree of the leading coefficient (and therefore the degree + of the whole polynomial) is [$parity]**, and the leading coefficient [:[$a]:] is [$sign]**. + + The polynomial goes **[@ $popup_left->correct_ans() @]* **on the left and **[@ $popup_right->correct_ans() @]* **on the right. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/polynomials/find_all_info_01_scaffold.pg b/Contrib/SVSU/College_Algebra/polynomials/find_all_info_01_scaffold.pg new file mode 100644 index 0000000000..0790d0a89b --- /dev/null +++ b/Contrib/SVSU/College_Algebra/polynomials/find_all_info_01_scaffold.pg @@ -0,0 +1,358 @@ +# DESCRIPTION +# Gives the graph of a polynomial function +# Asks to find the zeros and their multiplicities, degree (even/odd), and +# leading coeff (pos/neg) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Polynomial equations and functions) +## DBsection(Graphs of polynomials) +## Institution(University of Missouri-Columbia) +## Institution(SVSU) +## Author(Rick Lynch) +## Author(Jan Hlavacek) +## MLT(polynomial_all_info) +## Level(3) +## KEYWORDS('functions', 'polynomials', 'graphs') + +# The original problem by Rick Lynch (UoM-C) modified to use PGML and scaffold +# by Jan Hlavacek (SVSU) (jhlavace@svsu.edu) +# +# The original problem in OPL: +# Mizzou/Algebra/graph_polynomials/find_all_info_01.pg + +########################################################################### +# initialization +########################################################################### +DOCUMENT(); +loadMacros( + "AnswerFormatHelp.pl", + "MathObjects.pl", + "PGgraphmacros.pl", + "PGstandard.pl", + "parserPopUp.pl", + "PGcourse.pl", + "PGML.pl", + "scaffold.pl", +); + +TEXT(beginproblem()); +$refreshCachedImages = 1; +$showPartialCorrectAnswers = 1; + + +########################################################################### +# setup contexts and variables +########################################################################### +Context("Numeric"); +Context()->strings->add("even"=>{}, "e"=>{alias=>"even"}, +"odd"=>{}, "o"=>{alias=>"odd"}, +"positive"=>{}, "pos"=>{alias=>"positive"}, "p"=>{alias=>"positive"}, +"negative"=>{}, "neg"=>{alias=>"negative"}, "n"=>{alias=>"negative"}); +Context()->{error}{msg}{"Operands of '*' can't be words"} = " "; +$numzeros = random(2,5); +do { + @posszeros = (-10..10); + @zeros = (1..$numzeros); + for ($i = 0; $i < $numzeros; $i++) { + $zeros[$i] = list_random(@posszeros); + if ($numzeros == 2 || $numzeros == 3) { + $powers[$i] = random(2,3); + } else { + $powers[$i] = random(1,2); + } + $removed = 0; + $count = 0; + do { # Remove the selected zero + if ($posszeros[$count] == $zeros[$i]) { + $tmp = $posszeros[$count]; + $posszeros[$count] = $posszeros[scalar(@posszeros)-1]; + $posszeros[scalar(@posszeros)-1] = $tmp; + pop(@posszeros); + $removed = 1; + } + $count++; + } until ($removed || $count == scalar(@posszeros)); + $removed = 0; + $count = 0; + do { # Remove the selected zero - 1 so zeros are not too close to each other + if ($posszeros[$count] == $zeros[$i]-1) { + $tmp = $posszeros[$count]; + $posszeros[$count] = $posszeros[scalar(@posszeros)-1]; + $posszeros[scalar(@posszeros)-1] = $tmp; + pop(@posszeros); + $removed = 1; + } + $count++; + } until ($removed || $count == scalar(@posszeros)); + $removed = 0; + $count = 0; + do { # Remove the selected zero + 1 so zeros are not too close to each other + if ($posszeros[$count] == $zeros[$i]+1) { + $tmp = $posszeros[$count]; + $posszeros[$count] = $posszeros[scalar(@posszeros)-1]; + $posszeros[scalar(@posszeros)-1] = $tmp; + pop(@posszeros); + $removed = 1; + } + $count++; + } until ($removed || $count == scalar(@posszeros)); + } + + $yint = 1; # y-intercept (is it needed for anything?) + for ($i = 0; $i < $numzeros; $i++) { + $yint = $yint*((-$zeros[$i])**$powers[$i]); + } + + # this sub routine represents what is to be the graphed polynomial (before + # scaling) + sub poly { + my $x = shift(); + $prod = 1; + for ($i = 0; $i < $numzeros; $i++) { + $prod = $prod*(($x - $zeros[$i])**$powers[$i]); + } + return $prod; + }; + + # sort zeros from low to high; (Webwork has a sorting function) + $swapped = 1; + $count = 0; + while ($swapped) { + $swapped = 0; + $count++; + for ($i = 0; $i < $numzeros - $count; $i++) { + if ($zeros[$i] > $zeros[$i+1]) { + $tmp = $zeros[$i]; + $zeros[$i] = $zeros[$i+1]; + $zeros[$i+1] = $tmp; + $swapped = 1; + } + } + } + + # this next bit is to be sure that the gap between the low or high point + # between zeros and the x-axis is not too small + for ($i = 0; $i < $numzeros-1; $i++) { + $maxs[$i] = 0; + } + + for ($j = 0; $j < $numzeros-1; $j++) { + $steps = 100; + $stepsize = ($zeros[$j+1] - $zeros[$j])/$steps; + for ($k = 0; $k < $steps; $k++) { + $tmp = abs(poly($zeros[$j]+$k*$stepsize)); + if ($tmp > $maxs[$j]) { + $maxs[$j] = $tmp; + } + } + } + + $min = min(@maxs); + $max = max(@maxs); + $scale = random(5,9); + $a = random(-1,1,2)*$scale/max($max); + $tmp1 = abs($min*$a); + $tmp2 = abs($max*$a); +} until (abs($tmp2/$tmp1) < 3*$scale/2); + +# The resulting scaled polynomial +$expn = sub { + my $x = shift(); + $prod = $a; + for ($i = 0; $i < $numzeros; $i++) { + $prod = $prod*(($x - $zeros[$i])**$powers[$i]); + } + return $prod; +}; + +# graph window: +$minx = min($zeros[0],0)-3; +$miny = -10; +$maxx = max($zeros[$numzeros-1],0)+3; +$maxy = 10; +$gsize = 400; + +$graph = init_graph($minx, $miny, $maxx, $maxy, size=>[$gsize,$gsize]); +for ($i = $minx; $i <= $maxx; $i++) { + $graph->moveTo($i,$miny); + $graph->lineTo($i,$maxy,'gray',1); +} +for ($i = $miny; $i <= $maxy; $i++) { + $graph->moveTo($minx,$i); + $graph->lineTo($maxx,$i,'gray',1); +} +$graph->moveTo($minx, 0); +$graph->arrowTo($maxx, 0, 'black', 2); +$graph->arrowTo($minx, 0, 'black', 2); +$graph->moveTo(0, $miny); +$graph->arrowTo(0, $maxy, 'black', 2); +$graph->arrowTo(0, $miny, 'black', 2); +$graph->lb(new Label($maxx-0.1, 0.4, 'x', 'black', 'bottom', 'right')); +$graph->lb(new Label(0.4, $maxy-0.1, 'y', 'black', 'top', 'left')); + +for ($i = $minx+1; $i < $maxx; $i++) { + if ($i != 0 && $i % 5 == 0 || $i == 1) { + $graph->lb(new Label($i,-0.1,$i, 'black', 'top','center')); + } +} + +for ($i = $miny+1; $i < $maxy; $i++) { + if ($i != 0 && $i % 5 == 0 || $i == 1) { + $graph->lb(new Label(-0.1,$i,$i, 'black', 'middle', 'right')); + } +} + +# Stamp zeros +for ($i = 0; $i < $numzeros; $i++) { + $graph->stamps(closed_circle($zeros[$i],0,'blue')); +} + +# Graph the polynomial +$fun = new Fun($expn, $graph); +$fun->steps(1500); +$fun->domain($minx,$maxx); + +$zerosans = List(@zeros); + +for ($i = 0; $i < $numzeros; $i++) { + if ($powers[$i] % 2 == 0) { + $mltpy[$i] = "even"; + } else { + $mltpy[$i] = "odd"; + } +} + +@even_odd = ["choose", "even", "odd"]; + +# Create popups +for ($i = 0; $i < $numzeros; $i++) { + $mult_popup[$i] = PopUp(@even_odd, $mltpy[$i]); +} + +$mult_pgml = "~~n~~n"; +for ($i = 0; $i < $numzeros; $i++) { + $mult_pgml = ($mult_pgml) . "* The zero [:[~~$zeros[$i]]:] has [__]{~~$mult_popup[$i]} multiplicity.~~n~~n"; +} + +$mult_pgml_sol = "~~n~~n"; +for ($i = 0; $i < $numzeros; $i++) { + $mult_pgml_sol = ($mult_pgml_sol) . "* The zero [:[~~$zeros[$i]]:] has [~~$mltpy[$i]] multiplicity.~~n~~n"; +} + +$degree = $powers[0]; +for ($i = 1; $i < $numzeros; $i++) { + $degree = $degree + $powers[$i]; +} +if ($degree % 2 == 0) { + $degreeans = "even"; +} else { + $degreeans = "odd"; +} + +$degree_popup = PopUp(@even_odd, $degreeans); + +if ($a < 0) { + $leadcoeffans = "negative"; +} else { + $leadcoeffans = "positive"; +} + +$leading_popup = PopUp(["choose", "negative", "positive"], $leadcoeffans); + +$dispzeros = "$zeros[0]"; +$dispmults = "$mltpy[0]"; +for ($i = 1; $i < $numzeros; $i++) { + $dispzeros = ($dispzeros).", ".($zeros[$i]); + $dispmults = ($dispmults).", ".($mltpy[$i]); +} + +BEGIN_PGML +>>[@ image(insertGraph($graph), width=>$gsize, height=>$gsize, tex_size=>500 ) @]*<< + +Find the following information pertaining to the polynomial, [:p(x):], graphed above. + +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect", +); +Section::Begin("Step 1: Find zeros of the polynomial."); + +BEGIN_PGML + +The real zeros of [:p(x):] are [:x = :] [________________________]{$zerosans} (separated by commas). + +END_PGML + +#Hint for step 1: +$showHint = 2; + +BEGIN_PGML_HINT +Real zeros of a polynomial are the [:x:]-coordinates of the [:x:]-intercepts. +END_PGML_HINT + +BEGIN_PGML_SOLUTION +The polynomial intersect the [:x:]-axis at [:[$dispzeros]:]. +END_PGML_SOLUTION + +Section::End(); + +######################## Section 2: + +Section::Begin("Step 2: Find the multiplicity of each zero."); + +BEGIN_PGML + +[$mult_pgml]** + +END_PGML + +#Hint for step 2: +$showHint = 2; + +BEGIN_PGML_HINT +How do the zeros of [:y = x:] or [:y = -x:] look like? How does the zero of [:y = x^2:] looks like? +END_PGML_HINT + +BEGIN_PGML_SOLUTION +If the graph crosses the [:x:]-axis, the multiplicity is odd. If the graph stays on the same side, the multiplicity is even. +[$mult_pgml_sol]** +END_PGML_SOLUTION + +Section::End(); + +######################## Section 3: + +Section::Begin("Step 3: Find the degree and sign of leading coefficient."); + +BEGIN_PGML + +1. The degree of [:p(x):] is [__]{$degree_popup}. + +1. The leading coefficient of [:p(x):] is [__]{$leading_popup}. + +END_PGML + +#Hint for step 3: +$showHint = 2; + +BEGIN_PGML_HINT +Look at the end behavior of the polynomial, and count its zeros. +END_PGML_HINT + +BEGIN_PGML_SOLUTION +If both end behaviors are the same, the polynomial has an even degree. If the +ends of the graph go in opposite directions, the polynomial has an odd degree. +If the right end points up, the leading coefficient is positive. If the right +end points down, the leading coefficient is negative. + +This polynomial has an [@ $degree_popup->correct_ans() @]* degree and +[@ $leading_popup->correct_ans() @]* leading coefficient. +END_PGML_SOLUTION + +Section::End(); +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/polynomials/identify_zeros.pg b/Contrib/SVSU/College_Algebra/polynomials/identify_zeros.pg new file mode 100644 index 0000000000..de613644fe --- /dev/null +++ b/Contrib/SVSU/College_Algebra/polynomials/identify_zeros.pg @@ -0,0 +1,152 @@ +#DESCRIPTION +## Algebra: Graphing polynomial functions +##ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Polynomial equations and functions) +## DBsection(Zeros and multiplicities) +## Date(01/10/2010) +## Institution(University of Minnesota) +## Author(Justin Sukiennik) +## MLT(polynomial_zeros_from_graph) +## Level(2) +## MO(1) +## TitleText1('Algebra for College Students') +## AuthorText1('Kaufmann, Schwitters') +## EditionText1('8') +## Section1('9.4') +## Problem1('') +## KEYWORDS('algebra', 'graph', 'functions', 'polynomials', 'quartic') + +# modified by Jan Hlavacek (jhlavace@svsu.edu): +# +# * Rewrite in PGML, add solutions and hints +# * Choose $b randomly so it is not always 1 +# * Change the notation from a,b,c to x_1, x_2, x_3 +# * Add a leading coefficient +# * Randomly flip the polynomial horizontally and vertically for +# more variability +# * Scale the polynomial to better fit the window + +##################################################################### + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", + "PGcourse.pl", + "PGgraphmacros.pl", + "PGML.pl", + "unorderedAnswer.pl", +); + +##################################################################### + +TEXT(beginproblem()); + +install_problem_grader(~~&std_problem_grader); + +$showPartialCorrectAnswers = 0; + +##################################################################### + +$w = 400; # graph size +$tw = 500; # graph size in TeX + +$a = random(-2,-1,1); +$c = random(2,3,1); +do {$b = random(-3,4,1);} until ($b != $c and $b != $a and $b != $a + 1 and $b != $a - 1); + +# Find scaling factor, so the polynomial will fit nicely into the window +sub poly { + my $x = shift(); + return ($x - $a)**2 * ($x - $b) * ($x - $c); +}; + +$m = min($a,$b); +$M = max($c,$b); + +$ymax = 0; +$steps = 100; +$stepsize = ($M - $m)/$steps; +for ($i = 0; $i < $steps; $i++) { + $tmp = abs(poly($m + $i*$stepsize)); + if ($tmp > $ymax) { + $ymax = $tmp; + } +} + +if ($ymax > 8) { + $target = random(5,8,1); + $scale = $target/$ymax; +} else { + $scale = 1; +} + +# flip upside down +$scale = list_random(-1,1)*$scale; + +# flip left-right +$flip = list_random(-1,1); + +$a = $flip*$a; +$b = $flip*$b; +$c = $flip*$c; + +Context("Numeric"); + +$ans = Real("$a"); +$answerb = Real("$b"); +$answerc = Real("$c"); + +$f1 = Formula("$scale*(x-$a)^2(x-$b)(x-$c)"); + +$gsize = 300; + +$graph = init_graph(-8,-8,8,8,'axes'=>[0,0],'ticks'=>[16,16],'grid'=>[16,16],'size'=>[500,500]); + +$p = FEQ("$f1 for x in <-8,8> using color:blue weight:2"); + +plot_functions($graph,$p); +($graph->fn)[0]->steps(300); + +##################################################################### + +BEGIN_PGML +The graph below is a polynomial function in the form + +>>[:f(x) = a*(x-x_1)^2(x-x_2)(x-x_3).:]<< + +Find suitable unique real numbers [:x_1:], [:x_2:], and [:x_3:] that describe the graph. + +>>[@ image(insertGraph($graph), width=>$gsize, height=>$gsize, tex_size=>500 ) @]*<< + +------ + +Answer: [:x_1 =:] [__________]{$a}, [:x_2 =:] [____________], and [:x_3 =:] [____________] + +------ +**Note:** __You can click on the graph to enlarge the image.__ +END_PGML + +UNORDERED_ANS( $answerb->cmp(), $answerc->cmp() ); + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Look at the multiplicity of the zeros. +END_PGML_HINT + +# Solution: +BEGIN_PGML_SOLUTION +In order to answer this question, one has to look at the multiplicities of the three zeros. The zero [:x_1:] +has multiplicity 2, while [:x_2:] and [:x_3:] each have multiplicity 1. From the graph you can see that the zero with +multiplicity 2 is [:[$a]:], while [:[$b]:] and [:[$c]:] each have multiplicity 1. + +Therefore [:x_1 = [$a]:] and [:x_2 = [$b]:] and [:x_3 = [$c]:] or [:x_2 = [$c]:] and [:x_3 = [$b]:]. +END_PGML_SOLUTION + +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/Contrib/SVSU/College_Algebra/square_complete/complete1.pg b/Contrib/SVSU/College_Algebra/square_complete/complete1.pg new file mode 100644 index 0000000000..90613aab85 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/square_complete/complete1.pg @@ -0,0 +1,152 @@ +## DESCRIPTION +## Algebra: Complete the square (simple) +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Completing the square) +## Level(1) +## KEYWORDS('algebra', 'completing the square') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"contextFraction.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 1; + +Context("Numeric"); + +$b1 = random(2,20,2); + +$a1 = Compute("$b1/2"); +$d1 = Compute("($a1)^2"); + +Context("LimitedFraction")->flags->set(showMixedNumbers => 0); + +$b2 = random(3,21,2); +$b22 = $b2**2; +$a2 = Compute("$b2/2"); +$d2 = Compute("$b22/4"); + +$b3top = random(2,15,1); +do { $b3bot = random(2,9,1); } until ( gcd($b3top, $b3bot) == 1 ); + +$a3bot = 2*$b3bot; +$d3top = $b3top**2; +$d3bot = $a3bot**2; + +$b3 = Compute("$b3top/$b3bot"); +$a3 = Compute("$b3top/$a3bot"); +$d3 = Compute("$d3top/$d3bot"); + +########################### +# Main text + +BEGIN_PGML +Fill in the blanks so that the following complete squares will be correct. + +* [` x^2 + [$b1]x + `][_____]{$d1} [` = (x + `][____]{$a1}[`)^2`] + +* [` x^2 + [$b2]x + `][_____]{$d2} [` = (x + `][____]{$a2}[`)^2`] + +* [` x^2 + [$b3]x + `][_____]{$d3} [` = (x + `][____]{$a3}[`)^2`] + +END_PGML + +#hint: +$showHint = 4; + +BEGIN_PGML_HINT +When matching + +[`` x^2 + bx + d ``] + +with + +[`` x^2 + 2ax + a^2 = (x + a)^2 ``] + +you can see that [` b = 2a `] and [` d = a^2 `]. + +END_PGML_HINT + +############################ +# Solution + +BEGIN_PGML_SOLUTION + +### Part 1 ### + +In the equation + +* [` x^2 + \color{red}{[$b1]} x + \color{orange}{d} = (x + a)^2`] + +we need to find [`a`] and [`d`]. From the perfect square equation, we know that + +* [` x^2 + \color{red}{2a} x + \color{orange}{a^2} = (x + a)^2`] + +By comparing the two equations, we see that [` 2a = [$b1] `] and [` d = a^2 `] + +First we need to find [`a`]: + +[` a = \frac{[$b1]}{2} = [$a1] `] + +Then [` d = a^2 = \left([$a1]\right)^2 = [$d1] `] + +### Part 2 ### + +In the equation + +* [` x^2 + \color{red}{[$b2]} x + \color{orange}{d} = (x + a)^2`] + +we need to find [`a`] and [`d`]. From the perfect square equation, we know that + +* [` x^2 + \color{red}{2a} x + \color{orange}{a^2} = (x + a)^2`] + +By comparing the two equations, we see that [` 2a = [$b2] `] and [` d = a^2 `] + +First we need to find [`a`]: + +[` a = \frac{[$b2]}{2} = [$a2] `] + +Then [` d = a^2 = \left([$a2]\right)^2 = [$d2] `] + +### Part 3 ### + +In the equation + +* [` x^2 + \color{red}{[$b3]} x + \color{orange}{d} = (x + a)^2`] + +we need to find [`a`] and [`d`]. From the perfect square equation, we know that + +* [` x^2 + \color{red}{2a} x + \color{orange}{a^2} = (x + a)^2`] + +By comparing the two equations, we see that [` 2a = [$b3] `] and [` d = a^2 `] + +First we need to find [`a`]: + +[` a = \frac{1}{2}[$b3] = [$a3] `] + +Then [` d = a^2 = \left([$a3]\right)^2 = [$d3] `] +END_PGML_SOLUTION + +COMMENT('Uses PGML.'); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/square_complete/complete2.pg b/Contrib/SVSU/College_Algebra/square_complete/complete2.pg new file mode 100644 index 0000000000..ed6503f7ed --- /dev/null +++ b/Contrib/SVSU/College_Algebra/square_complete/complete2.pg @@ -0,0 +1,211 @@ +## DESCRIPTION +## Algebra: Complete the square (quadratic equation) +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Completing the square) +## Level(2) +## KEYWORDS('algebra', 'rules of exponents') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"scaffold.pl", +"parserMultiAnswer.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 1; + +Context("Numeric"); + +$sign = list_random(-1,1); +$b1abs = random(4,20,2); +$b1 = $sign*$b1abs; + +$a1 = Compute("$b1/2"); +$a1abs = Compute("$b1abs/2"); +$a1neg = Compute("-($a1)"); +$d1 = Compute("($a1)^2"); + +$r1 = random(2,7,1); + +$r1s = ($r1)**2; + +$c1 = $d1 - $r1s; + +$lhs = Formula("x^2 + ($b1)*x + ($c1)")->reduce;; + +$lhsstart = Formula("x^2 + ($b1)*x")->reduce; + +$squareof = Formula("x + ($a1)")->reduce; + +if ($sign == -1) { + $perfsquare = "x^2 - 2ax + a^2 = (x - a)^2"; +} else { + $perfsquare = "x^2 + 2ax + a^2 = (x + a)^2"; +} + +$sol1 = Compute("-($a1)-$r1"); +$sol2 = Compute("-($a1)+$r1"); + +$mp = MultiAnswer($sol1, $sol2)->with( + singleResult => 0, + allowBlankAnswers => 1, + checker => sub { + my $correct= shift; my $student = shift; + my ($ca,$cb) = @$correct; + my ($sa,$sb) = @$student; + return (1,1) if ($ca == $sa and $cb == $sb) or + ($ca == $sb and $cb == $sa); + return (1,0) if $ca == $sa or $cb == $sa; + return (0,1) if $ca == $sb or $cb == $sb; + return (0,0); + }, + ); + +########################### +# Main text + +BEGIN_PGML + +Fill in the blanks to solve the equation + +[` [$lhs] = 0 `] + +by completing the square: + +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect", +); +Section::Begin("Step 1: Complete the square."); + +BEGIN_PGML +Add a number to both sides so the left side will become a perfect square: + +[` [$lhsstart] + `][_____]{$d1} [` = `][____]{$r1s} +END_PGML + +#Hint for step 1: +$showHint = 2; + +BEGIN_PGML_HINT +You want to make the left side look like [` x^2 + 2ax + a^2 `] or [` x^2 - 2ax + a^2 `]. +Comparing that to the original left hand side: [` [$lhs] `], what should [`a`] be? +END_PGML_HINT + +BEGIN_PGML_SOLUTION +Comparing the left hand side of the equation: [`[$lhs]`] with the perfect square +equation [` [$perfsquare] `], we can see that [` 2a = [$b1abs] `]. Then + +[`` a = \frac{[$b1abs]}{2} = [$a1abs] ``] + +and + +[`` d = a^2 = [$a1abs]^2 = [$d1] ``] + +To complete the square, we need to add [` [$d1] - ([$c1]) = [$r1s] `] to both sides of the equations. +After completing the square, the equation will look like + +[`` [$lhsstart] + [$d1] = [$r1s] ``] +END_PGML_SOLUTION + +Section::End(); + +######################## Section 2: + +Section::Begin("Step 2: Rewrite the left side as perfect square."); + +BEGIN_PGML +Next fill in the blank so that the left side of the equation is +written as an actual square: + +[` ( `][______]{$squareof}[` )^2 = [$r1s] `] + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +You already wrote the left side as [` x^2 + 2ax + a^2 `] or +[` x^2 - 2ax + a^2 `]. In this atep you have to write it as +[` (x + a)^2 `] or [` (x - a)^2 `]. +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +We already figured out in Step 1 that [` a = [$a1abs] `], so the perfect square on the left side is [` ([$squareof])^2 `]. The whole equations is now + + [` ([$squareof])^2 = [$r1s] `] + +END_PGML_SOLUTION + +Section::End(); + +######################## Section 3: + +Section::Begin("Step 3: Use the square root property"); + +BEGIN_PGML + +Now use the square root property and solve for [`x`]: + +[` x = `][________]{-$a1}[` \pm `][________]{$r1} + +The two solutions are [________]{$mp} and [________]{$mp}. + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The square root property says that the equation + + [` x^2 = d `] + +is equivalent to the pair of eqautions + + [` x = \pm\sqrt{d} `] +END_PGML_HINT + +BEGIN_PGML_SOLUTION +According to the square root property, the equation + + [` ([$squareof])^2 = [$r1s] `] + +is equivalent to + + [` [$squareof] = \pm\sqrt{[$r1s]} = \pm [$r1] `] + +Solving that for [`x`] will give us + + [` x = [$a1neg] \pm [$r1] `] + +The two solutions will be [$sol1] and [$sol2]. +END_PGML_SOLUTION + +Section::End(); +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/square_complete/complete3.pg b/Contrib/SVSU/College_Algebra/square_complete/complete3.pg new file mode 100644 index 0000000000..95df31722e --- /dev/null +++ b/Contrib/SVSU/College_Algebra/square_complete/complete3.pg @@ -0,0 +1,203 @@ +## DESCRIPTION +## Algebra: Complete the square (quadratic equation with leading coefficient) +# written by Jan Hlavacek (jhlavace@svsu.edu) +## ENDDESCRIPTION + + +## DBsubject(Algebra) +## DBchapter(Quadratic equations and functions) +## DBsection(Completing the square) +## Level(2) +## KEYWORDS('algebra', 'quadratic equation', 'completing the square') + + +########################### +# Initialization + +DOCUMENT(); + +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGcourse.pl", +"PGML.pl", +"contextFraction.pl", +"scaffold.pl", +"parserMultiAnswer.pl", +); + +TEXT(beginproblem()); + + +########################### +# Setup + +$showPartialCorrectAnswers = 1; + +Context("LimitedFraction")->flags->set(showMixedNumbers => 0); + +$b = random(2,15,1); +do { $a = random(2,9,1); } until ( gcd($a, $b) == 1 ); + +$c = non_zero_random(-20,$b**2/(4*$a)-1,1); + +$r1 = 4*$a*$c; + +$rtop = $b**2 - $r1; + +$a3bot = 2*$a; +$d3top = $b**2; +$d3bot = $a3bot**2; + +$b3 = Compute("$b/$a"); +$c3 = Compute("$c/$a"); +$a3 = Compute("$b/$a3bot"); +$d3 = Compute("$d3top/$d3bot"); +$r3 = Compute("$rtop/$d3bot"); + +Context("Numeric"); + +$squareof = Formula("x - ($a3)")->reduce; + +$sol1 = Real("$a3-sqrt($r3)"); +$sol2 = Real("$a3+sqrt($r3)"); + +$mp = MultiAnswer($sol1, $sol2)->with( + singleResult => 0, + allowBlankAnswers => 1, + checker => sub { + my $correct= shift; my $student = shift; + my ($ca,$cb) = @$correct; + my ($sa,$sb) = @$student; + return (1,1) if ($ca == $sa and $cb == $sb) or + ($ca == $sb and $cb == $sa); + return (1,0) if $ca == $sa or $cb == $sa; + return (0,1) if $ca == $sb or $cb == $sb; + return (0,0); + }, + ); + +########################### +# Main text + +BEGIN_PGML + +Fill in the blanks to solve the equation + +[` [$a]x^2 - [$b]x + [$c] = 0 `] + +by completing the square: + +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "correct_or_first_incorrect", +); +Section::Begin("Step 1: Complete the square."); + +BEGIN_PGML +Divide by [`a`] and complete the square (fill in the blanks as integers or fractions in the simplest form): + +[` x^2 - `][______]{$b3}[` x + `][_____]{$d3} [` = `][____]{$r3} +END_PGML + +#Hint for step 1: +$showHint = 2; + +BEGIN_PGML_HINT +First you want to divide both side of the equation by [$a]. +END_PGML_HINT + +BEGIN_PGML_SOLUTION +First divide both sides of the equations by [$a] to get + +[` x^2 - [$b3]x + [$c3] = 0 `] + +Subtracting [` [$c3] `] from both sides and adding [` [$d3] `] to both sides gives you + +[` x^2 - [$b3]x + [$d3] = [$r3] `] + +The left side is a complete square. +END_PGML_SOLUTION + +Section::End(); + +######################## Section 2: + +Section::Begin("Step 2: Rewrite the left side as perfect square."); + +BEGIN_PGML +Next fill in the blank so that the left side of the equation is +written as an actual square: + +[` \big( `][______]{$squareof}[` \big)^2 = [$r3] `] + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +You already wrote the left side as [` x^2 - 2ax + a^2 `]. In this step you +have to write it as [` (x - a)^2 `]. +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +We already figured out in Step 1 that [` a = [$a3] `], so the perfect square on the left side is + +[`` \left(x - [$a3]\right)^2 ``]. + +The whole equations is now + +[`` \left(x - [$a3]\right)^2 = [$r3] ``]. +END_PGML_SOLUTION + +Section::End(); + +######################## Section 3: + +Section::Begin("Step 3: Use the square root property"); + +BEGIN_PGML + +Now use the square root property and solve for [`x`]: + +The two solutions are [________________]{$mp} and [________________]{$mp}. (You can use sqrt() for square roots, if necessary). + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +The square root property says that the equation + + [` x^2 = d `] + +is equivalent to the pair of equations + + [` x = \pm\sqrt{d} `] +END_PGML_HINT + +BEGIN_PGML_SOLUTION +According to the square root property, the equation + + [` (x - [$a3])^2 = [$r3] `] + +is equivalent to + + [` x - [$a3] = \pm\sqrt{[$r3]} `] + +Solving that for [`x`] will give us + + [` x = [$a3] \pm \sqrt{[$r3]} `] + +The two solutions will be [$sol1] and [$sol2]. +END_PGML_SOLUTION + +Section::End(); +Scaffold::End(); + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/College_Algebra/systems/nonlinear_1.pg b/Contrib/SVSU/College_Algebra/systems/nonlinear_1.pg new file mode 100644 index 0000000000..b463158ac3 --- /dev/null +++ b/Contrib/SVSU/College_Algebra/systems/nonlinear_1.pg @@ -0,0 +1,195 @@ +# DESCRIPTION +# nonlinear system with two eaquations, integer solutions +# written by Jan Hlavacek (jhlavace@svsu.edu) +# ENDDESCRIPTION + +## DBsubject(Algebra) +## DBchapter(Systems of equations and inequalities) +## DBsection(Nonlinear systems) +## Institution(SVSU) +## Author(Jan Hlavacek) +## Level(2) +## TitleText1('Algebra and Trigonometry') +## AuthorText1('Swokowski, Cole') +## EditionText1('13') +## Section1('.') +## Problem1('') +## KEYWORDS('algebra, systems of equations, nonlinear') + +DOCUMENT(); +loadMacros( +"PGstandard.pl", +"MathObjects.pl", +"PGML.pl", +"PGcourse.pl", +"AnswerFormatHelp.pl", +"answerHints.pl", +"contextFraction.pl", +); +Context("Numeric")->variables->are(x=>"Real",y=>"Real"); + +# Pick a set of integer solutions: +# Each array contains a square of a radius of a circle and two lattice points +# on that circle. +@circlepoints = ( + [25,4,3,5,0], + [65,7,4,8,1], + [85,7,6,9,2], + [100,8,6,10,0], + [125,10,5,11,2], + [130,9,7,11,3], + [145,9,8,12,1], + [169,12,5,13,0], + [170,11,7,13,1], + [185,11,8,13,4], + [205,13,6,14,3], + [221,11,10,14,5], + [225,12,9,15,0], + [250,13,9,15,5], + ); + +$index = random(0,13,1); + +$c = $circlepoints[$index][0]; +$x1 = $circlepoints[$index][1]; +$y1 = $circlepoints[$index][2]; +$x2 = $circlepoints[$index][3]; +$y2 = $circlepoints[$index][4]; + +$swap1 = random(0,1,1); +$swap2 = random(0,1,1); + +if ($swap1) { + ($x1, $y1) = ($y1, $x1); +} +if ($swap2) { + ($x2, $y2) = ($y2, $x2); +} + +$x1 = list_random(-1,1)*$x1; +$x2 = list_random(-1,1)*$x2; +$y1 = list_random(-1,1)*$y1; +$y2 = list_random(-1,1)*$y2; + +$difx = $x2 - $x1; +$dify = $y2 - $y1; + +$det = $x1*$y2 - $y1*$x2; + +if ($difx > 0 and $dify < 0) { + $difx = -1*$difx; + $dify = -1*$dify; + $det = -1*$det; +} + +$gcd = gcd($difx, $dify, $det); +$difx = $difx/$gcd; +$dify = $dify/$gcd; +$det = $det/$gcd; + +$line_left = Compute("$dify*x - $difx*y")->reduce(); +$line_right = Compute("$det"); +$circ_right = Compute("$c"); + +$ans = Compute("($x1,$y1),($x2,$y2)"); + +#Solution: + +Context("Fraction-NoDecimals")->variables->are(x=>"Real",y=>"Real"); +if (abs($difx) == 1) { +# solve for y and substitute +$solvefor = "y"; +$solveother = "x"; +$solved = Compute("$dify/$difx*x - $det/$difx")->reduce(); +$subed = Compute("x^2 + ($solved)^2"); +$exped = Compute("(($dify)^2 + 1)*x^2 - 2*$dify*$det*x + $det^2")->reduce(); +$expedstd = Compute("(($dify)^2 + 1)*x^2 - 2*$dify*$det*x + $det^2 - $c")->reduce(); +$divby = Compute("($dify)^2 + 1"); +$divided = Compute("x^2 - 2*$dify*$det/$divby*x + ($det^2 - $c)/$divby")->reduce(); +$factored = Compute("(x - $x1)*(x - $x2)")->reduce(); +$other1 = $x1; +$other2 = $x2; +} elsif (abs($dify) == 1) { +# solve for x and substitute +$solvefor = "x"; +$solveother = "y"; +$solved = Compute("$difx/$dify*y + $det/$dify")->reduce(); +$subed = Compute("($solved)^2 + y^2"); +$exped = Compute("(($difx)^2 + 1)*y^2 + 2*$difx*$det*y + $det^2")->reduce(); +$expedstd = Compute("(($difx)^2 + 1)*y^2 + 2*$difx*$det*y + $det^2 - $c")->reduce(); +$divby = Compute("($difx)^2 + 1"); +$divided = Compute("y^2 + 2*$difx*$det/$divby*y + ($det^2 - $c)/$divby")->reduce(); +$factored = Compute("(y - $y1)*(y - $y2)")->reduce(); +$other1 = $y1; +$other2 = $y2; +} else { +# solve for y and substitute +$solvefor = "y"; +$solveother = "x"; +$solved = Compute("$dify/$difx*x - $det/$difx")->reduce(); +$subed = Compute("x^2 + ($solved)^2"); +$exped = Compute("(($dify)^2 + ($difx)^2)/($difx)^2*x^2 - 2*$dify*$det/($difx)^2*x + ($det/$difx)^2")->reduce(); +$expedstd = Compute("(($dify)^2 + ($difx)^2)*x^2 - 2*$dify*$det*x + ($det)^2 - $c*($difx)^2")->reduce(); +$divby = Compute("($dify)^2 + ($difx)^2"); +$divided = Compute("x^2 - 2*$dify*$det/$divby*x + (($det)^2 - $c*($difx)^2)/$divby")->reduce(); +$factored = Compute("(x - $x1)*(x - $x2)")->reduce(); +$other1 = $x1; +$other2 = $x2; +} + +# Actual problem goes here: +TEXT(beginproblem()); +BEGIN_PGML +Find all solutions of the system of equations + +>>[``\left\{\begin{aligned} x^2 + y^2 &= [$circ_right]\\[$line_left] &= [$line_right]\end{aligned}\right.``]<< + +Write your answer as a list of points. +----- + +The solution: [___________________________]{$ans} [@ AnswerFormatHelp("points") @]* + +END_PGML + +#hint: +$showHint = 2; + +BEGIN_PGML_HINT +Solve the second equation for one of the variables and substitute to the first equation. +END_PGML_HINT + +# Solution: +BEGIN_PGML_SOLUTION +We will start by solving the second equation for [:[$solvefor]:]. That will give us + +>>[:: [$solvefor] = [$solved] ::]<< + +Substituting this for [:[$solvefor]:] in the first equation gives us + +>>[:: [$subed] = [$c] ::]<< + +which, after distributing and combining like terms becomes + +>>[:: [$exped] = [$c] ::]<< + +and further + +>>[:: [$expedstd] = 0 ::]<< + +Dividing everything by [:[$divby]:] gives us + +>>[:: [$divided] = 0 ::]<< + +which factors as + +>>[:: [$factored] = 0 ::]<< + +That means [:[$solveother] = [$other1]:] or [:[$solveother] = [$other2]:]. Plugging each of these into + +>>[:: [$solvefor] = [$solved] ::]<< + +gives us the two solutions [:([$x1],[$y1]):] and [:([$x2],[$y2]):]. + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/SVSU/README.md b/Contrib/SVSU/README.md new file mode 100644 index 0000000000..c1f3500ff6 --- /dev/null +++ b/Contrib/SVSU/README.md @@ -0,0 +1,8 @@ +Problems created or significantly modified at the Saginaw Valley State University + +Contact person at SVSU: Jan Hlavacek, `jhlavace@svsu.edu`, github handle `lahvak`. + +Problems are organized mostly by course name. The following directories are present: + +* College_Algebra + diff --git a/OpenProblemLibrary/Mizzou/Algebra/graph_polynomials/find_all_info_01.pg b/OpenProblemLibrary/Mizzou/Algebra/graph_polynomials/find_all_info_01.pg index 90190c05c7..49e8dd0e2f 100644 --- a/OpenProblemLibrary/Mizzou/Algebra/graph_polynomials/find_all_info_01.pg +++ b/OpenProblemLibrary/Mizzou/Algebra/graph_polynomials/find_all_info_01.pg @@ -9,6 +9,8 @@ ## DBsection(Graphs of polynomials) ## Institution(University of Missouri-Columbia) ## Author(Rick Lynch) +## MLT(polynomial_all_info) +## MLTleader(1) ## Level(3) ## KEYWORDS('functions', 'polynomials', 'graphs') diff --git a/OpenProblemLibrary/UMN/algebraKaufmannSchwitters/ks_9_4_prob07.pg b/OpenProblemLibrary/UMN/algebraKaufmannSchwitters/ks_9_4_prob07.pg index 548c59d326..8a7d55dd62 100644 --- a/OpenProblemLibrary/UMN/algebraKaufmannSchwitters/ks_9_4_prob07.pg +++ b/OpenProblemLibrary/UMN/algebraKaufmannSchwitters/ks_9_4_prob07.pg @@ -9,6 +9,8 @@ ## Date(01/10/2010) ## Institution(University of Minnesota) ## Author(Justin Sukiennik) +## MLT(polynomial_zeros_from_graph) +## MLTleader(1) ## Level(2) ## MO(1) ## TitleText1('Algebra for College Students')