diff --git a/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg b/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg index 55e2e6d886..1f64893b80 100644 --- a/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg +++ b/Contrib/SVSU/College_Algebra/absolute_values/absolute1.pg @@ -17,41 +17,35 @@ ## KEYWORDS('algebra,absolute value') DOCUMENT(); + loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"PGcourse.pl", -"AnswerFormatHelp.pl", -"contextLimitedRadical.pl", + 'PGstandard.pl', 'PGML.pl', + 'contextLimitedRadical.pl', 'PGcourse.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; + my $message = shift; + $message =~ s/Unexpected character '~~|'/You cannot use absolute value/; + return $message; }; +# 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)); + $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: @@ -59,7 +53,8 @@ Write each of the following numbers without using absolute value: 2. [`\left| [$dif2] \right| = `] [_________]{$ans2} -([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*) + +[@ helpLink('formula') @]* END_PGML # Solution: diff --git a/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg b/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg index a4010ccf1b..27338e96f6 100644 --- a/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg +++ b/Contrib/SVSU/College_Algebra/absolute_values/absolute2.pg @@ -17,51 +17,45 @@ ## KEYWORDS('algebra,absolute value') DOCUMENT(); -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"PGcourse.pl", -"AnswerFormatHelp.pl", -"answerHints.pl", -); + +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.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; + 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); +$a = random(1, 9); -$dir = random(0,1,1); -$ord = random(0,1,1); +$dir = random(0, 1); +$ord = random(0, 1); $fst = Compute("$a - x"); $snd = Compute("x - $a"); if ($dir) { -$ineq = "\le"; -$ans = Compute("$a - x"); + $ineq = "\le"; + $ans = Compute("$a - x"); } else { -$ineq = "\ge"; -$ans = Compute("x - $a"); + $ineq = "\ge"; + $ans = Compute("x - $a"); } if ($ord) { -$p1 = $fst; -$p2 = $snd; + $p1 = $fst; + $p2 = $snd; } else { -$p1 = $snd; -$p2 = $fst; + $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] `]: @@ -69,7 +63,8 @@ Write each of the following numbers without using absolute value, given that [` 2. [`\left| [$p2] \right| = `] [_________]{$ans} -([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*) + +[@ helpLink('formula') @]* END_PGML # Solution: diff --git a/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg b/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg index 2c1dbd7b63..fbef936a3c 100644 --- a/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg +++ b/Contrib/SVSU/College_Algebra/absolute_values/distance1.pg @@ -17,23 +17,17 @@ ## KEYWORDS('algebra,absolute value') DOCUMENT(); -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"PGcourse.pl", -"AnswerFormatHelp.pl", -"answerHints.pl", -); + +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); Context("Numeric"); # Define variables here: -$a = random(1,9,1); -$b = random($a+1,15,1); # $a < $b +$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 +$c = random(7, 18, 1); +$d = random(2, $c - 1, 1); # $c > $d $ans1 = Compute("$b - $a"); $ans2 = Compute("$c - $d"); @@ -43,8 +37,6 @@ $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_. @@ -69,7 +61,7 @@ This problem is about the _distance between numbers on the number line_. [_________]{$ans5} -([@ AnswerFormatHelp("formulas", "Help entering formulas") @]*) +[@ helpLink('formula') @]* END_PGML # Solution: diff --git a/Contrib/SVSU/College_Algebra/applied_problems/interest.pg b/Contrib/SVSU/College_Algebra/applied_problems/interest.pg index 8935d0013a..c936cece57 100644 --- a/Contrib/SVSU/College_Algebra/applied_problems/interest.pg +++ b/Contrib/SVSU/College_Algebra/applied_problems/interest.pg @@ -9,54 +9,48 @@ ## Level(5) ## KEYWORDS('algebra', 'application problems', 'mixing problems') - ########################### # Initialization DOCUMENT(); loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"unionTables.pl", -"PGML.pl", -"scaffold.pl", + 'PGstandard.pl', 'PGML.pl', 'randomPerson.pl', 'scaffold.pl', + 'PGcourse.pl' ); -TEXT(beginproblem()); -$showPartialCorrectAnswers=1; - ########################### # Setup -Context("Numeric")->variables->are(x=>"Real"); +Context("Numeric")->variables->are(x => "Real"); ## names and pronouns: -$sex = list_random("he","she"); +$person = randomPerson(); -if ($sex eq "he") { - $name = list_random("John", "Darquese", "Sven", "Deleon", "Khulai", "Timbo", "Gerain"); -} else { - $name = list_random("Tawni", "Monisha", "Angelique", "Samantha", "Grauni", "Khianna"); -} +# $sex = list_random("he","she"); -$p1 = random(4,16,1); -do { $p2 = random(4,16,1); } until (abs($p2 - $p1) > 1); +# if ($sex eq "he") { +# $name = list_random("John", "Darquese", "Sven", "Deleon", "Khulai", "Timbo", "Gerain"); +# } else { +# $name = list_random("Tawni", "Monisha", "Angelique", "Samantha", "Grauni", "Khianna"); +# } -$pm = min($p1,$p2); -$pM = max($p1,$p2); +$p1 = random(4, 16); +do { $p2 = random(4, 16); } until (abs($p2 - $p1) > 1); + +$pm = min($p1, $p2); +$pM = max($p1, $p2); $pdiff = $pM - $pm; -$k = random(3,20,1); +$k = random(3, 20, 1); -$total = 100*$k*$pdiff; +$total = 100 * $k * $pdiff; -$f = random($pm*$k + 1, $pM*$k - 1, 1); +$f = random($pm * $k + 1, $pM * $k - 1, 1); -$interest = $f*$pdiff; +$interest = $f * $pdiff; $x = Compute("($interest*100 - $p2*$total)/($p1 - $p2)"); @@ -73,14 +67,12 @@ $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]? << +[$person] wants to invest $[$total]. There are two different accounts in which +[$person->they] can invest: first one pays [$p1]% simple +interest, while the second one pays [$p2]% simple interest. How much should +[$person->they] invest into each account so that +the resulting annual interest will be exactly $[$interest]? - ->> ----{100px} << END_PGML Scaffold::Begin( @@ -90,40 +82,33 @@ Scaffold::Begin( 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]* +[# + [.Account .] + [.Interest rate .] + [.Amount invested .] + [.Interest .]{headerrow=>1}* + [.First .] + [.[_]{$answer1}{10} .] + [.[_]{$answer2}{10} .] + [.[_]{$answer3}{10} .]* + [.Second .] + [.[_]{$answer4}{10} .] + [.[_]{$answer5}{10} .] + [.[_]{$answer6}{10} .]* + [.Total (given) .] + [. .] + [.[_]{$answer7}{10} .] + [.[_]{$answer8}{10} .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3} + -END_PGML -############################ -# Answer evaluation +[$table1]* -ANS( $answer1->cmp() ); -ANS( $answer2->cmp() ); -ANS( $answer3->cmp() ); -ANS( $answer4->cmp() ); -ANS( $answer5->cmp() ); -ANS( $answer6->cmp() ); -ANS( $answer7->cmp() ); -ANS( $answer8->cmp() ); +END_PGML BEGIN_PGML_SOLUTION The first column of the table is easy to fill in, just put down the rate of @@ -137,13 +122,20 @@ rate times quantity). The table will look like this: +[# + [.Account .] [.Interest rate.] [.Amount invested.] [.Interest.]{headerrow=>1}* + [.First .] [.[$answer1] .] [.[$answer2] .] [.[$answer3] .]* + [.Second .] [.[$answer4] .] [.[$answer5] .] [.[$answer6] .]* + [.Total (given) .] [. .] [.[$answer7] .] [.[$answer8] .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3} + + [$table2]* END_PGML_SOLUTION Section::End(); -########################################### Section::Begin("Part 2: Solve the equation"); BEGIN_PGML diff --git a/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg b/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg index cb67f1e7ae..e4e45f328d 100644 --- a/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg +++ b/Contrib/SVSU/College_Algebra/applied_problems/solutions.pg @@ -9,54 +9,41 @@ ## 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; +loadMacros('PGstandard.pl', 'PGML.pl', 'scaffold.pl', 'PGcourse.pl'); -########################### -# Setup - -Context("Numeric")->variables->are(x=>"Real"); +Context("Numeric")->variables->are(x => "Real"); ## chemicals -$chem = list_random("acid", "glucose", "hydrogen peroxide", "active ingredient"); +$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); +$x = random(7, 25, 1); -$k = random(3,7,1); +$k = random(3, 7, 1); -$s = random(2,5); +$s = random(2, 5); -$p2 = random(1,16,1); +$p2 = random(1, 16, 1); -$d = $k*$s; -$amount = $k*$x; +$d = $k * $s; +$amount = $k * $x; $p1 = $p2 + $d; $p = $s + $p2; -$amountchem = $p*$amount/100; +$amountchem = $p * $amount / 100; $answer2 = Compute("x"); $answer3 = Compute("$p1/100*x"); @@ -68,14 +55,10 @@ $answer8 = Compute("$amountchem"); # Main text BEGIN_PGML ->> ----{100px} << - ->> A chemist needs [$amount] [$unit] of [$p]% [$chem] solution by volume. She +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} << +amount and concentration she needs? END_PGML Scaffold::Begin( @@ -85,39 +68,27 @@ Scaffold::Begin( 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]* +[# + [.Concentration .] + [.Amount needed .] + [.Amount of pure [$chem] .]{headerrow=>1}* + [.[$p1]% .] + [.[_]{$answer2}{10} .] + [.[_]{$answer3}{10} .]* + [.[$p2]% .] + [.[_]{$answer5}{10} .] + [.[_]{$answer6}{10} .]* + [.[$p]% .] + [.[$amount] .] + [.[_]{$answer8}{10} .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|', padding=> 0.3} >> (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]. @@ -126,7 +97,22 @@ To get the last column, simply multiply the first and second column (amount of p The table will look like this: -[$table2]* +[# + [.Concentration .] + [.Amount needed .] + [.Amount of pure [$chem] .]{headerrow=>1}* + [.[$p1]% .] + [.[$answer2] .] + [.[$answer3] .]* + [.[$p2]% .] + [.[$answer5] .] + [.[$answer6] .]* + [.[$p]% .] + [.[$amount] .] + [.[$answer8] .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|', padding=> 0.3} + + >> (All amounts are in [$unit]) << END_PGML_SOLUTION @@ -141,7 +127,7 @@ 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}. +the amount of [$p2]% solution is [__________]{$amount-$x} END_PGML diff --git a/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg b/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg index ab5be5ea2e..134ffa8183 100644 --- a/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg +++ b/Contrib/SVSU/College_Algebra/applied_problems/tickets.pg @@ -9,37 +9,23 @@ ## 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 +loadMacros('PGstandard.pl', 'PGML.pl', 'scaffold.pl', 'PGcourse.pl'); -Context("Numeric")->variables->are(x=>"Real"); +Context("Numeric")->variables->are(x => "Real"); -$pricelow = random(4,12,1); -$pricehigh = $pricelow + random(2,10,1); +$pricelow = random(4, 12); +$pricehigh = $pricelow + random(2, 10); -$numberlow = random(30,200,1); -do { $numberhigh = random(30,200,1); } until ($numberhigh != $numberlow); +$numberlow = random(30, 200); +do { $numberhigh = random(30, 200); } until ($numberhigh != $numberlow); $totalnum = $numberhigh + $numberlow; -$totalrev = $pricelow*$numberlow + $pricehigh*$numberhigh; +$totalrev = $pricelow * $numberlow + $pricehigh * $numberhigh; $answer1 = Compute("$pricehigh"); $answer2 = Compute("$totalnum - x"); @@ -52,20 +38,17 @@ $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 +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]. << +for $[$pricelow]. ->> How may child tickets were sold? << +How may child tickets were sold? ->> ----{100px} << END_PGML Scaffold::Begin( @@ -74,41 +57,30 @@ Scaffold::Begin( ); 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]* +[# + [.Ticket type .] + [.Price .] + [.Number of tickets .] + [.Revenue .]{headerrow=>1}* + [.Adult .] + [.[_]{$answer1}{10} .] + [.[_]{$answer2}{10} .] + [.[_]{$answer3}{10} .]* + [.Child .] + [.[_]{$answer4}{10} .] + [.[_]{$answer5}{10} .] + [.[_]{$answer6}{10} .]* + [.Total (given) .] + [. .] + [.[_]{$answer7}{10} .] + [.[_]{$answer8}{10} .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3} 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. @@ -121,13 +93,29 @@ price times quantity). The table will look like this: -[$table2]* +[# + [.Ticket type .] + [.Price .] + [.Number of tickets .] + [.Revenue .]{headerrow=>1}* + [.Adult .] + [.[$answer1] .] + [.[$answer2] .] + [.[$answer3] .]* + [.Child .] + [.[$answer4] .] + [.[$answer5] .] + [.[$answer6] .]* + [.Total (given) .] + [. .] + [.[$answer7] .] + [.[$answer8] .]* +#]{horizontalrules => 1, texalignment => '|c|c|c|c|', padding=> 0.3} END_PGML_SOLUTION Section::End(); -########################################### Section::Begin("Part 2: Solve the equation"); BEGIN_PGML diff --git a/Contrib/SVSU/College_Algebra/circles/circle1.pg b/Contrib/SVSU/College_Algebra/circles/circle1.pg index 84a8e19ec8..d58763a6e3 100644 --- a/Contrib/SVSU/College_Algebra/circles/circle1.pg +++ b/Contrib/SVSU/College_Algebra/circles/circle1.pg @@ -17,41 +17,34 @@ ## KEYWORDS('algebra,equations,circle') DOCUMENT(); -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"PGcourse.pl", -"contextFraction.pl", -"AnswerFormatHelp.pl", -); -Context("Numeric")->variables->add(y=>"Real"); + +loadMacros('PGstandard.pl', 'PGML.pl', 'contextFraction.pl', 'PGcourse.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); +$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"); +$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(); +$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(); +$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 @@ -59,13 +52,12 @@ Find the center and radius of the circle with the equation ----- -The center: [________________]{$sol} [@ AnswerFormatHelp("points") @]* +The center: [________________]{$sol} [@ helpLink("points") @]* -The radius: [________________]{$r} [@ AnswerFormatHelp("numbers") @]* +The radius: [________________]{$r} [@ helpLink("numbers") @]* END_PGML -# Solution: BEGIN_PGML_SOLUTION To find the center and radius of the circle, we have to rewrite the given equation diff --git a/Contrib/SVSU/College_Algebra/circles/semicircle1.pg b/Contrib/SVSU/College_Algebra/circles/semicircle1.pg index 9a76ee4bb4..2e1d58dd9f 100644 --- a/Contrib/SVSU/College_Algebra/circles/semicircle1.pg +++ b/Contrib/SVSU/College_Algebra/circles/semicircle1.pg @@ -17,40 +17,33 @@ ## 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"); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserAssignment.pl', 'PGcourse.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"; +$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)]}); +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); +$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"); +$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") @]* +The equation: [________________]{$eq} [@ helpLink("equations") @]* END_PGML diff --git a/Contrib/SVSU/College_Algebra/complex/equation1.pg b/Contrib/SVSU/College_Algebra/complex/equation1.pg index 0b2fbf23d5..8566754cb1 100644 --- a/Contrib/SVSU/College_Algebra/complex/equation1.pg +++ b/Contrib/SVSU/College_Algebra/complex/equation1.pg @@ -3,108 +3,94 @@ # 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()); - +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -########################### -# Setup +Context('Numeric'); $showPartialCorrectAnswers = 0; Context("Complex"); Context()->variables->add(x => 'Complex'); -$re1 = random(1,8,1); -$im1 = list_random(-1,1)*random(1,8,1); +$re1 = random(1, 8, 1); +$im1 = list_random(-1, 1) * random(1, 8, 1); -$p1 = Complex($re1,$im1); -$q1 = Complex($re1,-$im1); +$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); +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); +$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); -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); -$p3 = Complex($re3,$im3); -$q3 = Complex($re3,-$im3); - -$h3 = $re3; +$h3 = $re3; $k3s = $im3**2; #Context("Numeric"); -$issol1 = list_random(0,1); -$issol2 = list_random(0,1); -$issol3 = list_random(0,1); +$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); + $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); + $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" + [ "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" + [ "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" + [ "choose", "is a solution", "is not a solution" ], + $issol3 ? "is a solution" : "is not a solution" ); $eq1plug = $eq1->substitute(x => "$p1"); @@ -131,9 +117,6 @@ 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. @@ -171,6 +154,4 @@ 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 index 8d154ce9bc..fb6cb61e84 100644 --- a/Contrib/SVSU/College_Algebra/complex/equation2.pg +++ b/Contrib/SVSU/College_Algebra/complex/equation2.pg @@ -3,43 +3,27 @@ # 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; +loadMacros('PGstandard.pl', 'PGML.pl', 'answerHints.pl', 'PGcourse.pl'); Context("Complex"); Context()->variables->add(x => 'Complex'); -$re1 = list_random(-1,1)*random(1,8,1); -$im1 = random(1,8,1); +$re1 = list_random(-1, 1) * random(1, 8, 1); +$im1 = random(1, 8, 1); -$p1 = Complex($re1,$im1); -$q1 = Complex($re1,-$im1); +$p1 = Complex($re1, $im1); +$q1 = Complex($re1, -$im1); $b1 = -($p1 + $q1); $c1 = $p1 * $q1; @@ -50,8 +34,12 @@ $solutions = List($p1, $q1); $squareof = Formula("x - ($re1)")->reduce; -########################### -# Main text +$cmp = $solutions->cmp( + removeParens => 1, + requireParenMatch => 0, +)->withPostFilter(AnswerHints( + "(NONE)" => "There are no real answers, but there may be complex ones!" +)); BEGIN_PGML @@ -59,19 +47,9 @@ Find all solutions of the equation [` [$eq1] = 0 `]. Enter the solutions, separated by comma. Enter NONE if there are no solutions. -[____________________] +[_]{$cmp}{30} 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; @@ -79,9 +57,6 @@ BEGIN_PGML_HINT Try completing the square. END_PGML_HINT -############################ -# Solution - BEGIN_PGML_SOLUTION First complete the square to get @@ -99,6 +74,4 @@ Adding [$re1] to both sides and simplifying the square root: 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 index 5efd34a60b..bddbb7fa2b 100644 --- a/Contrib/SVSU/College_Algebra/complex/equation3.pg +++ b/Contrib/SVSU/College_Algebra/complex/equation3.pg @@ -3,39 +3,23 @@ # 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; +loadMacros('PGstandard.pl', 'PGML.pl', 'answerHints.pl', 'PGcourse.pl'); Context("Complex"); Context()->variables->add(x => 'Complex'); -$a = list_random(-1,1)*random(2,6,1); +$a = list_random(-1, 1) * random(2, 6, 1); $a2 = $a**2; $a3 = $a**3; @@ -44,12 +28,18 @@ $s3 = Compute("-$a/2 - $a/2*sqrt(3)i")->reduce; $solutions = List($a, $s2, $s3); -$cubes = Formula("x^3 - $a^3")->reduce; +$cubes = Formula("x^3 - $a^3")->reduce; $cubes1 = Formula("x - $a")->reduce; $cubes2 = Formula("x^2 + $a*x + $a2")->reduce; -########################### -# Main text +$cmp = $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!", +)); BEGIN_PGML @@ -57,21 +47,10 @@ Find all solutions of the equation [` x^3 = [$a3] `]. Enter the solutions, separated by comma. Enter NONE if there are no solutions. -[____________________] +[_]{$cmp}{30} 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; @@ -80,9 +59,6 @@ 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: @@ -99,6 +75,4 @@ The first equation has a single solution [` x = [$a] `], while the second is a q 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 index 3ac2736079..22563a3817 100644 --- a/Contrib/SVSU/College_Algebra/coordinate_system/distance_axis.pg +++ b/Contrib/SVSU/College_Algebra/coordinate_system/distance_axis.pg @@ -17,53 +17,49 @@ ## KEYWORDS('algebra,equations,distance formuls') DOCUMENT(); + loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"contextLimitedPoint.pl", -"AnswerFormatHelp.pl", -"unorderedAnswer.pl", -"PGcourse.pl", + "PGstandard.pl", "PGML.pl", + "contextLimitedPoint.pl", "unorderedAnswer.pl", + "PGcourse.pl", ); -Context("Numeric")->variables->add(y=>"Real"); +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); +@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 +$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)"; +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)"; + $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])`]. @@ -71,12 +67,7 @@ The points are [_____________] and [_____________]. END_PGML -$showPartialCorrectAnswers = 1; - -UNORDERED_ANS( -$answer1->cmp(), -$answer2->cmp(), -); +UNORDERED_ANS($answer1->cmp(), $answer2->cmp(),); # Solution: BEGIN_PGML_SOLUTION diff --git a/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg index 3c23544650..87b4a6bbff 100644 --- a/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg +++ b/Contrib/SVSU/College_Algebra/difference_quotients/diff_quotient1.pg @@ -18,32 +18,30 @@ DOCUMENT(); loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGML.pl", -"PGcourse.pl", -"parserDifferenceQuotient.pl", -"AnswerFormatHelp.pl", + "PGstandard.pl", + "PGML.pl", + + "parserDifferenceQuotient.pl", "PGcourse.pl", ); -Context("Numeric")->variables->add(h=>"Real"); +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 ); +$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"); +$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(); +$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"); +$answer = DifferenceQuotient($diff, "h"); -# Actual problem goes here: -TEXT(beginproblem()); BEGIN_PGML Simplify the expression @@ -53,18 +51,18 @@ as much as possible. ----- -The answer: [__________________________________]{$answer} [@ AnswerFormatHelp("formulas") @]* +The answer: [_]{$answer}{30} [@ helpLink("formulas") @]* END_PGML # Solution: BEGIN_PGML_SOLUTION -[``\begin{align} +[``\begin{aligned} \frac{[$funxph] - ([$fun])}{h} &= \frac{[$funxphred] - ([$fun])}{h} \\ &= \frac{[$numred]}{h} \\ &= \frac{h([$diff])}{h} \\ &= [$diff] -\end{align}``] +\end{aligned}``] END_PGML_SOLUTION #hint: