From 1088038733f7e0c9398978f701fbac7face8763b Mon Sep 17 00:00:00 2001 From: "K. Andrew Parker" Date: Mon, 22 Jan 2024 13:32:02 -0500 Subject: [PATCH] changes from live server --- .../exponential-algebra.pg | 2 +- .../setLimits_-_Introduction/f-hidden-asy.pg | 2 +- .../setLimits_-_Introduction/f-hidden-asy.pge | 230 +++++++++++++ .../f-hidden-redux.pg | 2 +- .../f-hidden-redux.pge | 229 +++++++++++++ .../interactive-align-limits.pg | 2 +- .../intro-f-hidden.pg | 2 +- .../intro-f-hidden.pge | 232 +++++++++++++ .../setLimits_-_Introduction/intro-x-given.pg | 4 +- .../intro-x-given.pge | 188 +++++++++++ .../setLimits_-_Introduction/last-x-given.pg | 4 +- .../setLimits_-_Introduction/last-x-given.pge | 197 +++++++++++ .../limits-visually.pg | 2 +- .../setLimits_-_Introduction/more-x-given.pg | 4 +- .../setLimits_-_Introduction/more-x-given.pge | 187 +++++++++++ .../setLimits_-_One-Sided/intro-piecewise.pg | 2 +- .../algebraic-with-coefficients.pg | 24 +- .../unit-circle-cosine-vary-reference.pg | 144 ++++++++ .../unit-circle-sine-vary-reference.pg | 142 ++++++++ .../unit-circle-tangent-vary-reference.pg | 144 ++++++++ .../ggb-complex-argument.pg | 2 +- .../ggb-modulus-given.pg | 2 +- .../ggb-modulus.pg | 2 +- .../setComplex_Numbers_-_Operations | 1 + .../ggb-product-polar.pg | 2 +- .../ggb-product.pg | 2 +- .../ggb-quotient-polar.pg | 2 +- .../ggb-quotient.pg | 2 +- .../polar-form-product-and-convert.pg | 79 +++++ .../polar-form-quotient-and-convert.pg | 61 ++++ .../diff-quot-quad-2.pg | 207 ++++++++++++ .../comp-bases-lin-exp-intro.pg | 133 ++++++++ ...etExponential_Functions_-_Growth_and_Decay | 1 + .../setFunctionNotation/function-range.pg | 2 +- .../even-odd-neither-explicit-ggb.pg | 2 +- .../intro-even-vs-odd.pg | 2 +- .../setGraphingCalculator/max-min-roots-2.pg | 180 ++++++++++ .../setGraphingCalculator/max-min-roots.pg | 207 ++++++++++++ .../vertical-line-test.pg | 208 ++++++++++++ .../find-roots-of-cubic-with-rational.pg | 68 ++++ .../find-roots-of-cubic.pg | 88 +++++ .../graph-match-coeff.pg | 2 +- .../graph-match-factored.pg | 2 +- .../graph-match-mult.pg | 4 +- .../graph-match-polyn.pg | 2 +- .../function-intro.pg | 209 ++++++++++++ .../piecewise-function.pg | 145 ++++++++ .../compute-inverse-rational-dbl2.pg | 112 +++++++ .../ln-domains.pg | 2 +- .../shifting-logs.pg | 2 +- .../setLogarithmic_Functions_-_Properties | 1 + ...unctions-composition-domain-sqrt-linear.pg | 155 +++++++++ .../find-factors-of-cubic-with-rational.pg | 97 ++++++ .../find-factors-of-cubic.pg | 61 ++++ .../intro-long-division.pg | 20 +- .../long-division-monic-linear-rem.pg | 12 +- .../long-division-neg-nonmonic-linear-rem.pg | 12 +- .../long-division-neg-nonmonic-linear.pg | 12 +- .../long-division-nonmonic-linear-rem.pg | 12 +- .../long-division-nonmonic-linear.pg | 12 +- .../factor-cubic-complex-roots.pg | 78 +++++ .../graphs-repeated-factors-quad-denom.pg | 4 +- .../graphs-repeated-factors.pg | 14 +- .../linear-linear-xy.pg | 194 +++++++++++ .../linear-quad-xy.pg | 195 +++++++++++ .../quad-linear-rep-xy.pg | 197 +++++++++++ .../quad-linear-xy.pg | 196 +++++++++++ .../quad-quad-rep-xy.pg | 196 +++++++++++ .../quad-quad-xy.pg | 196 +++++++++++ .../pascals-triangle.pg | 190 +++++++++++ .../fundamental-functions-id.pg | 2 +- .../multiple-shifts-id.pg | 2 +- .../shift-reflect-id.pg | 2 +- .../half-angle.pg | 132 ++++++++ .../same-quad-all-solutions-cos.pg | 297 +++++++++++++++++ .../same-quad-all-solutions-sin.pg | 312 ++++++++++++++++++ .../same-quad-all-solutions-tan.pg | 297 +++++++++++++++++ .../ggb-amplitude-cosine.pg | 2 +- .../ggb-amplitude-sine.pg | 2 +- .../matching-amplitudes.pg | 2 +- .../short-answer-amplitudes.pg | 2 +- .../amp-per-cosine.pg | 2 +- .../amp-per-phase-cosine.pg | 2 +- .../amp-per-phase-sine.pg | 2 +- .../amp-per-sine.pg | 2 +- .../amp-phase-cosine.pg | 2 +- .../amp-phase-sine.pg | 2 +- .../per-phase-cosine.pg | 2 +- .../per-phase-sine.pg | 2 +- .../ggb-period-cosine.pg | 2 +- .../ggb-period-sine.pg | 2 +- .../matching-period.pg | 2 +- .../short-answer-period.pg | 2 +- .../ggb-phaseshift-cosine.pg | 2 +- .../ggb-phaseshift-sine.pg | 2 +- .../short-answer-phaseshift-cosine.pg | 2 +- .../short-answer-phaseshift-sine.pg | 2 +- .../ggb-unit-vector-components.pg | 2 +- .../ggb-vector-components.pg | 2 +- .../ggb-magnitude-direction.pg | 2 +- .../vector-magnitude-angle.pg | 44 +++ .../ggb-magnitude-angle.pg | 2 +- 102 files changed, 6348 insertions(+), 118 deletions(-) create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pge create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pge create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pge create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pge create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pge create mode 100644 Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pge create mode 100644 Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-cosine-vary-reference.pg create mode 100644 Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-sine-vary-reference.pg create mode 100644 Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-tangent-vary-reference.pg create mode 120000 Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Operations create mode 100644 Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-product-and-convert.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-quotient-and-convert.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setDifference_Quotient/diff-quot-quad-2.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Equations/comp-bases-lin-exp-intro.pg create mode 120000 Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Growth_and_Decay create mode 100644 Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots-2.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/vertical-line-test.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic-with-rational.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/function-intro.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/piecewise-function.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setInverse_Functions/compute-inverse-rational-dbl2.pg create mode 120000 Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Properties create mode 100644 Contrib/CUNY/CityTech/Precalculus/setOperationsonFunctions/functions-composition-domain-sqrt-linear.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic-with-rational.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setPolynomial_Theory/factor-cubic-complex-roots.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-linear-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-quad-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-rep-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-rep-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-xy.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setSequences_-_Binomial_Theorem/pascals-triangle.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Double_and_Half_Angle_Formulas/half-angle.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-cos.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-sin.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-tan.pg create mode 100644 Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/vector-magnitude-angle.pg diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Infinite/exponential-algebra.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Infinite/exponential-algebra.pg index 9b1b7e53db..b461e41c94 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Infinite/exponential-algebra.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Infinite/exponential-algebra.pg @@ -121,7 +121,7 @@ $grTable = LayoutTable( [$fig[4],[$fig[5],rowcss=>'padding-bottom:2px;']], ["Graph E", ["Graph F",rowcss=>'padding-top:2px;']] ], - align => 'c c', + align => 'cc', ); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pg index ee65a0d977..ec569f62a7 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pg @@ -125,7 +125,7 @@ $ansTable = LayoutTable( ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pge new file mode 100644 index 0000000000..ec569f62a7 --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-asy.pge @@ -0,0 +1,230 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') +## Inspired by: Library/AlfredUniv/anton8e/chapter2/2.4/prob2.pg + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$A = random(-1,1,2)*sqrt(list_random(2,3,5,6,7)); +$h = non_zero_random(-4,4,0.5)*atan(1); +$k = exp(random(0.5,3.5,0.25)); +# the point is not to "find" f... +$numer = Formula("$A(x-$h)^2+$k"); + +$a = non_zero_random(-12,12,1); +$denom = Formula("x - $a"); +$f = Formula("$numer/$denom"); +$yLimit = String("DNE")->with(typeMatch=>Real(pi)); +@x = (); + +# "n" determines the level of accuracy necessary for the estimate +$n = 5; + +# define a js function to evaluate f(x) "invisibly" +# function should NOT allow evaluation at "x = a" +HEADER_TEXT(< +EOF + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [['\(x\)', headerrow=>1], 'click to get:', '\(f(x)\)'], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], +], +allcellcss=>'padding: 1pt;', +align=>'c c c'); + +$ansTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[5]", "$y[5]"], + ["$x[1]", "$y[1]",' |',"$x[6]", "$y[6]"], + ["$x[2]", "$y[2]",'| ',"$x[7]", "$y[7]"], + ["$x[3]", "$y[3]",'| ',"$x[8]", "$y[8]"], + ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Analytic approach to taking limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + +>> #### Practice #### << + + +Evaluating [``\lim_{x \to [$a]} f(x)``]. + +[$xyTable]*** + +Based on the above, what do you estimate as the value for [``\lim_{x \to [$a]} f(x)``]? [___________] + +* use decimals for all responses. +* because our goal is to "get close," you should try [`x`]-values that are very close to [$a]. +* keep trying [`x`]-values until your final estimate is accurate to [$n] decimal places. + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# students must push +ANS($yLimit->cmp); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* Choose values of [`x`] that are getting closer and closer to [`[$a]`], say, from the left. + +* Observe what happens with the outputs [`f(x)`]. Can you estimate a left-limit? + +* Now do the same for the right side. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# + +BEGIN_PGML_SOLUTION + +* We have: + +[$ansTable]*** + +* As the inputs [`[$x[0]]`], [`[$x[1]]`], [`[$x[2]]`], [`[$x[3]]`] and [`[$x[4]]`] are approaching [`[$a]`] from the left, their corresponding outputs [`[$y[0]]`], [`[$y[1]]`], [`[$y[2]]`], [`[$y[3]]`] and [`[$y[4]]`] are [@ ($y[4]-$y[0] > 0)?"increasing":"decreasing" @]. + +* As the inputs [`[$x[5]]`], [`[$x[6]]`], [`[$x[7]]`], [`[$x[8]]`] and [`[$x[9]]`] are approaching [`[$a]`] from the right, their corresponding outputs [`[$y[5]]`], [`[$y[6]]`], [`[$y[7]]`], [`[$y[8]]`] and [`[$y[9]]`] are [@ ($y[9]-$y[5] > 0)?"increasing":"decreasing" @]. + +* [`\displaystyle\lim_{x \to [$a]} f(x)`] does not exist. + + + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pg index 1d0ce22a78..ed079cd965 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pg @@ -123,7 +123,7 @@ $ansTable = LayoutTable( ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pge new file mode 100644 index 0000000000..ed079cd965 --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/f-hidden-redux.pge @@ -0,0 +1,229 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') +## Inspired by: Library/AlfredUniv/anton8e/chapter2/2.4/prob2.pg + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$A = random(-1,1,2)*sqrt(list_random(2,3,5,6,7)); +$h = non_zero_random(-4,4,0.5)*atan(1); +$k = exp(random(0.5,3.5,0.25)); +# the point is not to "find" f... +$f = Formula("$A(x-$h)^2+$k"); + +$a = non_zero_random(-12,12,1); +$yLimit = $f->eval(x=>$a); +@x = (); + +# "n" determines the level of accuracy necessary for the estimate +$n = 5; + +# define a js function to evaluate f(x) "invisibly" +# function should NOT allow evaluation at "x = a" +HEADER_TEXT(< +EOF + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [['\(x\)', headerrow=>1], 'click to get:', '\(f(x)\)'], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], +], +allcellcss=>'padding: 1pt;', +align=>'c c c'); + +$ansTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[5]", "$y[5]"], + ["$x[1]", "$y[1]",' |',"$x[6]", "$y[6]"], + ["$x[2]", "$y[2]",'| ',"$x[7]", "$y[7]"], + ["$x[3]", "$y[3]",'| ',"$x[8]", "$y[8]"], + ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Analytic approach to taking limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + +>> #### Practice #### << + + +Evaluating [``\lim_{x \to [$a]} f(x)``]. + +[$xyTable]*** + +Based on the above, what do you estimate as the value for [``\lim_{x \to [$a]} f(x)``]? [___________] + +* use decimals for all responses. +* because our goal is to "get close," you should try [`x`]-values that are very close to [$a]. +* keep trying [`x`]-values until your final estimate is accurate to [$n] decimal places. +* if the limit does not exist, enter "DNE". + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# students must push +ANS(Real($yLimit)->cmp(tolerance=>5*10**(-$n-1))); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* Choose values of [`x`] that are getting closer and closer to [`[$a]`], say, from the left. + +* Observe what happens with the outputs [`f(x)`]. Can you estimate a left-limit? + +* Now do the same for the right side. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# + +BEGIN_PGML_SOLUTION + +* We have: + +[$ansTable]*** + +* As the inputs [`[$x[0]]`], [`[$x[1]]`], [`[$x[2]]`], [`[$x[3]]`] and [`[$x[4]]`] are approaching [`[$a]`] from the left, their corresponding outputs [`[$y[0]]`], [`[$y[1]]`], [`[$y[2]]`], [`[$y[3]]`] and [`[$y[4]]`] are approaching [`[$yLimit]`]. + +* As the inputs [`[$x[5]]`], [`[$x[6]]`], [`[$x[7]]`], [`[$x[8]]`] and [`[$x[9]]`] are approaching [`[$a]`] from the right, their corresponding outputs [`[$y[5]]`], [`[$y[6]]`], [`[$y[7]]`], [`[$y[8]]`] and [`[$y[9]]`] are approaching [`[$yLimit]`]. + +* We estimate [`\displaystyle\lim_{x \to [$a]} f(x)`] to be [`[$yLimit]`]. + + + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/interactive-align-limits.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/interactive-align-limits.pg index 5e23811f71..22fc90a828 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/interactive-align-limits.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/interactive-align-limits.pg @@ -285,7 +285,7 @@ $ggb_code = LayoutTable( ] ] ], - align => 'c c c', + align => 'cc', center => 1 ); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pg index 3855a1550d..1bfaeda7b2 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pg @@ -123,7 +123,7 @@ $ansTable = LayoutTable( ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pge new file mode 100644 index 0000000000..1bfaeda7b2 --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-f-hidden.pge @@ -0,0 +1,232 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$m = non_zero_random(-4,4,0.5)*atan(1); +$b = exp(random(0.5,3.5,0.25)); +# the point is not to "find" f... +$f = Formula("$m x + $b"); + +$a = non_zero_random(-12,12,1); +$yLimit = $f->eval(x=>$a); +@x = (); + +# "n" determines the level of accuracy necessary for the estimate +$n = 5; + +# define a js function to evaluate f(x) "invisibly" +# function should NOT allow evaluation at "x = a" +HEADER_TEXT(< +EOF + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [['\(x\)', headerrow=>1], 'click to get:', '\(f(x)\)'], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], + [ + MODES( + HTML => qq{}, + TeX => '\fbox{Enter \(x\)}' + ), MODES( + HTML => qq{}, + TeX => '\(\rightarrow\)' + ), MODES( + HTML => qq{}, + TeX => 'result: \(f(x)\)' + ) + ], +], +allcellcss=>'padding: 1pt;', +align=>'c c c'); + + + +$ansTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[5]", "$y[5]"], + ["$x[1]", "$y[1]",' |',"$x[6]", "$y[6]"], + ["$x[2]", "$y[2]",'| ',"$x[7]", "$y[7]"], + ["$x[3]", "$y[3]",'| ',"$x[8]", "$y[8]"], + ["$x[4]", "$y[4]",'| ',"$x[9]", "$y[9]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Analytic approach to taking limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + +>> #### Practice #### << + + + +Evaluating [``\lim_{x \to [$a]} f(x)``]. + +[$xyTable]*** + +Based on the above, what do you estimate as the value for [``\lim_{x \to [$a]} f(x)``]? [___________] + +* use decimals for all responses. +* because our goal is to "get close," you should try [`x`]-values that are very close to [$a]. +* keep trying [`x`]-values until your final estimate is accurate to [$n] decimal places. +* if the limit does not exist, enter "DNE". + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# students must push +ANS(Real($yLimit)->cmp(tolerance=>5*10**(-$n-1))); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* Choose values of [`x`] that are getting closer and closer to [`[$a]`], say, from the left. + +* Observe what happens with the outputs [`f(x)`]. Can you estimate a left-limit? + +* Now do the same for the right side. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# + +BEGIN_PGML_SOLUTION + +* We have: + +[$ansTable]*** + +* As the inputs [`[$x[0]]`], [`[$x[1]]`], [`[$x[2]]`], [`[$x[3]]`] and [`[$x[4]]`] are approaching [`[$a]`] from the left, their corresponding outputs [`[$y[0]]`], [`[$y[1]]`], [`[$y[2]]`], [`[$y[3]]`] and [`[$y[4]]`] are approaching [`[$yLimit]`]. + +* As the inputs [`[$x[5]]`], [`[$x[6]]`], [`[$x[7]]`], [`[$x[8]]`] and [`[$x[9]]`] are approaching [`[$a]`] from the right, their corresponding outputs [`[$y[5]]`], [`[$y[6]]`], [`[$y[7]]`], [`[$y[8]]`] and [`[$y[9]]`] are approaching [`[$yLimit]`]. + +* We estimate [`\displaystyle\lim_{x \to [$a]} f(x)`] to be [`[$yLimit]`]. + + + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pg index fc44f252be..80132c62ad 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pg @@ -69,7 +69,7 @@ $xyTable = LayoutTable( ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); $fxTable = LayoutTable( @@ -80,7 +80,7 @@ $fxTable = LayoutTable( ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pge new file mode 100644 index 0000000000..80132c62ad --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/intro-x-given.pge @@ -0,0 +1,188 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$f = Formula("sqrt(x)"); +$a = list_random(2,3,5,6,7,8,10,11,12,13,14,15); +$yLimit = $f->eval(x=>$a); +@x = (); + +# This sets the tolerance for the problem at -($n+1) +$n = 3; + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [[' ', headerrow=>1], ' ', 'f(x) = '.$f->TeX , ' ', ' '], + [['x', headerrow=>1], 'f(x)', ' ', 'x', 'f(x)'], + ["$x[0]", [ans_rule(5),noencase=>1],' ',"$x[3]", [ans_rule(5),noencase=>1]], + ["$x[1]", [ans_rule(5),noencase=>1],' ',"$x[4]", [ans_rule(5),noencase=>1]], + ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +$fxTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[3]", "$y[3]"], + ["$x[1]", "$y[1]",' |',"$x[4]", "$y[4]"], + ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Numerically Approximating Limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + +>> #### Practice #### << + +Evaluating [``\lim_{x \to [$a]} [$f]``]. + +[$xyTable]*** + +Based on the above, _estimate_ the value for [``\lim_{x \to [$a]} [$f]``]: [___________] + +* use decimals for all responses. +* because our goal is to "get close," make sure your decimal responses are accurate to at least [@$n+2@] decimal places. +* your final estimate is not expected to have as much "accuracy" - it will only be an estimate. +* if the limit does not exist, enter "DNE". + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# unnecessary, but the answer order looks strange in one-column +ANS(Real($y[0])->cmp); ANS(Real($y[3])->cmp); +ANS(Real($y[1])->cmp); ANS(Real($y[4])->cmp); +ANS(Real($y[2])->cmp); ANS(Real($y[5])->cmp); + +ANS(Real($yLimit)->cmp(tolerance=>5*10**(-$n-2))); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* The numbers [`[$x[0]]`], [`[$x[1]]`] and [`[$x[2]]`] approximate [`[$a]`] from the left. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[0]])`], [`f([$x[1]])`] and [`f([$x[2]])`]? +Are they approaching a specific number? If so, that's an estimate for the left limit. + +* The numbers [`[$x[3]]`], [`[$x[4]]`] and [`[$x[5]]`] approximate [`[$a]`] from the right. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[3]])`], [`f([$x[4]])`] and [`f([$x[5]])`]? +Are they approaching a specific number? If so, that's an estimate for the right limit. + +* Are your estimates for the left- and right-limit very close? If so, you have found [`\displaystyle\lim_{x \to [$a]} [$f]`]. If not, the limit does not exist. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# +BEGIN_PGML_SOLUTION +* For [`f(x) = [$f]`]: + +[$fxTable]*** + +* The left outputs, [`[$y[0]]`], [`[$y[1]]`] and [`[$y[2]]`], approach [`[$yLimit]`]. + +* The right outputs, [`[$y[3]]`], [`[$y[4]]`] and [`[$y[5]]`], also approach [`[$yLimit]`]. + +* We estimate [`\displaystyle\lim_{x \to [$a]} [$f]`] to be [`[$yLimit]`]. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pg index ed5b9ddcd6..1086835a3d 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pg @@ -73,7 +73,7 @@ $xyTable = LayoutTable( ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); $fxTable = LayoutTable( @@ -84,7 +84,7 @@ $fxTable = LayoutTable( ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pge new file mode 100644 index 0000000000..1086835a3d --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/last-x-given.pge @@ -0,0 +1,197 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$a = non_zero_random(-9,9,1); +do{ $b = non_zero_random(-9,9,1); } until ($a != $b); # just so lim != 0 +$B = -($a+$b); +$C = $a*$b; +$numer = Formula("x^2 + $B x + $C")->reduce; +$denom = Formula("x - $a")->reduce; +$f = Formula("$numer/$denom"); +$yLimit = Real($a - $b); +@x = (); + +$n = 3; + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [[' ', headerrow=>1], ' ', 'f(x) = '.$f->TeX , ' ', ' '], + [['x', headerrow=>1], 'f(x)', ' ', 'x', 'f(x)'], + ["$x[0]", [ans_rule(5),noencase=>1],' ',"$x[3]", [ans_rule(5),noencase=>1]], + ["$x[1]", [ans_rule(5),noencase=>1],' ',"$x[4]", [ans_rule(5),noencase=>1]], + ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +$fxTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[3]", "$y[3]"], + ["$x[1]", "$y[1]",' |',"$x[4]", "$y[4]"], + ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Numerically Approximating Limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + +>> #### Practice #### << + +Evaluating [``\lim_{x \to [$a]} [$f]``]. + +[$xyTable]*** + +Based on the above, what do you estimate as the value for [``\lim_{x \to [$a]} [$f]``]? [___________] + +* use decimals for all responses. +* because our goal is to "get close," make sure your decimal responses are accurate to at least 5 decimal places. +* your final estimate is not expected to have as much "accuracy" - it will only be an estimate. +* if the limit does not exist, enter "DNE". + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# unnecessary, but the answer order looks strange in one-column +ANS(Real($y[0])->cmp); ANS(Real($y[3])->cmp); +ANS(Real($y[1])->cmp); ANS(Real($y[4])->cmp); +ANS(Real($y[2])->cmp); ANS(Real($y[5])->cmp); + +ANS(Real($yLimit)->cmp); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* The numbers [`[$x[0]]`], [`[$x[1]]`] and [`[$x[2]]`] approximate [`[$a]`] from the left. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[0]])`], [`f([$x[1]])`] and [`f([$x[2]])`]? +Are they approaching a specific number? If so, that's the \color{blue}{left limit}. + +* The numbers [`[$x[3]]`], [`[$x[4]]`] and [`[$x[5]]`] approximate [`[$a]`] from the right. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[3]])`], [`f([$x[4]])`] and [`f([$x[5]])`]? +Are they approaching a specific number? If so, that's the right limit. + +* Are the left- and right-limit the same? If so, you have found [`\displaystyle\lim_{x \to [$a]} [$f]`]. If not, the limit does not exist. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# +BEGIN_PGML_SOLUTION +* For [`f(x) = \displaystyle[$f]`]: + +[$fxTable]*** + +* The left outputs [`[$y[0]]`], [`[$y[1]]`] and [`[$y[2]]`] approach [`[$yLimit]`]. + +* The right outputs [`[$y[3]]`], [`[$y[4]]`] and [`[$y[5]]`] also approach [`[$yLimit]`]. + +* We estimate [`\displaystyle\lim_{x \to [$a]} [$f]`] to be [`[$yLimit]`]. + + + +END_PGML_SOLUTION + + + + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/limits-visually.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/limits-visually.pg index f5e4bca34d..78ef59652a 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/limits-visually.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/limits-visually.pg @@ -105,7 +105,7 @@ $table = LayoutTable( ["\(\displaystyle \lim_{x \to $a} f(x) =\)".ans_rule(5), rowcss=>"padding-top:2pt;"]], ], - align => 'c c', + align => 'cc', center => 1, ); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pg index 7f488b7a3a..2fc05fbeb6 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pg @@ -69,7 +69,7 @@ $xyTable = LayoutTable( ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); $fxTable = LayoutTable( @@ -80,7 +80,7 @@ $fxTable = LayoutTable( ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], ], allcellcss=>'padding: 1pt;', -align=>'c c c c c', +align=>'ccccc', encase=>['\(','\)']); ############################################################## diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pge b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pge new file mode 100644 index 0000000000..2fc05fbeb6 --- /dev/null +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_Introduction/more-x-given.pge @@ -0,0 +1,187 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('calculus', '', '') + +## DBsubject('Calculus - single variable') +## DBchapter('') +## DBsection('') +## Date('6/15/2019') +## Author('K. Andrew Parker') +## Institution('CityTech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFormulas=>0, + tolerance=>10**(-10), + tolType=>'absolute', +); + +$a = non_zero_random(-9,9,1); +$b = non_zero_random(1,9,1); +$f = Formula("$b/(x-$a)")->reduce; +$yLimit = String("DNE")->with(typeMatch=>Real(1)); +@x = (); + +$n = 3; + +for $i ( 0..($n-1) ) { + $x[$i] = $a - 10**(-$i-1); + $x[$i+$n] = $a + 10**(-$i-1); +} + +@y = (); +for $i ( 0..(2*$n-1) ) { + $y[$i] = $f->eval(x=>$x[$i]); +} + +$xyTable = LayoutTable( +[ + [[' ', headerrow=>1], ' ', 'f(x) = '.$f->TeX , ' ', ' '], + [['x', headerrow=>1], 'f(x)', ' ', 'x', 'f(x)'], + ["$x[0]", [ans_rule(5),noencase=>1],' ',"$x[3]", [ans_rule(5),noencase=>1]], + ["$x[1]", [ans_rule(5),noencase=>1],' ',"$x[4]", [ans_rule(5),noencase=>1]], + ["$x[2]", [ans_rule(5),noencase=>1],' ',"$x[5]", [ans_rule(5),noencase=>1]], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +$fxTable = LayoutTable( +[ + [['x', headerrow=>1], 'f(x)', ' |', 'x', 'f(x)'], + ["$x[0]", "$y[0]",' |',"$x[3]", "$y[3]"], + ["$x[1]", "$y[1]",' |',"$x[4]", "$y[4]"], + ["$x[2]", "$y[2]",'| ',"$x[5]", "$y[5]"], +], +allcellcss=>'padding: 1pt;', +align=>'ccccc', +encase=>['\(','\)']); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Numerically Approximating Limits ### << + +Suppose that [``\lim_{x \to a} f(x)=L``]. This means that as [`x`] gets closer and closer (_but not equal_) to [`a`], the output [`f(x)`] gets closer and closer to [`L`]. To estimate [`L`], choose an [`x`] that is very close to [`a`], say, smaller than [`a`]. Then calculate [`f(x)`]. Now choose another [`x`] that is even closer to [`a`] and smaller than [`a`], and calculate [`f(x)`]. Repeat this process. Do you notice the outputs approaching a particular number? Do the same with values of [`x`] that are very close to [`a`], but greater than [`a`]. Do the outputs approach that same particular number? If so, you have estimated [`L`]. Otherwise, the limit does not exist. + + + +>> #### Practice #### << + +Evaluating [``\lim_{x \to [$a]} [$f]``]. + +[$xyTable]*** + +Based on the above, what do you estimate as the value for [``\lim_{x \to [$a]} [$f]``]? [___________] + +* use decimals for all responses. +* because our goal is to "get close," make sure your decimal responses are accurate to at least 5 decimal places. +* your final estimate is not expected to have as much "accuracy" - it will only be an estimate. +* if the limit does not exist, enter "DNE". + +END_PGML + +############################################################## +# +# Answers +# +# + +# reset the context to force entry of decimal values +Context("LimitedNumeric"); +Context()->flags->set( + tolerance=>5*10**(-$n-3), + tolType=>'absolute', +); +# and replace all the standard error messages about operations +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"} + = "Use decimals to represent your output value."; +Context()->{error}{msg}{"Unexpected character '('"} + = "Your answer should not contain parenthesis. Compute the result as a number."; + +# unnecessary, but the answer order looks strange in one-column +ANS(Real($y[0])->cmp); ANS(Real($y[3])->cmp); +ANS(Real($y[1])->cmp); ANS(Real($y[4])->cmp); +ANS(Real($y[2])->cmp); ANS(Real($y[5])->cmp); + +ANS($yLimit->cmp); + +############################################################## +# +# Hint +# +# + +BEGIN_PGML_HINT + +* The numbers [`[$x[0]]`], [`[$x[1]]`] and [`[$x[2]]`] approximate [`[$a]`] from the left. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[0]])`], [`f([$x[1]])`] and [`f([$x[2]])`]? +Are they approaching a specific number? If so, that's the left limit. + +* The numbers [`[$x[3]]`], [`[$x[4]]`] and [`[$x[5]]`] approximate [`[$a]`] from the right. As they approach [`[$a]`], what's happening with their outputs, [`f([$x[3]])`], [`f([$x[4]])`] and [`f([$x[5]])`]? +Are they approaching a specific number? If so, that's the right limit. + +* Are the left- and right-limit the same? If so, you have found [`\displaystyle\lim_{x \to [$a]} [$f]`]. If not, the limit does not exist. + +END_PGML_HINT + +############################################################## +# +# Solution +# +# +BEGIN_PGML_SOLUTION +* For [`f(x) = \displaystyle[$f]`]: + +[$fxTable]*** + +* The left outputs, [`[$y[0]]`], [`[$y[1]]`] and [`[$y[2]]`], are all negative and are decreasing, while the right outputs, [`[$y[3]]`], [`[$y[4]]`] and [`[$y[5]]`], are all positive and are increasing. So they cannot approach the same number. + +* [`\displaystyle\lim_{x \to [$a]} [$f] \; [$yLimit]`] +END_PGML_SOLUTION + + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Calculus/setLimits_-_One-Sided/intro-piecewise.pg b/Contrib/CUNY/CityTech/Calculus/setLimits_-_One-Sided/intro-piecewise.pg index 3a0fa075e3..fc9aef3522 100644 --- a/Contrib/CUNY/CityTech/Calculus/setLimits_-_One-Sided/intro-piecewise.pg +++ b/Contrib/CUNY/CityTech/Calculus/setLimits_-_One-Sided/intro-piecewise.pg @@ -155,7 +155,7 @@ $table = LayoutTable( ["\(\displaystyle \lim_{x \to $a} f(x) =\)".$multiAns[3]->ans_rule(6), rowcss=>"padding-top:2pt;"]], ], - align => 'c c', + align => 'cc', center => 1, ); ############################################################## diff --git a/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/MultiplyRadicals/algebraic-with-coefficients.pg b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/MultiplyRadicals/algebraic-with-coefficients.pg index 2e4915f68e..2599568a70 100755 --- a/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/MultiplyRadicals/algebraic-with-coefficients.pg +++ b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/MultiplyRadicals/algebraic-with-coefficients.pg @@ -35,18 +35,18 @@ $showPartialCorrectAnswers = 1; # # Context("LimitedRadical")->flags->set(reduceConstants=>0, reduceConstantFunctions=>0); -Context()->variables->are(a=>[Real,limits=>[0,2]], b=>[Real,limits=>[0,2]]); +Context()->variables->are(c=>[Real,limits=>[0,2]], d=>[Real,limits=>[0,2]]); $c1 = random(-1,1,2)*random(2,6,1); $c2 = random(-1,1,2)*random(2,6,1); $c = $c1*$c2; -$rad1 = Formula("b"); -$rad2 = Formula("a b"); +$rad1 = Formula("d"); +$rad2 = Formula("c d"); -$out = Formula("$c a b"); -$in = Formula("a"); -$problem1 = Formula("$c1 a sqrt($rad1)"); +$out = Formula("$c c d"); +$in = Formula("c"); +$problem1 = Formula("$c1 c sqrt($rad1)"); $problem2 = Formula("$c2 sqrt($rad2)"); $ans = Formula("$out sqrt($in)"); @@ -91,22 +91,22 @@ Remember that \(\sqrt{a}\sqrt{a} = a\) END_HINT BEGIN_SOLUTION $BBOLD Consider the non-radical factors separately: $EBOLD $BR -\( \displaystyle \left($problem1\right)\left($problem2\right) = \left($c1 \cdot $c2 a \right) \left( \sqrt{$rad1} \sqrt{$rad2} \right) \) +\( \displaystyle \left($problem1\right)\left($problem2\right) = \left($c1 \cdot $c2 c \right) \left( \sqrt{$rad1} \sqrt{$rad2} \right) \) $PAR $BBOLD Multiply the non-radical factors: $EBOLD $BR -\( \displaystyle \left($c1 \cdot $c2 a \right) \left( \sqrt{$rad1} \sqrt{$rad2} \right) = ($c a) \left( \sqrt{$rad1} \sqrt{$rad2} \right) \) +\( \displaystyle \left($c1 \cdot $c2 a \right) \left( \sqrt{$rad1} \sqrt{$rad2} \right) = ($c c) \left( \sqrt{$rad1} \sqrt{$rad2} \right) \) $PAR $BBOLD Break down the radicals: $EBOLD $BR -\( \displaystyle ($c a) \left( \sqrt{$rad1} \sqrt{$rad2} \right) = ($c a) \left( \sqrt{b} \sqrt{a} \sqrt{b} \right) \) +\( \displaystyle ($c c) \left( \sqrt{$rad1} \sqrt{$rad2} \right) = ($c c) \left( \sqrt{d} \sqrt{c} \sqrt{d} \right) \) $PAR $BBOLD Simplify the repeated radical: $EBOLD $BR -\( \displaystyle ($c a) \left( \sqrt{b} \sqrt{b} \sqrt{a} \right) = ($c a) \left( b \sqrt{a} \right) \) +\( \displaystyle ($c c) \left( \sqrt{d} \sqrt{d} \sqrt{c} \right) = ($c c) \left( d \sqrt{c} \right) \) $PAR $BBOLD Rearrange your result: $EBOLD $BR -\( \displaystyle ($c a) \left( b \sqrt{a} \right) = $c a b \sqrt{a} \) +\( \displaystyle ($c c) \left( d \sqrt{c} \right) = $c c d \sqrt{c} \) END_SOLUTION Context()->normalStrings; COMMENT("Funded by US DoE Title V: Opening Gateways grant."); -ENDDOCUMENT(); \ No newline at end of file +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-cosine-vary-reference.pg b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-cosine-vary-reference.pg new file mode 100644 index 0000000000..ac33a3c081 --- /dev/null +++ b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-cosine-vary-reference.pg @@ -0,0 +1,144 @@ +##DESCRIPTION +## Trigonometry problem: Find values of trig functions at given angles using unit circle +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'unit circle', 'angle', 'angles', 'radians', 'trig functions', 'trigonometric functions') + +## DBsubject(Trigonometry) +## DBchapter(Trigonometric functions) +## DBsection(Unit circle) +## Level(2) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.0005 +); + +Parser::Number::NoDecimals(); + +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-(sqrt(3)/2)"), + y => Formula("1/2"), + ny => Formula("-(1/2)"), + t => Formula("1/sqrt(3)"), + nt => Formula("-(1/sqrt(3))"), + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-(1/2)"), + y => Formula("sqrt(3)/2"), + ny => Formula("-(sqrt(3)/2)"), + t => Formula("sqrt(3)"), + nt => Formula("-sqrt(3)") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-(sqrt(2)/2)"), + y => Formula("sqrt(2)/2"), + ny => Formula("-(sqrt(2)/2)"), + t => Formula("1"), + nt => Formula("-1") + } +); + +@sin = qw(y y ny ny y ny y y); +@cos = qw(x nx nx x x nx nx x); +@ans = (); +@angle = (); + +$denom=3; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[0]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[0]= $unit{$denom}{$cos[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[1]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[1]= $unit{$denom}{$cos[$k]}; + + +$denom=4; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[2]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[2]= $unit{$denom}{$cos[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[3]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[3]= $unit{$denom}{$cos[$k]}; + + +$denom=6; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[4]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[4]= $unit{$denom}{$cos[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[5]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[5]= $unit{$denom}{$cos[$k]}; + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +Without using a calculator, state the _exact_ value of the following trig functions for the specified angle. + +a) [`` \cos\left([$angle[0]]\right) = ``] [_____________]{$ans[0]} + +a) [`` \cos\left([$angle[2]]\right) = ``] [_____________]{$ans[2]} + +a) [`` \cos\left([$angle[4]]\right) = ``] [_____________]{$ans[4]} + +END_PGML + +BEGIN_PGML_HINT + +What is the reference angle for each? + +And what does that tell you about the cosine of each angle? + +END_PGML_HINT +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-sine-vary-reference.pg b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-sine-vary-reference.pg new file mode 100644 index 0000000000..04dea6b8c5 --- /dev/null +++ b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-sine-vary-reference.pg @@ -0,0 +1,142 @@ +##DESCRIPTION +## Trigonometry problem: Find values of trig functions at given angles using unit circle +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'unit circle', 'angle', 'angles', 'radians', 'trig functions', 'trigonometric functions') + +## DBsubject(Trigonometry) +## DBchapter(Trigonometric functions) +## DBsection(Unit circle) +## Level(2) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.0005 +); + +Parser::Number::NoDecimals(); + +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-(sqrt(3)/2)"), + y => Formula("1/2"), + ny => Formula("-(1/2)"), + t => Formula("1/sqrt(3)"), + nt => Formula("-(1/sqrt(3))"), + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-(1/2)"), + y => Formula("sqrt(3)/2"), + ny => Formula("-(sqrt(3)/2)"), + t => Formula("sqrt(3)"), + nt => Formula("-sqrt(3)") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-(sqrt(2)/2)"), + y => Formula("sqrt(2)/2"), + ny => Formula("-(sqrt(2)/2)"), + t => Formula("1"), + nt => Formula("-1") + } +); + +@sin = qw(y y ny ny y ny y y); +@ans = (); + +$denom=3; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(0,7,1); +$angle[0]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[0]= $unit{$denom}{$sin[$j]}; + +do { $k=random(0,7,1); } until ($k!=$j); +$angle[1]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[1]= $unit{$denom}{$sin[$k]}; + + +$denom=4; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(0,7,1); +$angle[2]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[2]= $unit{$denom}{$sin[$j]}; + +do { $k=random(0,7,1); } until ($k!=$j); +$angle[3]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[3]= $unit{$denom}{$sin[$k]}; + + +$denom=6; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(0,7,1); +$angle[4]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[4]= $unit{$denom}{$sin[$j]}; + +do { $k=random(0,7,1); } until ($k!=$j); +$angle[5]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[5]= $unit{$denom}{$sin[$k]}; + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +Without using a calculator, state the _exact_ value of the following trig functions for the specified angle. + +a) [`` \sin\left([$angle[0]]\right) = ``] [_____________]{$ans[0]} + +a) [`` \sin\left([$angle[2]]\right) = ``] [_____________]{$ans[2]} + +a) [`` \sin\left([$angle[4]]\right) = ``] [_____________]{$ans[4]} + + +END_PGML + +BEGIN_PGML_HINT + +What is the reference angle for each? + +And what does that tell you about the sine of each angle? + +END_PGML_HINT + + +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-tangent-vary-reference.pg b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-tangent-vary-reference.pg new file mode 100644 index 0000000000..081eb38b0c --- /dev/null +++ b/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/UnitCircle/unit-circle-tangent-vary-reference.pg @@ -0,0 +1,144 @@ +##DESCRIPTION +## Trigonometry problem: Find values of trig functions at given angles using unit circle +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'unit circle', 'angle', 'angles', 'radians', 'trig functions', 'trigonometric functions') + +## DBsubject(Trigonometry) +## DBchapter(Trigonometric functions) +## DBsection(Unit circle) +## Level(2) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.0005 +); + +Parser::Number::NoDecimals(); + +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-(sqrt(3)/2)"), + y => Formula("1/2"), + ny => Formula("-(1/2)"), + t => Formula("1/sqrt(3)"), + nt => Formula("-(1/sqrt(3))"), + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-(1/2)"), + y => Formula("sqrt(3)/2"), + ny => Formula("-(sqrt(3)/2)"), + t => Formula("sqrt(3)"), + nt => Formula("-sqrt(3)") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-(sqrt(2)/2)"), + y => Formula("sqrt(2)/2"), + ny => Formula("-(sqrt(2)/2)"), + t => Formula("1"), + nt => Formula("-1") + } +); + +@sin = qw(y y ny ny y ny y y); +@cos = qw(x nx nx x x nx nx x); +@tan = qw(t nt t nt t t nt t); +@ans = (); +@angle = (); + +$denom=3; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[0]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[0]= $unit{$denom}{$tan[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[1]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[1]= $unit{$denom}{$tan[$k]}; + + +$denom=4; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[2]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[2]= $unit{$denom}{$tan[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[3]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[3]= $unit{$denom}{$tan[$k]}; + + +$denom=6; +@n = ( 1, $denom-1, $denom+1, 2*$denom-1, 2*$denom+1, -$denom+1, -$denom-1, -2*$denom+1 ); + +$j=random(1,7); +$angle[4]=Formula("( $n[$j] pi )/ $denom")->reduce; +$ans[4]= $unit{$denom}{$tan[$j]}; + +do { $k=random(1,7); } until ($k!=$j); +$angle[5]=Formula("( $n[$k] pi )/ $denom")->reduce; +$ans[5]= $unit{$denom}{$tan[$k]}; + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +Without using a calculator, state the _exact_ value of the following trig functions for the specified angle. + +a) [`` \tan\left([$angle[0]]\right) = ``] [__________]{$ans[0]} + +a) [`` \tan\left([$angle[2]]\right) = ``] [__________]{$ans[2]} + +a) [`` \tan\left([$angle[4]]\right) = ``] [__________]{$ans[4]} + +END_PGML + +BEGIN_PGML_HINT + +What is the reference angle for each? + +And what does that tell you about the tangent of each angle? + +END_PGML_HINT + +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Direction/ggb-complex-argument.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Direction/ggb-complex-argument.pg index 4e1d16bafc..05707b0f3f 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Direction/ggb-complex-argument.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Direction/ggb-complex-argument.pg @@ -416,7 +416,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus-given.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus-given.pg index d3006f03dd..fbae6173ce 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus-given.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus-given.pg @@ -231,7 +231,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus.pg index b41374dfb9..32bea9178f 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Magnitude/ggb-modulus.pg @@ -199,7 +199,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Operations b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Operations new file mode 120000 index 0000000000..d7c3eb83c7 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Operations @@ -0,0 +1 @@ +/opt/webwork/libraries/webwork-open-problem-library/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/ComplexNumbers/ \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product-polar.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product-polar.pg index 58ac05390b..6eac65c6ac 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product-polar.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product-polar.pg @@ -490,7 +490,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product.pg index 787bf4c4a2..c894933233 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-product.pg @@ -483,7 +483,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient-polar.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient-polar.pg index 5873886bc4..88e918d0ae 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient-polar.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient-polar.pg @@ -508,7 +508,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient.pg index bb6770b100..b7037dcdf9 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/ggb-quotient.pg @@ -482,7 +482,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-product-and-convert.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-product-and-convert.pg new file mode 100644 index 0000000000..fed4b4a288 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-product-and-convert.pg @@ -0,0 +1,79 @@ +DOCUMENT(); +loadMacros("PGstandard.pl","PGML.pl"); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Numeric"); +Context("Complex"); + +# $variable = random( low, high, interval ); +#$QuotOrPro=random(1,2,1); +$QuotOrPro=2; #1: quotien, 2:product + +@PossibleAngleAnsw=(30,45,60,90,120,135,150,180,210,225,240,270,300,315,330); + +if ($QuotOrPro==1) { + $version =random(0,9,1); #$version=2; #<<<------------------------------ + do {$AngleB=random(10,100,5); #$AngleB=90; + $AngleA=$PossibleAngleAnsw[$version]+$AngleB;} + until (($AngleB-90)*($AngleA-90)*($AngleA-180)*($AngleA-270)!=0); + $CoeffA=random(2,8,2); + $CoeffB=random(2,7,1); + + $cosi=cos($PossibleAngleAnsw[$version]*pi/180); + $sine=sin($PossibleAngleAnsw[$version]*pi/180); + $answer=Complex($CoeffA/$CoeffB*($cosi+$sine *i)); + + $display="\frac{$CoeffA\cdot (\cos $AngleA ^\circ+i\sin $AngleA ^\circ)}{$CoeffB\cdot (\cos $AngleB ^\circ+i\sin $AngleB ^\circ)}"; + $term="quotient"; + } +else { + $version =random(5,14,1); #$version=2; #<<<------------------------------ + do {$AngleB=random(10,100,5); #$AngleB=90; + $AngleA=$PossibleAngleAnsw[$version]-$AngleB;} + until (($AngleB-90)*($AngleA-90)*($AngleA-180)*($AngleA-270)!=0); + $CoeffA=random(2,6,1); + $CoeffB=random(2,8,1); + + $cosi=cos($PossibleAngleAnsw[$version]*pi/180); + $sine=sin($PossibleAngleAnsw[$version]*pi/180); + $answer=Complex($CoeffA*$CoeffB*($cosi+$sine *i)); + + $display="[$CoeffA\cdot (\cos $AngleA ^\circ+i\sin $AngleA ^\circ)]\cdot [$CoeffB\cdot (\cos $AngleB ^\circ+i\sin $AngleB ^\circ)]"; + $term="product"; + } + + + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex +#[```[$version], // , [$PossibleAngleAnsw[$version]],// , [$answer]```] + +BEGIN_PGML + +##### Example: ##### + +Multiply and write in [`a+bi`] form: [`\quad [3(\cos(115^\circ)+i\sin(115^\circ)]\cdot [4(\cos(95^\circ)+i\sin(95^\circ)]`] + +*Solution:* + +[``` +\begin{align*} +& 3(\cos(115^\circ)+i\sin(115^\circ)]\cdot [4(\cos(95^\circ)+i\sin(95^\circ)] +=12(\cos(210^\circ)+i\sin(210^\circ))\\ +&\quad =12\left(-\frac{\sqrt{3}}{2}+i\cdot \Big(-\frac 1 2\Big)\right) +=-12\cdot \frac{\sqrt{3}}{2}-12\cdot \frac 1 2\cdot i +=-6\sqrt{3}-6i +\end{align*} +```] + +>> #### Practice #### << + +Find the [$term] and write the result in [`a+bi`] form: +[```[$display] ```] + +Answer: [__________]{$answer} + + +END_PGML +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-quotient-and-convert.pg b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-quotient-and-convert.pg new file mode 100644 index 0000000000..001db83923 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setComplex_Numbers_-_Polar_Form/polar-form-quotient-and-convert.pg @@ -0,0 +1,61 @@ +DOCUMENT(); +loadMacros("PGstandard.pl","PGML.pl"); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Numeric"); +Context("Complex"); + +# $variable = random( low, high, interval ); +#$QuotOrPro=random(1,2,1); +$QuotOrPro=1; #1: quotien, 2:product + +@PossibleAngleAnsw=(30,45,60,90,120,135,150,180,210,225,240,270,300,315,330); + +if ($QuotOrPro==1) { + $version =random(0,9,1); #$version=2; #<<<------------------------------ + do {$AngleB=random(10,100,5); #$AngleB=90; + $AngleA=$PossibleAngleAnsw[$version]+$AngleB;} + until (($AngleB-90)*($AngleA-90)*($AngleA-180)*($AngleA-270)!=0); + $CoeffA=random(2,8,2); + $CoeffB=random(2,7,1); + + $cosi=cos($PossibleAngleAnsw[$version]*pi/180); + $sine=sin($PossibleAngleAnsw[$version]*pi/180); + $answer=Complex($CoeffA/$CoeffB*($cosi+$sine *i)); + + $display="\frac{$CoeffA\cdot (\cos $AngleA ^\circ+i\sin $AngleA ^\circ)}{$CoeffB\cdot (\cos $AngleB ^\circ+i\sin $AngleB ^\circ)}"; + $term="quotient"; + } +else { + $version =random(5,14,1); #$version=2; #<<<------------------------------ + do {$AngleB=random(10,100,5); #$AngleB=90; + $AngleA=$PossibleAngleAnsw[$version]-$AngleB;} + until (($AngleB-90)*($AngleA-90)*($AngleA-180)*($AngleA-270)!=0); + $CoeffA=random(2,6,1); + $CoeffB=random(2,8,1); + + $cosi=cos($PossibleAngleAnsw[$version]*pi/180); + $sine=sin($PossibleAngleAnsw[$version]*pi/180); + $answer=Complex($CoeffA*$CoeffB*($cosi+$sine *i)); + + $display="[$CoeffA\cdot (\cos $AngleA ^\circ+i\sin $AngleA ^\circ)]\cdot [$CoeffB\cdot (\cos $AngleB ^\circ+i\sin $AngleB ^\circ)]"; + $term="product"; + } + + + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex +#[```[$version], // , [$PossibleAngleAnsw[$version]],// , [$answer]```] + +BEGIN_PGML + +Find the [$term] and write the result in [`a+bi`] form: +[```[$display] ```] + +Answer: [__________]{$answer} + + +END_PGML +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setDifference_Quotient/diff-quot-quad-2.pg b/Contrib/CUNY/CityTech/Precalculus/setDifference_Quotient/diff-quot-quad-2.pg new file mode 100644 index 0000000000..cd915bd595 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setDifference_Quotient/diff-quot-quad-2.pg @@ -0,0 +1,207 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'function', 'input', 'output', 'rational function', 'difference quotient') + +## DBsubject('Algebra') +## DBchapter('Functions') +## DBsection('Difference quotient') +## Date('6/12/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') +## TitleText1('Precalculus') + + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextLimitedPolynomial.pl", + "niceTables.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->noreduce('(-x)-y','(-x)+y'); +Context()->variables->add(a=>Real,h=>Real); + +$fA = random(2,4,1); +$fB = 2*non_zero_random(-4,4,1); +# let's make sure that students have to deal distributing subtraction... +$fC = random(-40,-12,1); +$f = Formula("$fA x^2 + $fB x + $fC")->reduce; + +$fa = $f->substitute(x=>a); +$fah = Formula("$fA a^2 + (2*$fA) ah + $fA h^2 + $fB a + $fB h + $fC")->reduce; +$fdqNumer = Formula("(2*$fA) ah + $fA h^2 + $fB h")->reduce; +$fdq = Formula("(2*$fA) a + $fA h + $fB")->reduce; + + + +$fevone = Formula("$fah - $fA a^2- $fB a - $fC")->reduce; + +Context("LimitedPolynomial-Strict"); +Context()->{error}{msg}{"Addition is allowed only between monomials"} + = "Please combine like terms and resubmit your answer."; +Context()->{error}{msg}{"Subtraction is allowed only between monomials"} + = "Please combine like terms and resubmit your answer."; +Context()->{error}{msg}{"Multiplication can only be used between coefficients and variables"} + = "Please distribute your multiplication and resubmit your answer."; +Context()->{error}{msg}{"In a polynomial, you can only divide by numbers"} + = "Reduce your fraction and resubmit your answer."; + +Context()->variables->are(a=>Real, h=>Real); + +$fa = Formula($fa); +$fah = Formula($fah); +$fdqNumer = Formula($fdqNumer); +$fdq = Formula($fdq); + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + + +Consider [`f(x) = [$f]`]. + +a. Compute: [`\quad f(a) =`][________________________________________]{$fa} + +b. Compute and simplify: [`\quad f(a+h) =`][________________________________________]{$fah} + +c. Compute and simplify: [`\quad f(a+h) - f(a) =`][________________________________________]{$fdqNumer} + +d. Compute and simplify: [`\quad \displaystyle \frac{f(a+h) - f(a)}{h} =`][________________________________________]{$fdq} + + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + + +* Identify the function and the input you want to evaluate. + +* Substitute each [`x`] in the definition of the function by the input. Make sure to enclose your input in parentheses. + +* [`(x+y)^2=x^2+2xy+y^2`] + +* If necessary, simplify your answer. Verify if you have to use the distributive property by: + +[`\qquad`] - multiplying a number by each term inside the parentheses, + +[`\qquad`] - changing the sign of each term inside the parentheses. + +* Combine all like terms. Provide your answer in simplified form. + + + + + + + + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + +# the following makes sure that if $fB=1 then we don't have +1(a+b) + + + +if ( $fB == 1 ) { + $fevalone = "$fA(a+h)^2+ (a+h) + $fC"; +} else { + if ( $fB == -1 ) { + $fevalone = "$fA(a+h)^2- (a+h) + $fC"; + } else{ + $fevalone = "$fA(a+h)^2+ $fB (a+h) + $fC"; +} +} + +if ( $fB == 1 ) { + $fahEvalone = "$fA(a^2+2ah+h^2)+ a+h + $fC"; +} else { + if ( $fB == -1 ) { + $fahEvalone = "$fA(a^2+2ah+h^2)- a-h + $fC"; + } else{ + $fahEvalone = "$fA(a^2+2ah+h^2)+ $fB a+ $fB h + $fC"; +} +} + + + +BEGIN_PGML_SOLUTION + +a. + + [`f(x)=[$f] \quad\underset{x\rightarrow a}\longrightarrow\quad f(a) = [$fa]`] + + So [`f(a) = [$fa]`]. + +b. + + [`\begin{align*} f(x)=[$f] \quad\underset{x\rightarrow a+h}\longrightarrow\quad f(a+h) &\qquad = \quad & [$fevalone] \\ + &\quad\longrightarrow\quad & [$fahEvalone] \\ + &\quad\longrightarrow\quad &[$fah]\end{align*} `] + + So [`f(a+h)= [$fah] `]. + +c. + + [`\begin{align*} f(a+h)-f(a)& \quad\longrightarrow\quad & ([$fah])-([$fa])\\ + &\quad\longrightarrow\quad & [$fevone] \\ + &\quad\longrightarrow\quad &[$fdqNumer]\end{align*} `] + + So [`f(a+h)-f(a)= [$fdqNumer] `]. + +d. + + [`\begin{align*} \displaystyle \frac{f(a+h) - f(a)}{h} &\quad\longrightarrow\quad & +\frac{[$fdqNumer]}{h} \\ +&\quad\longrightarrow\quad & \frac{h([$fdq])}{h} \\ +&\quad\longrightarrow\quad & [$fdq] \end{align*}`] + + So [`\dfrac{f(a+h) - f(a)}{h} = [$fdq] `]. + +END_PGML_SOLUTION + + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Equations/comp-bases-lin-exp-intro.pg b/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Equations/comp-bases-lin-exp-intro.pg new file mode 100644 index 0000000000..29f477f4ba --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Equations/comp-bases-lin-exp-intro.pg @@ -0,0 +1,133 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'exponents', 'logarithm', 'logarithms', 'laws of logarithms') + +## DBsubject('Algebra') +## DBchapter('Exponential and logarithmic expressions and functions') +## DBsection('Exponential and logarithmic equations') +## Date('6/16/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.0005); + +# B^(ax+b) = (B^2)^(cx+d) +# a x + b = 2c x + 2d +# (a - 2c) x = 2d - b +# x = (2d - b) / (a - 2c) + +#$coeff = random(2,9,1); +$baseB = list_random(2,3,5,7); +$baseB2 = $baseB**2; + +$a = random(3,8,1); +$c=1; +#do { $c = random(2,8,1); } until ( $a != 2*$c ); + +$b=0; +#$b = non_zero_random(-9,9,1); +$d = non_zero_random(-9,9,1); + +$ans = Fraction("(2*$d-$b)/($a-2*$c)")->reduce; + +$lhs = Formula("$baseB^($a x + $b)")->reduce; +$rhs = Formula("$baseB2^($c x + $d)")->reduce; + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Exponential Equations with Common Base ### << + +Solve for [`x`]: [`\quad 6^{5x}=36^{x-7}`] + +Note that the equation can be rewritten in the same base [`6`] as [`6^{5x}=(6^2)^{x-7}`], or + +[```6^{5x}=6^{2(x-7)}```] + +Since the exponential function is one-to-one, the exponents have to be equal to each other. We obtain: + +[```5x=2(x-7) \quad \implies 5x=2x-14\quad \implies 3x=-14 \quad \implies x=-\frac {14}{3}```] + +>> ### Practice ### << + + +Solve for [`x`]: [` \quad[$lhs] = [$rhs]. `] + +[`x =`] [________________________________]{$ans} + + + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + + + + +END_PGML_HINT + +############################################################## +# +# Solution +# +# + + + +BEGIN_PGML_SOLUTION + + +END_PGML_SOLUTION + + + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Growth_and_Decay b/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Growth_and_Decay new file mode 120000 index 0000000000..d4b9ccda96 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setExponential_Functions_-_Growth_and_Decay @@ -0,0 +1 @@ +/opt/webwork/libraries/webwork-open-problem-library/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/ExponentialEquations-Calc/ \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setFunctionNotation/function-range.pg b/Contrib/CUNY/CityTech/Precalculus/setFunctionNotation/function-range.pg index cd08a78640..6c0b277a96 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setFunctionNotation/function-range.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setFunctionNotation/function-range.pg @@ -167,7 +167,7 @@ BEGIN_TEXT ['\(f(x)=$f\)','\(g(x)=$g\)','\(h(x)=$h\)'], ['The range of \(f(x)\) is $BR' . ans_rule(20),'The range of \(g(x)\) is $BR' . ans_rule(20),'The range of \(h(x)\) is $BR' . ans_rule(20)] ], - align => 'c c c', + align => 'cc', center => 1, );\} END_TEXT diff --git a/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/even-odd-neither-explicit-ggb.pg b/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/even-odd-neither-explicit-ggb.pg index d846d7d113..9066f4e1c6 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/even-odd-neither-explicit-ggb.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/even-odd-neither-explicit-ggb.pg @@ -199,7 +199,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>'geogebraweb code', HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>0, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/intro-even-vs-odd.pg b/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/intro-even-vs-odd.pg index d846d7d113..9066f4e1c6 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/intro-even-vs-odd.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setFunctions_-_Symmetries/intro-even-vs-odd.pg @@ -199,7 +199,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>'geogebraweb code', HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>0, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots-2.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots-2.pg new file mode 100644 index 0000000000..f3874ca49c --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots-2.pg @@ -0,0 +1,180 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Polynomial equations and functions') +## DBsection('Zeros and multiplicities') +## Date('6/18/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "PGchoicemacros.pl", + "parserPopUp.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->parens->set("("=>{type=>"Point"}); +parser::Assignment->Allow; +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.005); + + +$randm= random(1,8,1); + +if ( $randm == 1 ) { + $f = Formula(" x^4 -4 x^3+ 3 x^2+2x-1"); + $roots = List(Point("(-.618,0)"),Point("(.382,0)"), + Point("(1.618,0)"),Point("(2.618,0)")); + $max = Point("(1,1)"); + $min = List(Point("(-.225,-1.25)"),Point("(2.225,-1.25)")); +} elsif ( $randm == 2 ) { + $f = Formula(" x^4 -4 x^3- 3 x^2+2x+1"); + $roots = List(Point("(-.82,0)"),Point("(-.401,0)"), + Point("(.669,0)"),Point("(4.552,0)")); + $max = Point("(.233,1.255)"); + $min = List(Point("(-.631,-.293)"),Point("(3.398,-50.462)")); +} elsif ( $randm == 3 ) { + $f = Formula(" x^4 +4 x^3- 3 x^2-6x+1"); + $roots = List(Point("(-4.36,0)"),Point("(-1.111,0)"), + Point("(.157,0)"),Point("(1.314,0)")); + $max = Point("(-.533,2.821)"); + $min = List(Point("(-3.316,-37.032)"),Point("(.849,-3.289)")); +} elsif ( $randm == 4 ) { + $f = Formula(" x^4 +2 x^3- 3 x^2-6x-1"); + $roots = List(Point("(-2.228,0)"),Point("(-1.36,0)"), + Point("(-.186,0)"),Point("(1.775,0)")); + $max = Point("(-.727,1.287)"); + $min = List(Point("(-1.873,-1.121)"),Point("(1.101,-7.104)")); +} elsif ( $randm == 5 ) { + $f = Formula(" -x^4 +2 x^3+4 x^2-6x-1"); + $roots = List(Point("(-1.826,0)"),Point("(-.152,0)"), + Point("(1.386,0)"),Point("(2.593,0)")); + $max = List(Point("(-1.202,6.43)"),Point("(2.111,3.115)")); + $min = Point("(.591,-2.858)"); +} elsif ( $randm == 6 ) { + $f = Formula(" -x^4 +2 x^3+3 x^2-5x-1"); + $roots = List(Point("(-1.596,0)"),Point("(-.183,0)"), + Point("(1.516,0)"),Point("(2.263,0)")); + $max = List(Point("(-1.053,4.027)"),Point("(1.941,1.029)")); + $min = Point("(.612,-2.618)"); +} elsif ( $randm == 7 ) { + $f = Formula(" -x^4 + x^3+5 x^2-5x-1"); + $roots = List(Point("(-2.204,0)"),Point("(-.172,0)"), + Point("(1.233,0)"),Point("(2.143,0)")); + $max = List(Point("(-1.49,9.314)"),Point("(1.765,1.545)")); + $min = Point("(.475,-2.191)"); +} else { + $f = Formula(" -x^4 +5 x^3+5 x^2-5x-2"); + $roots = List(Point("(-1.239,0)"),Point("(-.33,0)"), + Point("(.857,0)"),Point("(5.711,0)")); + $max = List(Point("(-.858,2.271)"),Point("(4.267,124.649)")); + $min = Point("(.341,-2.939)"); +}; + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> #### Practice #### << + +Consider the function [`f(x) = [$f]`]. + +Use a graphing calculator to find the local maxima, local minima, and roots. Approximate your answer to the nearest hundredth. + + +a. The local maxima are [`(x,y)\approx`][_____]{$max}. + +b. The local minima are [`(x,y)\approx`][_______________]{$min}. + +c. The roots are at [`(x,y)\approx`][__________]{$roots}. + +* Enter the maxima, minima, and the roots as [`(x,y)`]-coordinates. + +* Separate multiple answer by commas. + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + +* Graph the function. + +* Search for local peaks and local valeys of the graph. + +* Change your graphing window if necessary. + +* The graph has four [`x`]-intercepts. + + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + +BEGIN_PGML_SOLUTION + + +END_PGML_SOLUTION + + + + + + + +# Custom error messages? +# "There should be more formulas in your list" -> "You're missing factors" +# "There should be more numbers in your list" -> "You're missing roots" + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots.pg new file mode 100644 index 0000000000..1ea47c2013 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/max-min-roots.pg @@ -0,0 +1,207 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Polynomial equations and functions') +## DBsection('Zeros and multiplicities') +## Date('6/18/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "PGchoicemacros.pl", + "parserPopUp.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->parens->set("("=>{type=>"Point"}); +parser::Assignment->Allow; +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, + tolType=>'absolute', + tolerance=>0.0005); + + +# f(x)=(x^2+bx+c)(px+q)=fA x^3+fB x^2+fC x+fD +$pp=random(2,4,1); +do{ $qq=random(-1,1,2)*random(1,9,2); } +until ($pp/$qq!=floor($pp/$qq)); + +$bb=random(-1,1,2)*random(3,7,1); +do{ +do{ $cc=random(1,9,2); $discrim=$bb*$bb-4*$cc;} +until ($discrim>0); +} until (sqrt($discrim)!=floor(sqrt($discrim))); + +$fA = $pp; +$fB = $qq+$bb*$pp; +$fC = $bb*$qq+$cc*$pp; +$fD = $cc*$qq; + +$f = Formula("$fA x^3 + $fB x^2+ $fC x+$fD")->reduce; + + +$rr1=-$qq/$pp; +$rr2=(-$bb+sqrt($bb*$bb-4*$cc))/2; +$rr3=(-$bb-sqrt($bb*$bb-4*$cc))/2; +$roots = List(Point("($rr1,0)"), + Point("($rr2,0)"), + Point("($rr3,0)")); +$maxX=(-2*$fB-sqrt(4*$fB*$fB-12*$fA*$fC))/(6*$fA); +$maxY=$fA*$maxX*$maxX*$maxX+$fB*$maxX*$maxX+$fC*$maxX+$fD; +$max = Point("($maxX,$maxY)"); + +$minX=(-2*$fB+sqrt(4*$fB*$fB-12*$fA*$fC))/(6*$fA); +$minY=$fA*$minX*$minX*$minX+$fB*$minX*$minX+$fC*$minX+$fD; +$min = Point("($minX,$minY)"); + + + +$graph_object1 = init_graph(-5,-5,5,5,axes=>[0,0],size=>[300,300],grid=>[10,10]); +add_functions($graph_object1,"(3x-7)*(2x+5)*(2*x^2-2*x-1)/35 for x in <-5,5> using color:blue and weight: 2"); + +$graph_object1->stamps( closed_circle( 0.431, 1.425, 'red') ); +$graph_object1->lb( new Label( 0.431, 1.6, "local max", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( -1.731, -4.53, 'green') ); +$graph_object1->lb( new Label( -1.731, -4.9, "local min", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( 1.925, -0.793, 'green') ); +$graph_object1->lb( new Label( 1.925, -1.2, "local min", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( -2.5, 0, 'yellow') ); +$graph_object1->lb( new Label( -2.5, .3, "root", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( -0.366, 0, 'yellow') ); +$graph_object1->lb( new Label( -0.366, .3, "root", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( 1.366, 0, 'yellow') ); +$graph_object1->lb( new Label( 1.366, .3, "root", 'black', 'center', 'bottom' ) ); + +$graph_object1->stamps( closed_circle( 2.333, 0, 'yellow') ); +$graph_object1->lb( new Label( 2.333, .3, "root", 'black', 'center', 'bottom' ) ); + + + +############################################################## +# +# Text +# +# + +BEGIN_PGML +>> ### Local Maxima, Minima, Roots with the Graphing Calculator ### << + +A *local maximum* of a function [`f`] is a point on the graph of [`f`] so that no "nearby" point is above that point. + +Similarly, a *local minimum* of a function [`f`] is a point on the graph of [`f`] so that no "nearby" point is below that point. + +Below is a graph with one local maximum graphed in red, and two local minima graphed in green. +(Note: The plural of "maximum" is "maxima", the plural of "minimum" is "minima"; hence the graph below has "one maximum" and "two minima".) A point that is either a maximum or a minimum is also called an *extremum*. + +The graph of [`f`] also has four [`x`]-intercepts. The [`x`]-intercepts are also called *roots* or *zeros* of [`f`]. The roots were graphed in yellow. + +>> [@image(insertGraph($graph_object1), width=>400, height=>400, tex_size=>400)@]* << + +The coordinates of the local maxima and minima are approximately (to the nearest tenth): + +* Local maximum: [`(x,y)\approx(0.4, 1.4)`] + +* Local minima: [`(x,y)\approx(-1.7, -4.5)`], and [`(1.9, -0.8)`] + +* Roots: [`(x,y)\approx(-2.5, 0)`], and [`(-0.4, 0)`], and [`(1.4, 0)`], and [`(2.3, 0)`] + +>> #### Practice #### << + +Consider the function [`f(x) = [$f]`]. + +Use a graphing calculator to find the local maximum, local minimum, and roots. Approximate your answer to the nearest thousandth. + + +a. The local maximum is [`(x,y)\approx`][_____]{$max}. + +b. The local minimum is [`(x,y)\approx`][_______________]{$min}. + +c. The roots are at [`(x,y)\approx`][__________]{$roots}. + +* Enter the local maximum, the local minimum, and the roots as [`(x,y)`]-coordinates. + +* Separate multiple answer by commas. + + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + +* Graph the function. + +* Search for a local peak and a local valey of the graph. + +* Change your graphing window if necessary. + +* The graph has three [`x`]-intercepts. + + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + +BEGIN_PGML_SOLUTION + + +END_PGML_SOLUTION + + + + + + + +# Custom error messages? +# "There should be more formulas in your list" -> "You're missing factors" +# "There should be more numbers in your list" -> "You're missing roots" + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/vertical-line-test.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/vertical-line-test.pg new file mode 100644 index 0000000000..26a6a4e7eb --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphingCalculator/vertical-line-test.pg @@ -0,0 +1,208 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Polynomial equations and functions') +## DBsection('Zeros and multiplicities') +## Date('6/18/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "PGgraphmacros.pl", + "PGchoicemacros.pl", + "niceTables.pl", + "parserPopUp.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->variables->add(y => 'Real'); + +#@C = NchooseK(4,4); +#@C = map { $_ + 1 } @C; + +$aa = random(2,6,1); +$bb = random(2,6,1); +$cc = random(2,7,1); +$dd = random(2,7,1); +$ee = random(2,15,1); +$ff = random(2,5,1); +$gg = random(2,6,1); +$hh = random(2,7,1); +$ii = random(3,7,1); +$jj = random(2,3,1); +$pp = random(2,4,1); +$qq = random(2,5,1); + +@f = ( + Formula("y^3-$bb y"), #1 + Formula("y^3+$aa y"), #2 + Formula("y"), #3 + Formula("y"), #4 + Formula("y"), #5 + Formula("y"), #6 + Formula("x^2+y^2"), #7 + Formula("(x-$pp)^2+(y-$qq)^2"), #8 + Formula("y^2"), #9 + Formula("y^2"), #10 + Formula("y^2"), #11 + Formula("y^3"), #12 +); + +@g = ( + Formula("x"), #1 + Formula("x"), #2 + Formula("x^3-$gg x^2+$hh x+$ii"), #3 + Formula("(-2)* sqrt(x^2+$dd x+$ee)"), #4 + Formula("(x-$ii)/(x-($ii+3))")->reduce, #5 + Formula("(x^2+$jj^2)/(x^2+($jj+1)^2)"), #6 + Formula("($cc+2)^2"),#7 + Formula("$cc^2"), #8 + Formula("x"), #9 + Formula("$ff^2"), #10 + Formula("x^2"), #11 + Formula("x"), #12 +); + +@ans = ( + 'not a function', #1 + 'a function', #2 + 'a function', #3 + 'a function', #4 + 'a function', #5 + 'a function', #6 + 'not a function', #7 + 'not a function', #8 + 'not a function', #9 + 'not a function', #10 + 'not a function', #11 + 'a function', #12 +); + +@opts = ('?', 'a function', 'not a function'); +@q = (); + +for my $i (0..11) { + $q[$i] = PopUp([@opts],$ans[$i]); +} + +@slice = NchooseK(12,5); + +@q=@q[@slice]; +@f=@f[@slice]; +@g=@g[@slice]; + +$graph_objectA = init_graph(-5,-5,5,5,axes=>[0,0],size=>[400,400],grid=>[10,10]); +add_functions($graph_objectA,"sqrt(x+3) for x in <-5,5> using color:blue and weight: 2"); +add_functions($graph_objectA,"-sqrt(x+3) for x in <-5,5> using color:blue and weight: 2"); + +$graph_objectA->stamps( closed_circle( 1.5, 2.121, 'red') ); +$graph_objectA->stamps( closed_circle( 1.5, -2.121, 'red') ); +$graph_objectA->moveTo(1.5,5); +$graph_objectA->lineTo(1.5,-5,'green'); + + +############################################################## +# +# Text +# +# + +BEGIN_PGML +>> ### Vertical line test ### << + +A function gives to each input [`x_0`] exactly one output [`y_0`], which is graphed on the vertical line at [`x_0`]. Therefore, the graph of a function can only have one point in common with a vertical line at [`x_0`]. + +Below is the graph of the equation [`y^2-x=3`]. + +Since the vertical line indicated in green intersects the graph in two points (drawn in red), this cannot be the graph of a function. + +>> [@image(insertGraph($graph_objectA), width=>400, height=>400, tex_size=>400)@]* << + +>> #### Practice #### << + +Graph each of the given equations below with a graphing calculator. + +Use the vertical line test to determine if this is the graph of a function or if this is not the graph of a function. + +a. [`\quad [$f[0]] = [$g[0]]\quad `] is [_]{$q[0]}. + +b. [`\quad [$f[1]] = [$g[1]]\quad `] is [_]{$q[1]}. + +c. [`\quad [$f[2]] = [$g[2]]\quad `] is [_]{$q[2]}. + +d. [`\quad [$f[3]] = [$g[3]]\quad `] is [_]{$q[3]}. + +e. [`\quad [$f[4]] = [$g[4]]\quad `] is [_]{$q[4]}. + + + + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + +* Graph the function. Check if there is a vertical line that intersects the graph in more than one point. + +* Change your graphing window if necessary. + + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + +BEGIN_PGML_SOLUTION + + +END_PGML_SOLUTION + + + + + + + +# Custom error messages? +# "There should be more formulas in your list" -> "You're missing factors" +# "There should be more numbers in your list" -> "You're missing roots" + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic-with-rational.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic-with-rational.pg new file mode 100644 index 0000000000..8e14890237 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic-with-rational.pg @@ -0,0 +1,68 @@ +DOCUMENT(); +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Fraction"); +Parser::Number::NoDecimals(); + +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, +); + +do{ + +do{$aa=random(2,4,1); + $bb=random(-1,1,2)*random(1,8,1); + $cc=random(-1,1,2)*random(1,7,1); + $discrim = $bb*$bb-4*$aa*$cc; + } +until (($bb*$bb-4*$aa*$cc>0)); + + $sr=Real(sqrt($discrim)); + $asr=floor($sr); +} until ($sr!=$asr); + +do{$ss=random(-1,1,2)*random(1,5,1);} +until ($aa*$ss^2+$bb*$ss+$cc!=0); + +# f(x)=(x+s)(ax^2+bx+c) = ax^3+(sa+b)x^2+(sb+c)x+sc +$pp=$ss*$aa+$bb; $qq=$ss*$bb+$cc; $rr=$ss*$cc; +$poly=Formula("$aa x^3+$pp x^2+$qq x+$rr")->reduce; + +$mss=-$ss; +$twoaa = 2*$aa; +$mbb = -$bb; +$answer = List(Formula("-$ss")->reduce, Formula("($mbb+sqrt($discrim))/$twoaa"), Formula("($mbb-sqrt($discrim))/$twoaa")); +$quot=Formula("$aa x^2+$bb x +$cc")->reduce; + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex + +#[`[$sr]`], [`[$asr]`], [`[$aa]`], [`[$bb]`], [`[$cc]`], [`s=[$ss]`] + +BEGIN_PGML + +Find all roots of the given polynomial. Do *not* approximate your solution! + +[```f(x)=[$poly]```] + +An integer root of [`f(x)`] is at [`x=`][__________]{$mss} + +The quotient [`f(x)\div (x-`]root[`)`] is equal to: [__________]{$quot} + +List all roots of [`f(x)`]: [`x=`][__________]{$answer} + + +* Separate multiple roots with commas. + + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic.pg new file mode 100644 index 0000000000..6af1314c25 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/find-roots-of-cubic.pg @@ -0,0 +1,88 @@ +DOCUMENT(); +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Fraction"); +Parser::Number::NoDecimals(); + +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, +); + +$pmsgn = random(-1,1,2); + +$aa=random(-1,1,2)*random(1,4,1); +do{$bb=$pmsgn*random(1,7,2); + $dd=random(2,4,2);} until ($dd*$aa-$bb!=0); +do{$cc=-1*$pmsgn*random(2,4,2); + $ee=random(3,5,2);} until ($ee*$aa-$cc!=0); + +# f(x)=(x+a)(dx+b)(ex+c) = dex^3+(ade+eb+dc)x^2+(abe+acd+bc)x+abc +$oo=$dd*$ee; $pp=$aa*$dd*$ee+$ee*$bb+$dd*$cc; +$qq=$aa*$bb*$ee+$aa*$cc*$dd+$bb*$cc; $rr=$aa*$bb*$cc; +$poly=Formula("$oo*x^3+$pp*x^2+$qq*x+$rr")->reduce; + +$maa=-$aa; +$mbb=-$bb; +$mcc=-$cc; +$answer = List(Formula("-$aa")->reduce, Formula("$mbb/$dd"), Formula("$mcc/$ee")->reduce); +$quotb=$dd*$cc+$bb*$ee; +$quotc=$bb*$cc; +$quot=Formula("$dd*$ee*x^2+$quotb*x+$quotc")->reduce; + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex + + +BEGIN_PGML + +>> ### Roots of a polynomial ### << + +Find the roots of the polynomial [`f(x)=6x^3+17x^2-31x-12`]. + +We follow the same steps that we used when finding the factors of [`f(x)`]. + +* *Step 1*: Find a *root* of [`f(x)`]. + +Using the graphing calculator, we identify one of the roots, here [`x=-4`] is a root. (*Check this!*) + +* *Step 2*: *Divide* [`f(x)`] by [`(x-`]root[`)`]. + +Using a *long-division*, we find that (*check this!*) +[```(6x^3+17x^2-31x-12)\div(x+4)=6x^2-7x-3```] +(Note that this has remainder [`0`] since [`-4`] is a root of [`f(x)`].) + +Therefore, [`6x^3+17x^2-31x-12=(x+4)\cdot(6x^2-7x-3)`]. + +* *Step 3*: Find the roots of the quotient, either by factoring or by using the quadratic formula. + +Factoring [`6x^2-7x-3=(2x-3)(3x+1)`] shows that the roots of [`f(x)`] are: +[```-4,\frac 3 2,-\frac 1 3```] + +When factoring does not work easily, one can alernatively use the quadratic formula: +[```ax^2+bx+c=0 \implies x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}```] + +>> #### Practice #### << + +Find all roots of the given polynomial. Do *not* use decimals in your answer! +[```f(x)=[$poly]```] + +An integer root of [`f(x)`] is at [`x=`][__________]{$maa} + +The quotient [`f(x)\div (x-`]root[`)`] is equal to: [__________]{$quot} + +List all roots of [`f(x)`]: [`x=`][__________]{$answer} + +* Separate multiple roots with commas. + + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-coeff.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-coeff.pg index 3b4753688b..90be3755bb 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-coeff.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-coeff.pg @@ -192,7 +192,7 @@ BEGIN_TEXT [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]], ], - align => 'c c', + align => 'cc', center => 1, ); \} END_TEXT diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-factored.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-factored.pg index 56e3df560c..83e3369492 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-factored.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-factored.pg @@ -160,7 +160,7 @@ BEGIN_TEXT [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); \} END_TEXT diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-mult.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-mult.pg index 4e9a2d1517..81b9641709 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-mult.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-mult.pg @@ -111,7 +111,7 @@ These functions are similar in the sense that they both have the same factors, [ [image(insertGraph($graph_object1), width=>200, height=>200, tex_size=>400), [image(insertGraph($graph_object2), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['f(x)',['g(x)',rowcss=>"padding:1pt;"]], ], - align => 'c c', + align => 'cc', center => 1, );@]* << @@ -148,7 +148,7 @@ BEGIN_TEXT [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]], ], - align => 'c c', + align => 'cc', center => 1, ); \} END_TEXT diff --git a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-polyn.pg b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-polyn.pg index 752024b559..fb0b2e6284 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-polyn.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setGraphs_of_Polynomials/graph-match-polyn.pg @@ -138,7 +138,7 @@ BEGIN_TEXT [image(insertGraph($fIm[2]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[3]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph C',['Graph D',rowcss=>"padding:1pt;"]], ], - align => 'c c', + align => 'cc', center => 1, ); \} END_TEXT diff --git a/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/function-intro.pg b/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/function-intro.pg new file mode 100644 index 0000000000..0a5735d7c7 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/function-intro.pg @@ -0,0 +1,209 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('function', 'input', 'output') + +## DBsubject('Algebra') +## DBchapter('Functions') +## DBsection('Definition, concept') +## Date('6/4/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') +## TitleText1('Precalculus') + + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->noreduce('(-x)-y'); +Context()->variables->add(a=>Real); + +$f1 = random(-1,1,2)*random(2,8,1); +$f2 = non_zero_random(-15,15,1); +$f = Formula("$f1 x + $f2")->reduce; + + +$g1 = random(2,5,1); +$g2 = non_zero_random(-8,8,1); +$g3 = non_zero_random(-15,15,1); +$g = Formula("$g1 x^2 + $g2 x + $g3")->reduce; + + +$ax = random(3,9,1); +$bx = random(-9,-2,1); +$cx = random(2,8,1); +$dx = random(-8,-2,1); + +$fax = $f->eval(x=>$ax); +$fbx = $f->eval(x=>$bx); +$gcx = $g->eval(x=>$cx); +$gdx = $g->eval(x=>$dx); +$ga = $g->substitute(x=>a); + +# Steps in the solution +$faxm = Formula("$f1 * $ax")-> reduce; +$fbxm = Formula("$f1 * $bx")-> reduce; +$gcxm2 = Formula("$g2 * $cx")-> reduce; +$gcxm1 = Formula("$g1 * ($cx)^2")-> reduce; +$gdxm2 = Formula("$g2 * $dx")-> reduce; +$gdxm1 = Formula("$g1 * ($dx)^2")-> reduce; + + + +Context("LimitedNumeric"); +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Addition is disabled for this problem. Simplify the sum and resubmit your answer."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Subtraction is disabled for this problem. Simplify the difference and resubmit your answer."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Multiplication is disabled for this problem. Simplify the product and resubmit your answer."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Division is disabled for this problem. Simplify the quotient and resubmit your answer."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Exponents are disabled for this problem. Compute the result for yourself and resubmit your answer."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Exponents are disabled for this problem. Compute the result for yourself and resubmit your answer."; + +$fax = Real($fax); +$fbx = Real($fbx); +$gcx = Real($gcx); +$gdx = Real($gdx); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Introduction to Functions ### << + +We usually define [`y`] (the _dependent_ variable) in terms of [`x`] (the _independent_ variable), like so: +>> [` y = 3x - 5 `] << + +It is understood that the value of [`y`] _depends_ on the value of [`x`]. Specifically, [`y`] is five less than the product of three and [`x`]. Here, [`x`] takes the role of "_input_" and [`y`] takes the role of "_output_". + +But what about when we have more than one definition for [`y`]? Maybe we'd like to consider [` y = x^2 + 3x + 4 `] in addition to having [` y = 3x - 5 `]. + +This is part of the reason for functional notation. Instead of using the dependent variable [`y`], we instead use the notation [`f(x)`]. This means we can describe multiple "functions" at the same time, like so: +>> [` f(x) = 3x - 5 `] << +>> [` g(x) = x^2 + 3x + 4 `] << + +Now, if we want to discuss the "_output_" when the "_input_" is [`2`] (in other words, when [`x=2`]), we can use the letters "[`f`]" or "[`g`]" to specify which equation we are intending to substitute [`x=2`] into. + +Functional notation also simplifies this idea of "plugging in [`x=2`]" as we don't need to say "find [`y`] when [`x=2`]" anymore. +Instead, writing [`f(2)`] expresses the same idea - specifically, we're taking [`f(x)`] and replacing [`x`] with [`2`], like so: +>> [`f(2) = 3(2) - 5 `] << + +Notice that it looks _exactly_ like [`f(x)`], except that all the [`x`]'s have been replaced with [`2`]'s. +Furthermore, we can simplify [`f(2) = 3(2) - 5`] as [`f(2) = 6 - 5`], and finally [`f(2) = 1`]. +In other words, the output of [`f(x)`] is [`1`] when the input is [`2`]. + +Doing the same for [`g(x)`], for example [`g(-1)`] means we want the _output_ of [`g(x)`] when [`x`] is replaced by [`-1`], like so: +>> [` g(-1) = (-1)^2 + 3(-1) + 4 `] << + +Again, we can simplify to see that [`g(-1) = 1 - 3 + 4`], so [`g(-1) = 2`]. In other words, the output of [`g(x)`] is [`2`] when the input is [`-1`]. + + +>> #### Practice #### << + + + +Use the functions [`f(x)= [$f]`] and [`g(x)= [$g]`] to evaluate the following: +a. [` f([$ax]) = `][_____________________________]{$fax} +b. [` f([$bx]) = `][_____________________________]{$fbx} +c. [` g([$cx]) = `][_____________________________]{$gcx} +d. [` g([$dx]) = `][_____________________________]{$gdx} +e. [` g(a) = `][_____________________________]{$ga} + +END_PGML + +############################################################## +# +# Answers +# +# + +############################################################## +# +# Hints +# +# + + + +BEGIN_PGML_HINT + +* Which *function* do you want to evaluate? + +* What is your *input*? + +* Take your function and replace *each [`x`]* by your input. + +* The result is your *output*. + +* Simplify your output, if necessary. + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + + + + + +BEGIN_PGML_SOLUTION + +a. We want to evaluate the function [`f(x)= [$f]`] for [`x=[$ax]`]. + + >>[` f([$ax]) \quad\longrightarrow\quad [$f1] ([$ax]) + [$f2] \quad\longrightarrow\quad [$faxm] + [$f2] \quad\longrightarrow\quad [$fax] `]<< + +b. We want to evaluate the function [`f(x)= [$f]`] for [`x=[$bx]`]. + + >>[` f([$bx]) \quad\longrightarrow\quad [$f1] ([$bx]) + [$f2] \quad\longrightarrow\quad [$fbxm] + [$f2] \quad\longrightarrow\quad [$fbx] `]<< + +c. We want to evaluate the function [`g(x)= [$g]`] for [`x=[$cx]`]. + + >>[` g([$cx]) \quad\longrightarrow\quad [$g1] ([$cx])^2 + [$g2] ([$cx]) + [$g3] \quad\longrightarrow\quad [$gcxm1] + ([$gcxm2]) + [$g3] \quad\longrightarrow\quad [$gcx] `]<< + +d. We want to evaluate the function [`g(x)= [$g]`] for [`x=[$dx]`]. + + >>[` g([$dx]) \quad\longrightarrow\quad [$g1] ([$dx])^2 + [$g2] ([$dx]) + [$g3] \quad\longrightarrow\quad [$gdxm1] + ([$gdxm2]) + [$g3] \quad\longrightarrow\quad [$gdx] `]<< + +e. We want to evaluate the function [`g(x)= [$g]`] for [`x=a`]. + + >>[` g(a) \quad\longrightarrow\quad [$ga] `]<< + + + + + + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/piecewise-function.pg b/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/piecewise-function.pg new file mode 100644 index 0000000000..0a979c0427 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setIntroductiontoFunctions/piecewise-function.pg @@ -0,0 +1,145 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('precalculus', '', '') + +## DBsubject('Precalculus') +## DBchapter('') +## DBsection('') +## Date('11/15/2019') +## Author('K. Andrew Parker') +## Institution('CUNY City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "PGchoicemacros.pl", + "contextPiecewiseFunction.pl", + "contextFraction.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# + +Context("Fraction"); +Context()->variables->add(m=>Real); +Context()->noreduce('(-x)-y','(-x)+y'); +Context()->strings->add('undefined'); + + $rndm = random(0,1,1); + +# make sure the middle interval is wide enough to support evaluation +# at an integer x-value (in case both endpoints are not included) +# and make sure that the "gaps" are wide enough for at least one +# x-value where the function is undefined... +do { + @x = NchooseK(11,4); + @x = PGsort( sub{$_[0]<$_[1]}, @x ); + @x = map { $_ - 5 } @x; +} until ($x[2]-$x[1] > 1) && ($x[3]-$x[2] > 1 || $x[1]-$x[0] > 1); + +# decide whether to include each x-value in the domain +for my $i (0..3) { + @inc[$i] = random(0,1,1); +} + +$int[0] = Interval("(-inf,$x[0])"); +$int[0] = $int[0] + Set("{$x[0]}") if $inc[0]; + +$int[1] = Interval("($x[1],$x[2])"); +$int[1] = $int[1] + Set("{$x[1]}") if $inc[1]; +$int[1] = $int[1] + Set("{$x[2]}") if $inc[2]; + +$int[2] = Interval("($x[3],inf)"); +$int[2] = $int[2] + Set("{$x[3]}") if $inc[3]; + +$domain = $int[0]+$int[1]+$int[2]; + +# select an x-value in each interval for evaluation +@a = (); +$a[0] = random(-10,$x[0]-1,1); +do { + $a[1] = random($x[1],$x[2],1); +} until $int[1]->contains(Set("{$a[1]}")); +$a[2] = random($x[3]+1,10,1); +# select one x-value outside of the domain +do { + $a[3] = random($x[0],$x[3],1); +} until !($domain->contains(Set("{$a[3]}"))); + +# Construct three lines, one for each interval +# evaluate line at corresponding x-value chosen above +@m = (); @b = (); @line = (); @y = (); +for my $i (0..2) { + $m[$i] = Fraction(non_zero_random(-5,5,1),random(1,5,1))->reduce; + $b[$i] = random(-8,8,1); + $line[$i] = Formula("m x + $b[$i]")->reduce; + $line[$i] = $line[$i]->substitute(m=>$m[$i]); + $line[$i] = $line[$i]->reduce if (abs($m[$i])==1); + $y[$i] = Fraction($line[$i]->eval(x=>$a[$i])); +} + +$y[3] = String("undefined")->with(typeMatch=>Fraction(1,1)); + +@shuffle = NchooseK(4,4); +@y = @y[@shuffle]; +@a = @a[@shuffle]; + +Context("PiecewiseFunction"); +Context()->flags->set(reduceConstants=>0); + +$f = PiecewiseFunction( + $int[0]=>$line[0], + $int[1]=>$line[1], + $int[2]=>$line[2])->with(final_period=>1); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +Given the piecewise equation: +>> [` y = [$f] `] << + +Evaluate [`f(a)`] for each of the following: + a. [`f([$a[0]])`] = [_________]{$y[0]} + a. [`f([$a[1]])`] = [_________]{$y[1]} + a. [`f([$a[2]])`] = [_________]{$y[2]} + a. [`f([$a[3]])`] = [_________]{$y[3]} + +*Notes:* +* If any of the [`f(a)`] are not defined, then enter "undefined" as your answer. + +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT +END_PGML_HINT + +BEGIN_PGML_SOLUTION +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setInverse_Functions/compute-inverse-rational-dbl2.pg b/Contrib/CUNY/CityTech/Precalculus/setInverse_Functions/compute-inverse-rational-dbl2.pg new file mode 100644 index 0000000000..a5db614c47 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setInverse_Functions/compute-inverse-rational-dbl2.pg @@ -0,0 +1,112 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Inverse functions') +## DBsection('Finding the inverse function') +## Date('6/18/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set(reduceConstants=>0, reduceConstantFunctions=>0); +Context()->noreduce('(-x)-y'); + +$rndmm = random(6,78,2); + +do { + $M = random(2,9,1); + $N = non_zero_random(-10,10,1); + + $B = random(2,9,1); + $C = non_zero_random(-9,9,1); +} until ( gcf( gcf($M,$N), gcf($B,$C) ) == 1 && $M != $B ); + +$f = Formula("($M x - $N)/($B x - $C)")->reduce; + +# x(By - C) = M y - N +# Bxy - My = Cx - N +$fInv = Formula("($C x - $N)/($B x - $M)")->reduce; + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Computing Inverse Functions ### << + + +If [` \displaystyle f(x) = [$f] `], find the inverse function. + +[` f^{-1}(x) = `] [_____________________]{$fInv} + +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Since we are given the function [` y = \displaystyle[$f] `], start by swapping [`x`] and [`y`], which yields: + +>>[` x = \dfrac{[$M]y - [$N] }{[$B] y - [$C]}. `]<< + +Now solve for [`y`] in terms of [`x`]. Start by clearing the denominator; then collect all the [` y `]-terms on one side of the equation and factor out [` y `]. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +Since we are given the function [` y = \displaystyle[$f] `], we start by swapping [`x`] and [`y`], which yields: + +>>[` x = \dfrac{[$M]y - [$N] }{[$B] y - [$C]}. `]<< + +Now we solve for [`y`] in terms of [`x`]: + +>>[` \begin{align*} +x([$B] y - [$C]) &= [$M]y - [$N] \\ + [$B] xy - [$C]x &= [$M]y - [$N] \\ +[$B] xy - [$M]y &= [$C]x - [$N] \\ + y([$B] x - [$M]) &= [$C]x - [$N] \\ + y &= \dfrac{[$C]x - [$N]}{[$B] x - [$M]} + \end{align*}`]<< + +Thus, + +[` f^{-1}(x) = \displaystyle[$fInv] `]. + +END_PGML_SOLUTION + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/ln-domains.pg b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/ln-domains.pg index 601a05d677..f73659e0ad 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/ln-domains.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/ln-domains.pg @@ -74,7 +74,7 @@ $adjustError = sub { return $ans; }; -$logDom = Compute("(-inf,$va)"); +$logDom = $a > 0 ? Compute("($va,inf)") : Compute("(-inf,$va)"); ############################################################## # diff --git a/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/shifting-logs.pg b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/shifting-logs.pg index 07dedb1d16..25658951c3 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/shifting-logs.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Graphs/shifting-logs.pg @@ -249,7 +249,7 @@ $logInt = Point("($int,0)"); TEXT($PAR, MODES(TeX=>'geogebraweb code', HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Properties b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Properties new file mode 120000 index 0000000000..665656848e --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setLogarithmic_Functions_-_Properties @@ -0,0 +1 @@ +/opt/webwork/libraries/webwork-open-problem-library/Contrib/CUNY/CityTech/CollegeAlgebra_Trig/LogarithmicProperties/ \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setOperationsonFunctions/functions-composition-domain-sqrt-linear.pg b/Contrib/CUNY/CityTech/Precalculus/setOperationsonFunctions/functions-composition-domain-sqrt-linear.pg new file mode 100644 index 0000000000..e45883eedd --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setOperationsonFunctions/functions-composition-domain-sqrt-linear.pg @@ -0,0 +1,155 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'function', 'input', 'output', 'domain', 'rational function', 'radical function', 'operations') + +## DBsubject('Algebra') +## DBchapter('Functions') +## DBsection('Compositions and combinations of functions') +## Date('6/4/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') +## TitleText1('Precalculus') + + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextRationalFunction.pl", + "contextFraction.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +# Set everything up in "Numeric" context +Context("Fraction"); +Context()->noreduce('(-x)-y'); + +@word = ("zero","one","two","three","four","five","six","seven","eight","nine","ten"); + +$fB = random(2,5,1); +# determine what we want the quadratic radicand to look like _first_ +do { $fogRootNumer = random(3,8,1); } until (gcf($fB,$fogRootNumer) != $fB); +$DoS = $fogRootNumer**2; +# break up the constant value from the composition (f o g) +do { $gC = random(-1*$DoS+1,-3,1); } until ( gcf($fB, abs($gC)) == $fB ); +$fC = $DoS-abs($gC); +$gC = $gC/$fB; +$fB = -$fB; +$f = Formula("sqrt($fB x + $fC)")->reduce; +$fRoot = Fraction(-$fC,$fB)->reduce; + +$gA = 0; #abs($fB); #TT: no quadratic term... +$gB = -1*random(2,5,1); +# the remainder from splitting the constant value of the composition +#$gC = abs($fC)-$DoS; +$g = Formula("($gB x + $gC)")->reduce; + +# define the compositions as already simplified +$gOffX = Formula("$gB*sqrt($fB x + $fC)+$gC")->reduce; +$fOfgX = Formula("sqrt(($fB)*($gB) x+($fB*$gC+$fC))")->reduce; + +$fOfgRoot1 = Fraction(-1*($fB*$gC+$fC),$fB*$gB)->reduce; +$fOfgRoot2 = 3; #Fraction($fogRootNumer,$gA)->reduce; + +Context("Interval"); + +$fOfgDom = Compute("[$fOfgRoot1,inf)"); +$gOffDom = Compute("(-inf, $fRoot]"); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Composition of Functions ### << + + + + + +>> #### Practice #### << + +Let [` f(x) = [$f] `] and [` \displaystyle g(x) = [$g] `]. + +* You must combine all like terms before you submit your answer. +* You must expand all products before your submit your answer. +* Use _sqrt_ for the square root. + +a. Simplify: [` (g \circ f)(x) = `][_____________________________]{$gOffX} + +b. What is the domain of [` (g \circ f)(x) `]? [_____________________________]{$gOffDom} + +d. Simplify: [` (f \circ g)(x) = `][_____________________________]{$fOfgX} + +d. What is the domain of [` (f \circ g)(x) `]? [_____________________________]{$fOfgDom} + + +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +**To find the composition** + +* What is the _function_ you want to evaluate? +* What is the _input_? +* Plug the _input_ into the _function_. + +**To find the domain of a composition** + +* Find all [`x`]'s for which you can calculate the _input_. +* Find all [`x`]'s for which the _input_ belongs to the domain of the _function_. +* Find all [`x`]'s satisfying each one of the above restrictions. +* Do not use your algebraic simplication for the composition to find its domain. + + +END_PGML_HINT + +############################################################## +# +# Solutions +# +# + +$gevalf = ($gB == 0)? "$gA (f(x))^2 + $gC" : +"$gA(f(x))^2 + $gB (f(x)) + $gC"; + +$geval = Formula("$gA ($f)^2 + $gB ($f) + $gC")->reduce; + +$ineq = ($fB >0)? "\geq" : "\leq"; + +$fDom = ($fB>0)? Compute("[$fRoot,inf)") : Compute("(-inf,$fRoot]") ; + + +BEGIN_PGML_SOLUTION + + +END_PGML_SOLUTION + + + +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic-with-rational.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic-with-rational.pg new file mode 100644 index 0000000000..d176ea0c60 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic-with-rational.pg @@ -0,0 +1,97 @@ +DOCUMENT(); +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Fraction"); +Parser::Number::NoDecimals(); + +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, +); + +do{ + +do{$bb=random(-1,1,2)*random(1,8,1); + $cc=random(-1,1,2)*random(1,7,1); + $discrim = $bb*$bb-4*$cc; + } +until (($bb*$bb-4*$cc>0)); + + $sr=Real(sqrt($discrim)); + $asr=floor($sr); +} until ($sr!=$asr); +#} until (1!=0); + +do{$aa=random(-1,1,2)*random(1,5,1);} +until ($aa^2+$bb*$aa+$cc!=0); + +# f(x)=(x+a)(x^2+bx+c) = x^3+(a+b)x^2+(ab+c)x+ac +$pp=$aa+$bb; $qq=$aa*$bb+$cc; $rr=$aa*$cc; +$poly=Formula("x^3+$pp*x^2+$qq*x+$rr")->reduce; + +$maa = -$aa; +$mbb = -$bb; +$answer = List(Formula("x+$aa")->reduce, Formula("x-($mbb+sqrt($discrim))/2"), Formula("x-($mbb-sqrt($discrim))/2")); +$quot = Formula("x^2+$bb*x+$cc")->reduce; + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex + +#[`[$sr]`], [`[$asr]`], [`[$aa]`], [`[$bb]`], [`[$cc]`] + +BEGIN_PGML + + +>> ### Factors of a polynomial, including irrational roots ### << + +Find the factors of the polynomial [`f(x)=x^3+4x^2-2x-5`]. + +* *Step 1*: Find a *root* of [`f(x)`]. + +Using the graphing calculator, we find the root [`x=-1`]. + +(Note that the other two roots have decimal expressions!) + +* *Step 2*: *Divide* [`f(x)`] by [`(x-`]root[`)`]. + +Using a *long-division*, we find that (*check this!*) +[```(x^3-3x^2-10x+24)\div(x+1)=x^2+3x-5```] +(Note that this has remainder [`0`] since [`-1`] is a root of [`f(x)`].) + +Therefore, [`(x^3-3x^2-10x+24)=(x+1)\cdot (x^2+3x-5)`]. + +* *Step 3*: Keep *factoring* the quotient. + +Since [`x^2+3x-5`] cannot be factored in an obvious way, we use the qudratic formula: +[```ax^2+bx+c=0 \implies x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}```] +We obtain: +[``` x^2+3x-5=0 \implies x=\frac{-3\pm\sqrt{3^2-4\cdot 1\cdot (-5)}}{2}=\frac{-3\pm\sqrt{29}}{2}```] +Therefore, [`f(x)=(x+1)\cdot (x-\frac{-3+\sqrt{29}}{2})\cdot (x-\frac{-3-\sqrt{29}}{2})`] and the factors of [`f(x)`] are: +[```x+1,x-\frac{-3+\sqrt{29}}{2},x-\frac{-3-\sqrt{29}}{2}```] + +>> #### Practice #### << + +Find all factors of the given polynomial. Do *not* approximate your solution! + +[```f(x)=[$poly]```] + +An integer root of [`f(x)`] is at [`x=`][__________]{$maa} + +The quotient [`f(x)\div (x-`]root[`)`] is equal to: [__________]{$quot} + +List all factors of [`f(x)`]: [__________]{$answer} + + +* Separate multiple factors with commas. + + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic.pg new file mode 100644 index 0000000000..42d8e25bb4 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/find-factors-of-cubic.pg @@ -0,0 +1,61 @@ +DOCUMENT(); +loadMacros("PGstandard.pl","PGML.pl"); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Numeric"); + +$aa=random(-1,1,2)*random(1,5,1); +do{$bb=random(-1,1,2)*random(1,5,1);} until ($aa-$bb!=0); +do{$cc=random(-1,1,2)*random(1,5,1);} until (($aa-$cc)*($bb-$cc)!=0); + +# f(x)=(x+a)(x+b)(x+c) = x^3+(a+b+c)x^2+(ab+ac+bc)x+abc +$pp=$aa+$bb+$cc; $qq=$aa*$bb+$aa*$cc+$bb*$cc; $rr=$aa*$bb*$cc; +$poly=Formula("x^3+$pp*x^2+$qq*x+$rr")->reduce; + +$answer = List(Formula("x+$aa")->reduce, Formula("x+$bb")->reduce, Formula("x+$cc")->reduce); + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex + + +BEGIN_PGML + +>> ### Factors of a polynomial ### << + +Find the factors of the polynomial [`f(x)=x^3-3x^2-10x+24`]. + +* *Step 1*: Find a *root* of [`f(x)`]. + +Using the graphing calculator, we pick one of the roots, say, for example, [`x=2`]. + +(Any other root you can find can be used in a similar way!) + +* *Step 2*: *Divide* [`f(x)`] by [`(x-`]root[`)`]. + +Using a *long-division*, we find that (*check this!*) +[```(x^3-3x^2-10x+24)\div(x-2)=x^2-x-12```] +(Note that this has remainder [`0`] since [`2`] is a root of [`f(x)`].) + +Therefore, [`x^3-3x^2-10x+24=(x-2)\cdot (x^2-x-12)`]. + +* *Step 3*: Keep *factoring* the quotient. + +Factoring [`x^2-x-12=(x+3)(x-4)`] shows that +[```x^3-3x^2-10x+24=(x-2)\cdot (x+3)\cdot (x-4)```] +The factors of [`f(x)`] are therefore: +[```x-2,x+3,x-4```] + +>> #### Practice #### << + +Find all factors of the given polynomial. +[```f(x)=[$poly]```] + +List all factors of [`f(x)`]: [__________]{$answer} + +* Separate multiple factors with commas. + + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/intro-long-division.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/intro-long-division.pg index ff9051f84a..d418fe86bf 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/intro-long-division.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/intro-long-division.pg @@ -102,7 +102,7 @@ LayoutTable( ["x-8",["2 x^3",cellcss=>'border-top:2px solid blue; border-left:2px solid blue;'],["-11 x^2",cellcss=>'border-top:2px solid blue;'],["-41 x",cellcss=>'border-top:2px solid blue;'],["+8",cellcss=>'border-top:2px solid blue;']], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -136,7 +136,7 @@ LayoutTable( ['','0',["5 x^2",cellcss=>'color:brown; '],"-41 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -168,7 +168,7 @@ LayoutTable( ['','','0',["- x",cellcss=>'color:green;'],"+8"], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -204,7 +204,7 @@ LayoutTable( ['','','',["0",cellcss=>'color:red;'],["0",cellcss=>'color:red;']] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -259,7 +259,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -304,7 +304,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -350,7 +350,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -438,7 +438,7 @@ LayoutTable( ['','0',"$q[1] x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -471,7 +471,7 @@ LayoutTable( ['','','0',"$q[0] x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -508,7 +508,7 @@ LayoutTable( ['','','','0','0'] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-monic-linear-rem.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-monic-linear-rem.pg index c7c6963fd7..296582a0b8 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-monic-linear-rem.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-monic-linear-rem.pg @@ -112,7 +112,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -154,7 +154,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -198,7 +198,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -305,7 +305,7 @@ LayoutTable( ['','0',"$rem2 x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -338,7 +338,7 @@ LayoutTable( ['','','0',"$rem1 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -375,7 +375,7 @@ LayoutTable( ['','','','0',"$rem0"] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear-rem.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear-rem.pg index 557c162fca..100ab0ecde 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear-rem.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear-rem.pg @@ -112,7 +112,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -154,7 +154,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -198,7 +198,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -305,7 +305,7 @@ LayoutTable( ['','0',"$rem2 x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -338,7 +338,7 @@ LayoutTable( ['','','0',"$rem1 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -375,7 +375,7 @@ LayoutTable( ['','','','0',"$rem0"] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear.pg index 499f81826a..168ef7b034 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-neg-nonmonic-linear.pg @@ -112,7 +112,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -154,7 +154,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -198,7 +198,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -305,7 +305,7 @@ LayoutTable( ['','0',"$rem2 x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -338,7 +338,7 @@ LayoutTable( ['','','0',"$rem1 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -375,7 +375,7 @@ LayoutTable( ['','','','0','0'] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear-rem.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear-rem.pg index 25c8f2546a..4c77d8a030 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear-rem.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear-rem.pg @@ -112,7 +112,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -154,7 +154,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -198,7 +198,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -305,7 +305,7 @@ LayoutTable( ['','0',"$rem2 x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -338,7 +338,7 @@ LayoutTable( ['','','0',"$rem1 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -375,7 +375,7 @@ LayoutTable( ['','','','0',"$rem0"] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear.pg index 689a2e16ef..09dbe2a277 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Division/long-division-nonmonic-linear.pg @@ -112,7 +112,7 @@ LayoutTable( ['','0',[ $part1Ans->ans_rule(5),noencase=>1],'',''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -154,7 +154,7 @@ LayoutTable( ['','','0',[ $part2Ans->ans_rule(5),noencase=>1],''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -198,7 +198,7 @@ LayoutTable( ['','','','0',[ $part3Ans->ans_rule(5),noencase=>1]] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], ); @]*** @@ -305,7 +305,7 @@ LayoutTable( ['','0',"$rem2 x^2","",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -338,7 +338,7 @@ LayoutTable( ['','','0',"$rem1 x",''], ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** @@ -375,7 +375,7 @@ LayoutTable( ['','','','0','0'] ], midrules=>0, - align=>' c c c c c ', + align=>'ccccc', encase=>['\(','\)'], )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Theory/factor-cubic-complex-roots.pg b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Theory/factor-cubic-complex-roots.pg new file mode 100644 index 0000000000..ea224ffa01 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setPolynomial_Theory/factor-cubic-complex-roots.pg @@ -0,0 +1,78 @@ +DOCUMENT(); +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextLimitedComplex.pl", + "PGchoicemacros.pl", + "contextFraction.pl" +); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Complex"); +Parser::Number::NoDecimals(); + +Context()->variables->add(x => 'Real'); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, +); + +do{ + +do{$bb=random(-1,1,2)*random(1,8,1); + $cc=random(-1,1,2)*random(1,7,1); + $discrim = $bb*$bb-4*$cc; + } +until (($bb*$bb-4*$cc<0)); + + $sr=Real(sqrt(-$discrim)); + $asr=floor($sr); +} until ($sr!=$asr); +#} until (1!=0); + +do{$aa=random(-1,1,2)*random(1,5,1);} +until ($aa^2+$bb*$aa+$cc!=0); + +# f(x)=(x+a)(x^2+bx+c) = x^3+(a+b)x^2+(ab+c)x+ac +$pp=$aa+$bb; $qq=$aa*$bb+$cc; $rr=$aa*$cc; +$poly=Formula("x^3+$pp*x^2+$qq*x+$rr")->reduce; + +$maa = -$aa; +$mbb = -$bb; +$mdiscrim=-$discrim; +$answer = List(Formula("x+$aa")->reduce, Formula("x-($mbb+i*sqrt($mdiscrim))/2"), Formula("x-($mbb-i*sqrt($mdiscrim))/2")); +$quot = Formula("x^2+$bb*x+$cc")->reduce; +$answerRoot = List(Formula("$maa"), Formula("($mbb+i*sqrt($mdiscrim))/2"), Formula("($mbb-i*sqrt($mdiscrim))/2")); + + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex + +#[`[$sr]`], [`[$asr]`], [`[$aa]`], [`[$bb]`], [`[$cc]`] + +BEGIN_PGML + + + +Find all factors of the given polynomial. Do *not* approximate your solution! + +[```f(x)=[$poly]```] + +An integer root of [`f(x)`] is at [`x=`][__________]{$maa} + +The quotient of [`f(x)\div (x-`]root[`)`] is equal to: [__________]{$quot} + +List all roots of [`f(x)`]: [__________]{$answerRoot} + +List all factors of [`f(x)`]: [__________]{$answer} + + +* Separate multiple factors with commas. + +* Write complex numbers using the imaginary unit [`i`]. For example, convert [`\sqrt{-3}`] to [`i\cdot \sqrt{3}`], etc. + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors-quad-denom.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors-quad-denom.pg index 445325ef5e..09bbf68976 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors-quad-denom.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors-quad-denom.pg @@ -206,7 +206,7 @@ We verify all the above with the graphs: rowcss=>"padding-bottom:2pt;"]], ['f(x)',['g(x)']], ], - align => 'c c ', + align => 'cc', center => 1, );@]* << @@ -235,7 +235,7 @@ Can you see how we can also read off the domain of [`f(x)`] and [`g(x)`] from it [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, );@]* << diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors.pg index fbe137b0c0..0bf0ec5023 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Asymptotes/graphs-repeated-factors.pg @@ -177,8 +177,8 @@ The following graphs reflect a vertical asymptote at [`x=-1`]: [image(insertGraph($gr1), width=>300, height=>300, tex_size=>600), [image(insertGraph($gr2), width=>300, height=>300, tex_size=>600), rowcss=>"padding-bottom:2pt;"]], ['Graph 1',['Graph 2']], - ], - align => 'c c ', + ], + align => 'cc', center => 1, );@]* << @@ -186,11 +186,11 @@ The following graphs reflect a vertical asymptote at [`x=-1`]: >> [@ LayoutTable( [ - [image(insertGraph($gr3), width=>300, height=>300, tex_size=>600)], - rowcss=>"padding-bottom:2pt;", + [[image(insertGraph($gr3), width=>300, height=>300, tex_size=>600)], + rowcss=>"padding-bottom:2pt;"], ['Graph 3'], - ], - align => 'c ', + ], + align => 'c', center => 1, );@]* << @@ -219,7 +219,7 @@ This leaves us with Graph 1 as the best option for the graph of [`f(x)`]. [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, );@]* << diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-linear-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-linear-xy.pg new file mode 100644 index 0000000000..d53f1d73f9 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-linear-xy.pg @@ -0,0 +1,194 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[1],$r[2],$r[3]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); + $B = random(1,7,1); + + $rational = Formula("($A*$fac[0])/($B*$fac[1])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0])/($B*$fac[1])")->reduce; + +$ha = Fraction($A,$B)->reduce; +$HA = Formula("y=$ha"); +$VA = List(Formula("x=$r[1]")); +$roots = List(Point("($r[0],0)")); +$hole = Real("$r[1]"); +$holeY = 0; #Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("($A*$r[0])/($B*$r[1])"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +#$holePoint = Compute("($hole,$holeY)"); +$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,1,3,3); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$A/$B); +$gr->lineTo(20,$A/$B,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$r[1]) U ($r[1],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp()->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp()->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-quad-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-quad-xy.pg new file mode 100644 index 0000000000..68123193ae --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/linear-quad-xy.pg @@ -0,0 +1,195 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[1],$r[2]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); + $B = random(1,7,1); + + $rational = Formula("($A*$fac[0])/($B*$fac[1]*$fac[2])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0])/($B*$fac[1]*$fac[2])")->reduce; + +$haReal = 0; #$A/$B; +$ha = Fraction($haReal); +$HA = Formula("y=$ha"); +$VA = List(Formula("x=$r[1]"),Formula("x=$r[2]")); +$roots = List(Point("($r[0],0)")); +$hole = Real("$r[1]"); +$holeY = 0; #Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("(-$A*$r[0])/($B*$r[1]*$r[2])"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +#$holePoint = Compute("($hole,$holeY)"); +$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,1,1,3); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$haReal); +$gr->lineTo(20,$haReal,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp()->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp()->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-rep-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-rep-xy.pg new file mode 100644 index 0000000000..ca1b385442 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-rep-xy.pg @@ -0,0 +1,197 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[1],$r[2]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); + $B = random(1,7,1); + + $rational = Formula("($A*$fac[0]*$fac[1])/($B*$fac[1])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0])/($B)")->reduce; + +$haReal = 0; #$A/$B; +$ha = Fraction($haReal); +$HA = String("none"); +$HAtype = Formula("y=$ha"); +$VA = String("none"); +$VAtype = List(Formula("x=$r[1]")); +$roots = List(Point("($r[0],0)")); +$hole = Real("$r[1]"); +$holeY = Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("(-$A*$r[0])/($B)"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +$holePoint = Compute("($hole,$holeY)"); +#$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,2,3,3); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$haReal); +$gr->lineTo(20,$haReal,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$r[1]) U ($r[1],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp(typeMatch=>$HAtype)->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp(typeMatch=>$VAtype)->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-xy.pg new file mode 100644 index 0000000000..2712777d8c --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-linear-xy.pg @@ -0,0 +1,196 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[1],$r[2]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); + $B = random(1,7,1); + + $rational = Formula("($A*$fac[0]*$fac[1])/($B*$fac[2])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0]*$fac[1])/($B*$fac[2])")->reduce; + +$haReal = 0; #$A/$B; +$ha = Fraction($haReal); +$HA = String("none"); +$HAtype = Formula("y=$ha"); +$VA = List(Formula("x=$r[2]")); +$roots = List(Point("($r[0],0)"),Point("($r[1],0)")); +$hole = Real("$r[1]"); +$holeY = 0; #Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("(-$A*$r[0]*$r[1])/($B*$r[2])"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +#$holePoint = Compute("($hole,$holeY)"); +$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,0,1,3); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$haReal); +$gr->lineTo(20,$haReal,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$r[2]) U ($r[2],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp(typeMatch=>$HAtype)->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp()->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-rep-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-rep-xy.pg new file mode 100644 index 0000000000..3fd45d25ce --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-rep-xy.pg @@ -0,0 +1,196 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[1],$r[2]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); +do { $B = random(1,7,1); } until ($B != abs($A)); + + $rational = Formula("($A*$fac[0]*$fac[1])/($B*$fac[1]*$fac[2])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0])/($B*$fac[2])")->reduce; + +$haReal = $A/$B; +$ha = Fraction($haReal); +$HAtype = Formula("y=$ha"); +$HA = $HAtype; #String("none"); +$VA = List(Formula("x=$r[2]")); +$roots = List(Point("($r[0],0)")); +$hole = Real("$r[1]"); +$holeY = Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("($A*$r[0])/($B*$r[2])"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +$holePoint = Compute("($hole,$holeY)"); +#$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,2,1,3); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$haReal); +$gr->lineTo(20,$haReal,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp(typeMatch=>$HAtype)->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp()->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-xy.pg b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-xy.pg new file mode 100644 index 0000000000..ec6b134e82 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setRational_Functions_-_Comprehensive/quad-quad-xy.pg @@ -0,0 +1,196 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Rational equations and functions') +## DBsection('Asymptotes') +## Date('6/29/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl", + "PGgraphmacros.pl", + "parserAssignment.pl", + "answerHints.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Fraction"); +Context()->variables->are(x=>['Real',limits=>[-15,15]],y=>['Real',limits=>[-15,15]]); +Context()->parens->set("("=>{type=>"Point"}); +Context()->noreduce('(-x)+y','(-x)-y'); +parser::Assignment->Allow; + +#@roots = (-7,-5,-3,-1,1,3,5,7); +#@rChoice = NchooseK(8,4); +#@r = @roots[ @rChoice ]; + +$r[0] = non_zero_random(-4,4,1); +do { $r[1] = $r[0]+random(-1,1,2)*random(2,8,1); } until ($r[1] != 0); +do { $gap = random(3,6,1); } until ( abs($r[0]-$r[1])!= $gap && abs($r[0]) != $gap); +$r[2] = $r[0]+$gap; +$r[3] = $r[0]-$gap; + +# sort the roots for graphing purposes +@x = PGsort( sub {$_[0] < $_[1]} , @r ); +@dom = PGsort( sub {$_[0] < $_[1]}, ($r[2],$r[3]) ); + +foreach my $i (0..3) { + $fac[$i] = Formula("x-$r[$i]")->reduce; +} + + $A = random(-1,1,2)*random(3,7,2); +do { $B = random(1,7,1); } until ($B != abs($A)); + + $rational = Formula("($A*$fac[0]*$fac[1])/($B*$fac[2]*$fac[3])")->reduce; +# $rational = $rational->with(test_at=>[ [ $r[1],0 ] ]); +# $rational->{checkUndefinedPoints} = 'true'; + + # define the reduced formulas for rational_i + # so we can place the open_circle on the graph + $reduced = Formula("($A*$fac[0]*$fac[1])/($B*$fac[2]*$fac[3])")->reduce; + +$haReal = $A/$B; +$ha = Fraction($haReal); +$HAtype = Formula("y=$ha"); +$HA = $HAtype; #String("none"); +$VA = List(Formula("x=$r[2]"),Formula("x=$r[3]")); +$roots = List(Point("($r[0],0)"),Point("($r[1],0)")); +$hole = Real("$r[1]"); +$holeY = Fraction($reduced->eval(x=>$r[1])); +$yyy= Fraction("($A*$r[0]*$r[1])/($B*$r[2]*$r[3])"); +$yint = Point("(0,$yyy)"); + +#Context("Point"); +#Context()->strings->add("none"); +#$holePoint = Compute("($hole,$holeY)"); +$holePoint = String("none")->with( typeMatch => Point(0,0) ); + +# rational_i has a VA (=1) or root (=0) or hole (=2) or none (=3) for r_j +@tf = (0,0,1,1); + +# Custom PostFilters for error messages +####################################### +$customAsy = sub { + my $ans = shift; + $ans->{ans_message} = "Asymptotes are lines, and must be expressed as equations - not just as numbers." if ($ans->{ans_message} =~ m/isn't a variable equal to a/); + return $ans; +}; + +$customHole = sub { + my $ans = shift; + $ans->{ans_message} = "Your function does not express the hole in the graph." + if $ans->{ans_message} eq "The domain of your function doesn't match that of the correct answer"; + return $ans; +}; + +################ +# Create Graph # +################ +$gr = init_graph(-20,-20,20,20, size=>[400,400], grid=>[20,20], axes=>[0,0]); +add_functions($gr,"$rational for x in <-20,$x[0]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[0],$x[1]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[1],$x[2]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[2],$x[3]> using color:blue and weight:2"); +add_functions($gr,"$rational for x in <$x[3],20> using color:blue and weight:2"); +($gr->fn)[0]->steps(250); +($gr->fn)[1]->steps(200); +($gr->fn)[2]->steps(200); +($gr->fn)[3]->steps(200); +($gr->fn)[4]->steps(300); +foreach my $j (0..3) { + if ($tf[$j]==0) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( closed_circle($r[$j],$y,'blue') ); + #$gr->lb( new Label($r[$j],$y,"($r[$j],$y)", 'blue','bottom','right')); + }; + if($tf[$j]==1) { + $gr->moveTo($r[$j],-20); + $gr->lineTo($r[$j],20,'red',2,'dashed'); + }; + if ($tf[$j]==2) { + $y = $reduced->eval(x=>$r[$j]); + $gr->stamps( open_circle($r[$j],$y,'blue') ); + }; +} +$gr->moveTo(-20,$haReal); +$gr->lineTo(20,$haReal,'red',1,'dashed'); + +$im = image(insertGraph($gr), width=>400, height=>400, tex_size=>800); + +Context("Interval"); +Context()->operators->undefine('-',' -','- '); +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Please submit your answer in proper interval notation."; + +$domain = Interval("(-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],inf)"); +# (-inf,$dom[0]) U ($dom[0],$dom[1]) U ($dom[1],$dom[2]) U ($dom[2],inf) + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +[`` y = [$rational] ``] + +The domain of this function is: [_______________________]{$domain} + +This graph has horizontal asymptote(s) at: [_______________________]{$HA->cmp(typeMatch=>$HAtype)->withPostFilter($customAsy)} + +This graph has vertical asymptote(s) at: [_______________________]{$VA->cmp()->withPostFilter($customAsy)} + +This function has hole(s) at: [_______________________]{$holePoint->cmp(typeMatch=>Point(0,0))} + +This function has [`x`]-intercept(s) at: [_______________________]{$roots} + +This function has [`y`]-intercept at: [_______________________]{$yint} + +* If this function does not have one of the requested features, respond with "none" +END_PGML + +############################################################## +# +# Answers +# +# + +BEGIN_PGML_HINT + +Think about where your rational function will have: +* _vertical asymptotes_, +* _holes_, +* and _roots_. + +END_PGML_HINT + +BEGIN_PGML_SOLUTION + +>> [$im]* << + +END_PGML_SOLUTION + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/CUNY/CityTech/Precalculus/setSequences_-_Binomial_Theorem/pascals-triangle.pg b/Contrib/CUNY/CityTech/Precalculus/setSequences_-_Binomial_Theorem/pascals-triangle.pg new file mode 100644 index 0000000000..86ca1c71a4 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setSequences_-_Binomial_Theorem/pascals-triangle.pg @@ -0,0 +1,190 @@ +##DESCRIPTION +## Algebra problem: true or false for inequality +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'inequality', 'fraction') + +## DBsubject('Algebra') +## DBchapter('Finite sequences and series') +## DBsection('Binomial theorem') +## Date('8/21/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set(reduceConstants=>0, reduceConstantFunctions=>0); + +$eighthRow = List(1,8,28,56,70,56,28,8,1); + +$introN = random(4,7,1); +$introK = random(2,$introN-2,1); +$introNFact = Real("$introN!"); +$introKFact = Real("$introK!"); +$introNKFact = Real("($introN-$introK)!"); +$introPascal = Real("$introNFact/($introKFact*$introNKFact)"); + +$n[0] = random(6,8,1); +$k[0] = random(2,$n[0]-2,1); +$nkDiff[0]= Formula("$n[0] - $k[0]")->reduce; + +$n[1] = random(8,10,1); +$k[1] = random(3,$n[1]-3,1); +$nkDiff[1]= Formula("$n[1] - $k[1]")->reduce; + +foreach my $i (0..1) { + $nFact[$i] = Real("$n[$i]!"); + $kFact[$i] = Real("$k[$i]!"); + $nkFact[$i] = Real("($n[$i]-$k[$i])!"); + $pascal[$i] = Real("$nFact[$i]/($kFact[$i]*$nkFact[$i])"); +} + +### Re-initialize all answer variables in LimitedNumeric +### This prevents students from using "!" in their answers + +Context("LimitedNumeric"); +Context()->{error}{msg}{"Can't use '+' in this context"} + = "Addition is disabled for this problem. Simplify the sum and resubmit your answer."; +Context()->{error}{msg}{"Can't use '-' in this context"} + = "Subtraction is disabled for this problem. Simplify the difference and resubmit your answer."; +Context()->{error}{msg}{"Can't use '*' in this context"} + = "Multiplication is disabled for this problem. Simplify the product and resubmit your answer."; +Context()->{error}{msg}{"Can't use '/' in this context"} + = "Division is disabled for this problem. Simplify the quotient and resubmit your answer."; +Context()->{error}{msg}{"Can't use '^' in this context"} + = "Exponents are disabled for this problem. Compute the result for yourself and resubmit your answer."; +Context()->{error}{msg}{"Can't use '**' in this context"} + = "Exponents are disabled for this problem. Compute the result for yourself and resubmit your answer."; +Context()->{error}{msg}{"Can't use '!' in this context"} + = "Factorials are disabled for this problem. Compute the result for yourself and resubmit your answer."; + +foreach my $i (0..1) { + $nFact[$i] = Real($nFact[$i]); + $kFact[$i] = Real($kFact[$i]); + $nkFact[$i] = Real($nkFact[$i]); + $pascal[$i] = Real($pascal[$i]); +} + +$introNFact = Real($introNFact); +$introKFact = Real($introKFact); +$introNKFact = Real($introNKFact); +$introPascal = Real($introPascal); + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Pascal's Triangle ### << + +*Pascal's triangle* is a number pattern that is useful when computing large exponents of binomial expressions. + +The pattern of Pascal's triangle involves computing each row from the row above. Each entry is the sum of the two adjacent elements above it, as illustrated here: + +>> [@ image("PascalTriangleAnimated2.gif")@]* << + +The next image shows several more rows of Pascal's triangle: + +>> [@ image("Pascal_triangle_small.png", width=>300, height=>135)@]* << + +Can you determine what the next row will look like? [_____________________________]{$eighthRow} + _(use commas to separate each element in the eighth row)_ + +Building Pascal's triangle is a _recursive_ process, in that each calculating each row would seem to require the row before it. After all, how would you know what belongs in the [`10^{th}`] row if you didn't know what to add together from the [`9^{th}`] row? + +Fortunately, there's a closed form for this pattern, and it involves the 'choose' function: +>> [`` \binom{n}{k} = \frac{n!}{k!(n-k)!} ``] << + +In this closed form, [`n`] refers to which _row_ we want (_vertically_), and [`k`] indicates which _position_ in the row (_horizontally_). + +Now, there's a slight hiccup in the numbering of the rows and the positions of the triangle. Above, when you were asked to find the [`8^{th}`] row of Pascal's triangle, perhaps you caught the fact that there were already 8 rows displayed. This minor discrepancy happens because we _actually_ consider the first row to be [`n=0`], or the [`0^{th}`] row. + +The same thing happens when considering [`k`], the "first" element in the row is actually called the [`0^{th}`], or [`k=0`]. Understanding this is *crucial* for aligning Pascal's triangle with the closed form. + +Use the image above to locate the element with [`n = [$introN]`] and [`k = [$introK]`]: [_____]{$introPascal} + +* What is [`n!`]? [__________]{$introNFact} +* What is [`k!`]? [__________]{$introKFact} +* What is [`(n-k)!`]? [_________]{$introNKFact} + +Compute [`\dfrac{n!}{k!(n-k)!}`] and confirm that it matches the element you found in the image. + +>> #### Practice #### << + +1. Compute the element from Pascal's triangle with [`n=[$n[0]]`] and [`k=[$k[0]]`]: + a. What is [`n!`]? [__________]{$nFact[0]} + a. What is [`k!`]? [__________]{$kFact[0]} + a. What is [`(n-k)!`]? [__________]{$nkFact[0]} + a. Finally, what is the element from Pascal's triangle? [__________]{$pascal[0]} + +1. Compute the element from Pascal's triangle with [`n=[$n[1]]`] and [`k=[$k[1]]`]: + a. What is [`n!`]? [__________]{$nFact[1]} + a. What is [`k!`]? [__________]{$kFact[1]} + a. What is [`(n-k)!`]? [__________]{$nkFact[1]} + a. Finally, what is the element from Pascal's triangle? [__________]{$pascal[1]} + +END_PGML + +############################################################## +# +# Answers +# +# + + +BEGIN_PGML_HINT + +* [`0!=1`] +* [`1!=1`] +* [`2!=2\times 1 = 2 `] +* [`3!=3\times 2 \times 1 = 6 `] +* [`4!=4\times 3\times 2 \times 1 = 24 `] +* [`\vdots`] +* [`n!=n\times (n-1)\times (n-2) \times \ldots \times 1`] +* The element from Pascal’s triangle with [`n`] and [`k`] is +[`\dfrac{n!}{k!(n-k)!}`]. + +END_PGML_HINT + + +BEGIN_PGML_SOLUTION + +1. + a. [`[$n[0]]!=[$nFact[0]]`] + a. [`[$k[0]]!=[$kFact[0]]`] + a. [`[$nkDiff[0]]!=[$nkFact[0]]`] + a. [`\dfrac{[$n[0]]!} {([$k[0]]!)([$nkDiff[0]] !)}= [$pascal[0]]`] + +2. + a. [`[$n[1]]!=[$nFact[1]]`] + a. [`[$k[1]]!=[$kFact[1]]`] + a. [`[$nkDiff[1]]!=[$nkFact[1]]`] + a. [`\dfrac{[$n[1]]!}{([$k[1]]!)([$nkDiff[1]]!)}= [$pascal[1]]`] + + + +END_PGML_SOLUTION +ENDDOCUMENT(); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/fundamental-functions-id.pg b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/fundamental-functions-id.pg index 3ece77015d..864568d615 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/fundamental-functions-id.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/fundamental-functions-id.pg @@ -89,7 +89,7 @@ BEGIN_PGML [ $im[4], [ $im[5], rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/multiple-shifts-id.pg b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/multiple-shifts-id.pg index ad6e742876..aa6f41fba7 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/multiple-shifts-id.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/multiple-shifts-id.pg @@ -88,7 +88,7 @@ BEGIN_PGML [ $im[4], [ $im[5], rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/shift-reflect-id.pg b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/shift-reflect-id.pg index 52e52db078..23c7ba754b 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/shift-reflect-id.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTranslating_Functions/shift-reflect-id.pg @@ -94,7 +94,7 @@ BEGIN_PGML [ $fIm[4], [ $fIm[5], rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, )@]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Double_and_Half_Angle_Formulas/half-angle.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Double_and_Half_Angle_Formulas/half-angle.pg new file mode 100644 index 0000000000..6174164c57 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Double_and_Half_Angle_Formulas/half-angle.pg @@ -0,0 +1,132 @@ +##DESCRIPTION +## +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'trig functions', 'trigonometric functions', 'double', 'half','fraction', 'analytic trigonometry', 'angle', 'angles', 'radians') + +## DBsubject('Trigonometry') +## DBchapter('Analytic trigonometry') +## DBsection('Addition & subtraction formulas') +## Date('7/28/2018') +## Author('K. Andrew Parker') +## Institution('City Tech') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + "contextFraction.pl" +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Parser::Number::NoDecimals(); +Context()->{error}{msg}{"You are not allowed to type decimal numbers in this problem"} + = "Decimals are not allowed for this problem, please use exact forms (such as fractions) instead of decimal approximations."; +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0, +); + +$divSin=random(8,12,4); +if ($divSin==8){$ansSin=Formula("sqrt(2-sqrt(2))/2");} +elsif ($divSin==12){$ansSin=Formula("(sqrt(3)-1)/(2*sqrt(2))");} +else {$ansSin=Formula("sqrt(2-sqrt(2+sqrt(2)))/2");}; + +$divCos=random(12,16,4); +if ($divCos==12){$ansCos=Formula("(1+sqrt(3))/(2*sqrt(2))");} +else {$ansCos=Formula("sqrt(2+sqrt(2+sqrt(2)))/2");}; + +$divTan=random(8,12,4); +if ($divTan==8){$ansTan=Formula("sqrt((2-sqrt(2))/(2+sqrt(2)))");} +elsif ($divTan==12){$ansTan=Formula("2-sqrt(3)");} +else {$ansTan=Formula("sqrt((2-sqrt(2+sqrt(2)))/(2+sqrt(2+sqrt(2))))");}; + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +>> ### Double and Half Angle Formulas ### << + +Recall the *double angle formulas*: + +[``` +\begin{align*} +\sin(2 \alpha)&=2\sin(\alpha)\cos(\alpha)\\ +\cos(2 \alpha)&=\cos^2(\alpha)-\sin^2(\alpha)=1-2\sin^2(\alpha)=2\cos^2(\alpha)-1\\ +\tan(2 \alpha)&=\frac{2\tan(\alpha)}{1-\tan^2(\alpha)}\\ +\end{align*} +```] + +Recall the *half angle formulas*: + +[``` +\begin{align*} +\sin\left(\frac \alpha 2\right)&=\pm\sqrt{\frac{1-\cos(\alpha)}{2}}\\ +\cos\left(\frac \alpha 2\right)&=\pm\sqrt{\frac{1+\cos(\alpha)}{2}}\\ +\tan\left(\frac \alpha 2\right)&=\pm\sqrt{\frac{1-\cos(\alpha)}{1+\cos(\alpha)}}\\ +\end{align*} +```] + + +####Example:#### + +Since [`\cos(\frac \pi 4)=\frac{\sqrt{2}}{2}`], get the cosine of [`\frac{\pi}{8}`] via the half-angle formula: + +[``` +\begin{align*} +\cos\left(\frac{\pi}{8}\right)&=\cos\left(\frac{\pi/4}{2}\right) +=\pm\sqrt{\frac{1+\cos(\frac{\pi}{4})}{2}} +=\sqrt{\frac{1+\frac{\sqrt{2}}{2}}{2}}\\ +&=\sqrt{\left(\frac 2 2+\frac{\sqrt{2}}{2}\right)\cdot \frac{1}{2}} +=\sqrt{\frac{2+\sqrt{2}}{4}} +=\frac{\sqrt{2+\sqrt{2}}}{2} +\end{align*} +```] +Here, we used the '[`+`]' sign, because the angle [`\frac \pi {8}=\frac{180^\circ}{8}=22.5^\circ`] is in the first quadrant, so that it's cosine is positive. +>> ### Practice ### << + +Use the half angle formulas to find the following trigonometric function values. + +a. [` \sin\left(\frac{\pi}{[$divSin]}\right) = `][_________________________]{$ansSin} + +a. [` \tan\left(\frac{\pi}{[$divTan]}\right) = `][_________________________]{$ansTan} + +a. [` \cos\left(\frac{\pi}{[$divCos]}\right) = `][_________________________]{$ansCos} + + +* Decimal approximations are not allowed for this problem. +* Enter your answer in exact form. +* Use "sqrt( )" to represent [`\sqrt{ }`] + +END_PGML + + + +############################################################## +# +# Answers +# +# + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-cos.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-cos.pg new file mode 100644 index 0000000000..b0a1a8bbd8 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-cos.pg @@ -0,0 +1,297 @@ +##DESCRIPTION +## Trigonometry problem: Solve a trig equation - ALL solutions required +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'trig functions', 'trigonometric functions', 'analytic trigonometry', 'trigonometric equation') + +## DBsubject(Trigonometry) +## DBchapter(Analytic trigonometry) +## DBsection(Solving trigonometric equations exactly) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0 +); +Context()->variables->add(n=>['Real',limits=>[-10,10]]); + +Parser::Number::NoDecimals(); +Context()->{error}{msg}{"You are not allowed to type decimal numbers in this problem"} + = "Please state your answer in radians, using fractions of 'pi' rather than decimal approximations."; + +# unit circle hash for each denom +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-sqrt(3)/2"), + x2 => Formula("3/4"), + y => Formula("1/2"), + ny => Formula("-1/2"), + y2 => Formula("1/4"), + t => Formula("1/sqrt(3)"), + nt => Formula("-1/sqrt(3)"), + t2 => Formula("1/3") + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-1/2"), + x2 => Formula("1/4"), + y => Formula("sqrt(3)/2"), + ny => Formula("-sqrt(3)/2"), + y2 => Formula("3/4"), + t => Formula("sqrt(3)/1"), + nt => Formula("-sqrt(3)/1"), + t2 => Formula("3/1") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-sqrt(2)/2"), + x2 => Formula("1/2"), + y => Formula("sqrt(2)/2"), + ny => Formula("-sqrt(2)/2"), + y2 => Formula("1/2"), + t => Formula("1/1"), + nt => Formula("-1/1"), + t2 => Formula("1/1") + } +); + +# choose reference angle and generate necessary secondary numerators +$denom = list_random(3,4,6); +$dminus1 = $denom-1; +$dplus1 = $denom+1; +$twodminus1 = 2*$denom-1; + +# hash to provide principal solutions in [0,2pi) +# $principal{$trigFunction}{$isPositive} +%principal = ( + sin => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + }, + cos => { + 1 => Formula("pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + }, + tan => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + } +); + +# hash to provide secondary solutions in [0,2pi) +# $secondary{$trigFunction}{$isPositive} +%secondary = ( + sin => { + 1 => Formula("$dminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + cos => { + 1 => Formula("$twodminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + tan => { + 1 => Formula("$dplus1 pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + } +); + +# for generating a hashkey +# usage: row = sin/cos/tan +# column = squared/Q1/Q2/Q3/Q4 +@select = ( [ 'y2', 'y', 'y', 'ny', 'ny' ], + [ 'x2', 'x', 'nx', 'nx', 'x' ], + [ 't2', 't', 'nt', 't', 'nt' ] +); + +### Randomly select quadrant and trig function to use +$quad = random(1,4,1); +@trig = ("sin","cos","tan"); +@trigFull = ("sine", "cosine", "tangent"); # for display +#$function = random(0,2,1); +$function = 1; +$trigFunction = $trigFull[$function]; # display name for hint/solution +### Select a second trig function as common factor = 0 +# to avoid reduction-confusion, we don't pair cosine and tangent +$function2 = ( $function == 0 ) ? random(1,2,1) : 0; +$trigFunction2 = $trigFull[$function2]; + + +### Generate a hash key for retrieving result from unit circle hash +$hashKey = $select[$function][$quad]; + +### Pull the proper ratio from the unit circle hash and generate coefficients +$ratio = Formula("$unit{$denom}{$hashKey}"); +$hashKey =~ tr/n//d; +$absRatio = Formula("$unit{$denom}{$hashKey}"); +$A = Formula($absRatio->{tree}{rop}); +$B = Formula($absRatio->{tree}{lop}); + +$LHS = ($A == 1) ? Formula("$trig[$function]^2(x)") : Formula("$A $trig[$function]^2(x)"); +if ($ratio < 0) { + $LHS = ($B == 1) ? Formula("$LHS + $trig[$function](x)") : Formula("$LHS + $B $trig[$function](x)"); + } else { + $LHS = ($B == 1) ? Formula("$LHS - $trig[$function](x)") : Formula("$LHS - $B $trig[$function](x)"); +}; +$RHS = Formula("0"); + +$isPos = ($ratio > 0) ? 1 : 0; +$ans1 = Formula("$principal{$trig[$function]}{$isPos} + 2pi n"); +$ans2 = Formula("$secondary{$trig[$function]}{$isPos} + 2pi n"); +$ans3 = ($function == 1) ? Formula("pi/2 + 2pi n") : Formula("0 + 2pi n"); +$ans4 = ($function == 1) ? Formula("3 pi / 2 + 2pi n") : Formula("pi + 2pi n"); +$ans = List( $ans1, $ans2, $ans3, $ans4 ); + +$correctDepth = 3; # correct values will be measured +/- 2pi * this parameter +$studentDepth = 10; # student values will be +/- 2pi * this parameter + # should be at least 2x larger in case of tangent + +$periodicCheck = sub { + my ($correct,$student,$ansHash,$value) = @_; + my $m = scalar(@$correct); # number of correct answers + my $n = scalar(@$student); # number of student answers + my $score = 0; # number of correct student answers + my @errors = (); # stores error messages + my $i, $j; # loop counters + my $correctSet = Set(); + foreach my $k (0..$m-1) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>0))); + foreach my $l (1..$correctDepth) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>$l), $correct->[$k]->eval(n=>-$l))); + } + } + # + # Loop though the student answers + ## + my $studentCumulative = Set(); + for ($i = 0; $i < $n; $i++) { + my $ith = Value::List->NameForNumber($i+1); + my $p = $student->[ $i ]; # i-th student answer + my $Dp = $p -> D('n'); # positive? negative? ZERO?? + my $DDp = $Dp -> D('n'); # make sure students aren't overcomplicating + # + # Check that the student's answer contains "n" (hopefully 2 pi n) + # + if ( $Dp == 0 ) { + push(@errors,"Your $ith answer is a single solution when it should be an expression that represents multiple values."); + push(@errors,"Your $ith answer is not a solution to the given equation.") if ($LHS->eval(x=>$p) != $RHS); # update this if RHS is nonconstant + next; + } + # + # Make sure that student's answer contains "n" + # + if ( $DDp != 0 ) { + push(@errors,"You're overcomplicating your $ith answer."); + next; + } + # + # Check that the answer hasn't been given before + # + my $studentSet = Set($p->eval(n=>0)); + my $used = 0; + foreach my $k (1..$studentDepth) { + $studentSet = Set($studentSet + Set($p->eval(n=>$k), $p->eval(n=>-$k))); + } + if ( $studentSet->intersects($studentCumulative) ) { + push(@errors, "Your $ith expression represents overlapping values with a previous answer."); + $used = 1; last; + } + # + # If not already used, check that it satisfies the equation + # and increase the score if so. + # + if (!$used) { + my @studentValues = $studentSet->value; + my $l = scalar(@studentValues); + my $incorrect = 0; + foreach my $k (0..$l-1) { + # note to self : update this evaluation if RHS is nonconstant + if ($LHS->eval(x=>$studentValues[$k]) != $RHS) {$incorrect++} + } + if ( $incorrect == 0) { + $score++; + } else { + push(@errors,"Your $ith expression represents values that do not solve the equation.") unless $ansHash->{isPreview}; + } + $studentCumulative = Set( $studentCumulative + $studentSet ); + } + } + # + # Check that there are the right number of answers + # + if (!$ansHash->{isPreview}) { + push(@errors,"You have not expressed all possible solutions.") if !$studentCumulative->contains($correctSet); + # if the student answers cover the necessary solution, + # and there's been no mistakes, and we're still shy + # of the required number of solutions based on the input list + # _still_ give full credit because there's been a more + # condensed solution possible (tangent) + if ( $studentCumulative->contains($correctSet) && $score == $n && $score < $m ) { $score = $m }; + # push(@errors,"You have given too many solutions") if $score > 4 && $i != $score; + } + return ($score,@errors); + }; + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +*Quadratic trigonometric equation with "cosine":* + +Solve for [`x`]: +>> [`` \large [$LHS] = [$RHS] ``] << + +Give expressions to represent all solutions to the equation: + + [`x = `] [________________________________________]{$ans->cmp(showLengthHints=>0, list_checker=>$periodicCheck)} + +* Give your answer in radians. +* Separate multiple solutions with commas. +* Use "[`n`]" as the parameter in your solution(s). +* Do not use decimal approximations. Use 'pi' to represent [` \pi `]. + +END_PGML + +BEGIN_PGML_HINT + +* Get the equation in standard form if not already +* Is there a trig function in common? Factor it! +* Use the zero-product property +* Solve each of the trig equations separately +* Collect _all_ answers for your final answer + +END_PGML_HINT + +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-sin.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-sin.pg new file mode 100644 index 0000000000..ada3921cfb --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-sin.pg @@ -0,0 +1,312 @@ +##DESCRIPTION +## Trigonometry problem: Solve a trig equation - ALL solutions required +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'trig functions', 'trigonometric functions', 'analytic trigonometry', 'trigonometric equation') + +## DBsubject(Trigonometry) +## DBchapter(Analytic trigonometry) +## DBsection(Solving trigonometric equations exactly) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0 +); +Context()->variables->add(n=>['Real',limits=>[-10,10]]); + +Parser::Number::NoDecimals(); +Context()->{error}{msg}{"You are not allowed to type decimal numbers in this problem"} + = "Please state your answer in radians, using fractions of 'pi' rather than decimal approximations."; + +# unit circle hash for each denom +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-sqrt(3)/2"), + x2 => Formula("3/4"), + y => Formula("1/2"), + ny => Formula("-1/2"), + y2 => Formula("1/4"), + t => Formula("1/sqrt(3)"), + nt => Formula("-1/sqrt(3)"), + t2 => Formula("1/3") + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-1/2"), + x2 => Formula("1/4"), + y => Formula("sqrt(3)/2"), + ny => Formula("-sqrt(3)/2"), + y2 => Formula("3/4"), + t => Formula("sqrt(3)/1"), + nt => Formula("-sqrt(3)/1"), + t2 => Formula("3/1") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-sqrt(2)/2"), + x2 => Formula("1/2"), + y => Formula("sqrt(2)/2"), + ny => Formula("-sqrt(2)/2"), + y2 => Formula("1/2"), + t => Formula("1/1"), + nt => Formula("-1/1"), + t2 => Formula("1/1") + } +); + +# choose reference angle and generate necessary secondary numerators +$denom = list_random(3,4,6); +$dminus1 = $denom-1; +$dplus1 = $denom+1; +$twodminus1 = 2*$denom-1; + +# hash to provide principal solutions in [0,2pi) +# $principal{$trigFunction}{$isPositive} +%principal = ( + sin => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + }, + cos => { + 1 => Formula("pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + }, + tan => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + } +); + +# hash to provide secondary solutions in [0,2pi) +# $secondary{$trigFunction}{$isPositive} +%secondary = ( + sin => { + 1 => Formula("$dminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + cos => { + 1 => Formula("$twodminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + tan => { + 1 => Formula("$dplus1 pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + } +); + +# for generating a hashkey +# usage: row = sin/cos/tan +# column = squared/Q1/Q2/Q3/Q4 +@select = ( [ 'y2', 'y', 'y', 'ny', 'ny' ], + [ 'x2', 'x', 'nx', 'nx', 'x' ], + [ 't2', 't', 'nt', 't', 'nt' ] +); + +### Randomly select quadrant and trig function to use +$quad = random(1,4,1); +@trig = ("sin","cos","tan"); +@trigFull = ("sine", "cosine", "tangent"); # for display +#$function = random(0,2,1); +$function = 0; +$trigFunction = $trigFull[$function]; # display name for hint/solution +### Select a second trig function as common factor = 0 +# to avoid reduction-confusion, we don't pair cosine and tangent +$function2 = ( $function == 0 ) ? random(1,2,1) : 0; +$trigFunction2 = $trigFull[$function2]; + + +### Generate a hash key for retrieving result from unit circle hash +$hashKey = $select[$function][$quad]; + +### Pull the proper ratio from the unit circle hash and generate coefficients +$ratio = Formula("$unit{$denom}{$hashKey}"); +$hashKey =~ tr/n//d; +$absRatio = Formula("$unit{$denom}{$hashKey}"); +$A = Formula($absRatio->{tree}{rop}); +$B = Formula($absRatio->{tree}{lop}); + +$LHS = ($A == 1) ? Formula("$trig[$function]^2(x)") : Formula("$A $trig[$function]^2(x)"); +if ($ratio < 0) { + $LHS = ($B == 1) ? Formula("$LHS + $trig[$function](x)") : Formula("$LHS + $B $trig[$function](x)"); + } else { + $LHS = ($B == 1) ? Formula("$LHS - $trig[$function](x)") : Formula("$LHS - $B $trig[$function](x)"); +}; +$RHS = Formula("0"); + +$isPos = ($ratio > 0) ? 1 : 0; +$ans1 = Formula("$principal{$trig[$function]}{$isPos} + 2pi n"); +$ans2 = Formula("$secondary{$trig[$function]}{$isPos} + 2pi n"); +$ans3 = ($function == 1) ? Formula("pi/2 + 2pi n") : Formula("0 + 2pi n"); +$ans4 = ($function == 1) ? Formula("3 pi / 2 + 2pi n") : Formula("pi + 2pi n"); +$ans = List( $ans1, $ans2, $ans3, $ans4 ); + +$correctDepth = 3; # correct values will be measured +/- 2pi * this parameter +$studentDepth = 10; # student values will be +/- 2pi * this parameter + # should be at least 2x larger in case of tangent + +$periodicCheck = sub { + my ($correct,$student,$ansHash,$value) = @_; + my $m = scalar(@$correct); # number of correct answers + my $n = scalar(@$student); # number of student answers + my $score = 0; # number of correct student answers + my @errors = (); # stores error messages + my $i, $j; # loop counters + my $correctSet = Set(); + foreach my $k (0..$m-1) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>0))); + foreach my $l (1..$correctDepth) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>$l), $correct->[$k]->eval(n=>-$l))); + } + } + # + # Loop though the student answers + ## + my $studentCumulative = Set(); + for ($i = 0; $i < $n; $i++) { + my $ith = Value::List->NameForNumber($i+1); + my $p = $student->[ $i ]; # i-th student answer + my $Dp = $p -> D('n'); # positive? negative? ZERO?? + my $DDp = $Dp -> D('n'); # make sure students aren't overcomplicating + # + # Check that the student's answer contains "n" (hopefully 2 pi n) + # + if ( $Dp == 0 ) { + push(@errors,"Your $ith answer is a single solution when it should be an expression that represents multiple values."); + push(@errors,"Your $ith answer is not a solution to the given equation.") if ($LHS->eval(x=>$p) != $RHS); # update this if RHS is nonconstant + next; + } + # + # Make sure that student's answer contains "n" + # + if ( $DDp != 0 ) { + push(@errors,"You're overcomplicating your $ith answer."); + next; + } + # + # Check that the answer hasn't been given before + # + my $studentSet = Set($p->eval(n=>0)); + my $used = 0; + foreach my $k (1..$studentDepth) { + $studentSet = Set($studentSet + Set($p->eval(n=>$k), $p->eval(n=>-$k))); + } + if ( $studentSet->intersects($studentCumulative) ) { + push(@errors, "Your $ith expression represents overlapping values with a previous answer."); + $used = 1; last; + } + # + # If not already used, check that it satisfies the equation + # and increase the score if so. + # + if (!$used) { + my @studentValues = $studentSet->value; + my $l = scalar(@studentValues); + my $incorrect = 0; + foreach my $k (0..$l-1) { + # note to self : update this evaluation if RHS is nonconstant + if ($LHS->eval(x=>$studentValues[$k]) != $RHS) {$incorrect++} + } + if ( $incorrect == 0) { + $score++; + } else { + push(@errors,"Your $ith expression represents values that do not solve the equation.") unless $ansHash->{isPreview}; + } + $studentCumulative = Set( $studentCumulative + $studentSet ); + } + } + # + # Check that there are the right number of answers + # + if (!$ansHash->{isPreview}) { + push(@errors,"You have not expressed all possible solutions.") if !$studentCumulative->contains($correctSet); + # if the student answers cover the necessary solution, + # and there's been no mistakes, and we're still shy + # of the required number of solutions based on the input list + # _still_ give full credit because there's been a more + # condensed solution possible (tangent) + if ( $studentCumulative->contains($correctSet) && $score == $n && $score < $m ) { $score = $m }; + # push(@errors,"You have given too many solutions") if $score > 4 && $i != $score; + } + return ($score,@errors); + }; + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + + +>> ### Trig Equations ### << + +Equations of the form [`AX^2+BX=0`] have solutions [`X = 0`] or [`X=-\frac B A`]. + +This is so because we solve quadratic equations in standard form by factoring, + +[`X\cdot (AX+B)=0`] and using the zero-product property. + +>>To solve trig equations that are not of the form [`\tan(x)=A`], [`\cos(x)=B`] or [`\sin(x)=C`], we use factoring.<< + +>> When we see an exponent on a trig function, we rewrite the equation in standard form and we factor it.<< + +>> ### Practice ### << + +*Quadratic trigonometric equation with "sine":* + +Solve for [`x`]: +>> [`` \large [$LHS] = [$RHS] ``] << + +Give expressions to represent all solutions to the equation: + + [`x = `] [________________________________________]{$ans->cmp(showLengthHints=>0, list_checker=>$periodicCheck)} + +* Give your answer in radians. +* Separate multiple solutions with commas. +* Use "[`n`]" as the parameter in your solution(s). +* Do not use decimal approximations. Use 'pi' to represent [` \pi `]. + +END_PGML + +BEGIN_PGML_HINT + +* Get the equation in standard form if not already +* Is there a trig function in common? Factor it! +* Use the zero-product property +* Solve each of the trig equations separately +* Collect _all_ answers for your final answer + +END_PGML_HINT + +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-tan.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-tan.pg new file mode 100644 index 0000000000..e346bbfaa5 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Equations/same-quad-all-solutions-tan.pg @@ -0,0 +1,297 @@ +##DESCRIPTION +## Trigonometry problem: Solve a trig equation - ALL solutions required +##ENDDESCRIPTION + +##KEYWORDS('trigonometry', 'trig functions', 'trigonometric functions', 'analytic trigonometry', 'trigonometric equation') + +## DBsubject(Trigonometry) +## DBchapter(Analytic trigonometry) +## DBsection(Solving trigonometric equations exactly) +## Author(K. Andrew Parker) +## Institution(CUNY City Tech) +## Language(en) + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", +); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +############################################################## +# +# Setup +# +# +Context("Numeric"); +Context()->flags->set( + reduceConstants=>0, + reduceConstantFunctions=>0 +); +Context()->variables->add(n=>['Real',limits=>[-10,10]]); + +Parser::Number::NoDecimals(); +Context()->{error}{msg}{"You are not allowed to type decimal numbers in this problem"} + = "Please state your answer in radians, using fractions of 'pi' rather than decimal approximations."; + +# unit circle hash for each denom +%unit = ( + 6 => { + x => Formula("sqrt(3)/2"), + nx => Formula("-sqrt(3)/2"), + x2 => Formula("3/4"), + y => Formula("1/2"), + ny => Formula("-1/2"), + y2 => Formula("1/4"), + t => Formula("1/sqrt(3)"), + nt => Formula("-1/sqrt(3)"), + t2 => Formula("1/3") + }, + 3 => { + x => Formula("1/2"), + nx => Formula("-1/2"), + x2 => Formula("1/4"), + y => Formula("sqrt(3)/2"), + ny => Formula("-sqrt(3)/2"), + y2 => Formula("3/4"), + t => Formula("sqrt(3)/1"), + nt => Formula("-sqrt(3)/1"), + t2 => Formula("3/1") + }, + 4 => { + x => Formula("sqrt(2)/2"), + nx => Formula("-sqrt(2)/2"), + x2 => Formula("1/2"), + y => Formula("sqrt(2)/2"), + ny => Formula("-sqrt(2)/2"), + y2 => Formula("1/2"), + t => Formula("1/1"), + nt => Formula("-1/1"), + t2 => Formula("1/1") + } +); + +# choose reference angle and generate necessary secondary numerators +$denom = list_random(3,4,6); +$dminus1 = $denom-1; +$dplus1 = $denom+1; +$twodminus1 = 2*$denom-1; + +# hash to provide principal solutions in [0,2pi) +# $principal{$trigFunction}{$isPositive} +%principal = ( + sin => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + }, + cos => { + 1 => Formula("pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + }, + tan => { + 1 => Formula("pi/$denom"), + 0 => Formula("$twodminus1 pi/$denom"), # or -pi/$denom outside [0,2pi) + } +); + +# hash to provide secondary solutions in [0,2pi) +# $secondary{$trigFunction}{$isPositive} +%secondary = ( + sin => { + 1 => Formula("$dminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + cos => { + 1 => Formula("$twodminus1 pi/$denom"), + 0 => Formula("$dplus1 pi/$denom"), + }, + tan => { + 1 => Formula("$dplus1 pi/$denom"), + 0 => Formula("$dminus1 pi/$denom"), + } +); + +# for generating a hashkey +# usage: row = sin/cos/tan +# column = squared/Q1/Q2/Q3/Q4 +@select = ( [ 'y2', 'y', 'y', 'ny', 'ny' ], + [ 'x2', 'x', 'nx', 'nx', 'x' ], + [ 't2', 't', 'nt', 't', 'nt' ] +); + +### Randomly select quadrant and trig function to use +$quad = random(1,4,1); +@trig = ("sin","cos","tan"); +@trigFull = ("sine", "cosine", "tangent"); # for display +#$function = random(0,2,1); +$function = 2; +$trigFunction = $trigFull[$function]; # display name for hint/solution +### Select a second trig function as common factor = 0 +# to avoid reduction-confusion, we don't pair cosine and tangent +$function2 = ( $function == 0 ) ? random(1,2,1) : 0; +$trigFunction2 = $trigFull[$function2]; + + +### Generate a hash key for retrieving result from unit circle hash +$hashKey = $select[$function][$quad]; + +### Pull the proper ratio from the unit circle hash and generate coefficients +$ratio = Formula("$unit{$denom}{$hashKey}"); +$hashKey =~ tr/n//d; +$absRatio = Formula("$unit{$denom}{$hashKey}"); +$A = Formula($absRatio->{tree}{rop}); +$B = Formula($absRatio->{tree}{lop}); + +$LHS = ($A == 1) ? Formula("$trig[$function]^2(x)") : Formula("$A $trig[$function]^2(x)"); +if ($ratio < 0) { + $LHS = ($B == 1) ? Formula("$LHS + $trig[$function](x)") : Formula("$LHS + $B $trig[$function](x)"); + } else { + $LHS = ($B == 1) ? Formula("$LHS - $trig[$function](x)") : Formula("$LHS - $B $trig[$function](x)"); +}; +$RHS = Formula("0"); + +$isPos = ($ratio > 0) ? 1 : 0; +$ans1 = Formula("$principal{$trig[$function]}{$isPos} + 2pi n"); +$ans2 = Formula("$secondary{$trig[$function]}{$isPos} + 2pi n"); +$ans3 = ($function == 1) ? Formula("pi/2 + 2pi n") : Formula("0 + 2pi n"); +$ans4 = ($function == 1) ? Formula("3 pi / 2 + 2pi n") : Formula("pi + 2pi n"); +$ans = List( $ans1, $ans2, $ans3, $ans4 ); + +$correctDepth = 3; # correct values will be measured +/- 2pi * this parameter +$studentDepth = 10; # student values will be +/- 2pi * this parameter + # should be at least 2x larger in case of tangent + +$periodicCheck = sub { + my ($correct,$student,$ansHash,$value) = @_; + my $m = scalar(@$correct); # number of correct answers + my $n = scalar(@$student); # number of student answers + my $score = 0; # number of correct student answers + my @errors = (); # stores error messages + my $i, $j; # loop counters + my $correctSet = Set(); + foreach my $k (0..$m-1) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>0))); + foreach my $l (1..$correctDepth) { + $correctSet = Set($correctSet + Set($correct->[$k]->eval(n=>$l), $correct->[$k]->eval(n=>-$l))); + } + } + # + # Loop though the student answers + ## + my $studentCumulative = Set(); + for ($i = 0; $i < $n; $i++) { + my $ith = Value::List->NameForNumber($i+1); + my $p = $student->[ $i ]; # i-th student answer + my $Dp = $p -> D('n'); # positive? negative? ZERO?? + my $DDp = $Dp -> D('n'); # make sure students aren't overcomplicating + # + # Check that the student's answer contains "n" (hopefully 2 pi n) + # + if ( $Dp == 0 ) { + push(@errors,"Your $ith answer is a single solution when it should be an expression that represents multiple values."); + push(@errors,"Your $ith answer is not a solution to the given equation.") if ($LHS->eval(x=>$p) != $RHS); # update this if RHS is nonconstant + next; + } + # + # Make sure that student's answer contains "n" + # + if ( $DDp != 0 ) { + push(@errors,"You're overcomplicating your $ith answer."); + next; + } + # + # Check that the answer hasn't been given before + # + my $studentSet = Set($p->eval(n=>0)); + my $used = 0; + foreach my $k (1..$studentDepth) { + $studentSet = Set($studentSet + Set($p->eval(n=>$k), $p->eval(n=>-$k))); + } + if ( $studentSet->intersects($studentCumulative) ) { + push(@errors, "Your $ith expression represents overlapping values with a previous answer."); + $used = 1; last; + } + # + # If not already used, check that it satisfies the equation + # and increase the score if so. + # + if (!$used) { + my @studentValues = $studentSet->value; + my $l = scalar(@studentValues); + my $incorrect = 0; + foreach my $k (0..$l-1) { + # note to self : update this evaluation if RHS is nonconstant + if ($LHS->eval(x=>$studentValues[$k]) != $RHS) {$incorrect++} + } + if ( $incorrect == 0) { + $score++; + } else { + push(@errors,"Your $ith expression represents values that do not solve the equation.") unless $ansHash->{isPreview}; + } + $studentCumulative = Set( $studentCumulative + $studentSet ); + } + } + # + # Check that there are the right number of answers + # + if (!$ansHash->{isPreview}) { + push(@errors,"You have not expressed all possible solutions.") if !$studentCumulative->contains($correctSet); + # if the student answers cover the necessary solution, + # and there's been no mistakes, and we're still shy + # of the required number of solutions based on the input list + # _still_ give full credit because there's been a more + # condensed solution possible (tangent) + if ( $studentCumulative->contains($correctSet) && $score == $n && $score < $m ) { $score = $m }; + # push(@errors,"You have given too many solutions") if $score > 4 && $i != $score; + } + return ($score,@errors); + }; + + +############################################################## +# +# Text +# +# + +BEGIN_PGML + +*Quadratic trigonometric equation with "tangent":* + +Solve for [`x`]: +>> [`` \large [$LHS] = [$RHS] ``] << + +Give expressions to represent all solutions to the equation: + + [`x = `] [________________________________________]{$ans->cmp(showLengthHints=>0, list_checker=>$periodicCheck)} + +* Give your answer in radians. +* Separate multiple solutions with commas. +* Use "[`n`]" as the parameter in your solution(s). +* Do not use decimal approximations. Use 'pi' to represent [` \pi `]. + +END_PGML + +BEGIN_PGML_HINT + +* Get the equation in standard form if not already +* Is there a trig function in common? Factor it! +* Use the zero-product property +* Solve each of the trig equations separately +* Collect _all_ answers for your final answer + +END_PGML_HINT + +COMMENT("Funded by US DoE Title V: Opening Gateways grant."); + +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-cosine.pg index c8ff143935..4a6af81030 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-cosine.pg @@ -235,7 +235,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-sine.pg index c65d7822e1..329ce000f7 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/ggb-amplitude-sine.pg @@ -233,7 +233,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/matching-amplitudes.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/matching-amplitudes.pg index 44fa841fc4..715c7b5e6c 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/matching-amplitudes.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/matching-amplitudes.pg @@ -115,7 +115,7 @@ Match the equations given below with their corresponding graphs: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/short-answer-amplitudes.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/short-answer-amplitudes.pg index 8372867f1f..a351d28727 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/short-answer-amplitudes.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Amplitude/short-answer-amplitudes.pg @@ -115,7 +115,7 @@ Enter the corresponding trigonometric expression for each graph: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['\\( y = \\) '.$fChoice[4]->ans_rule,['\\( y = \\) '.$fChoice[5]->ans_rule,rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-cosine.pg index 8a9d6aafb0..375db15622 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-cosine.pg @@ -257,7 +257,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-cosine.pg index 90076ce727..8895ee20c5 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-cosine.pg @@ -256,7 +256,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-sine.pg index f9b892518b..40a6e5a068 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-phase-sine.pg @@ -259,7 +259,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-sine.pg index f32d30e9d7..6a3cdfc93c 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-per-sine.pg @@ -249,7 +249,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-cosine.pg index da8181f535..c7744a5f6b 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-cosine.pg @@ -256,7 +256,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-sine.pg index 31f9f5fdd4..97a4a90143 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/amp-phase-sine.pg @@ -256,7 +256,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-cosine.pg index b60e66083a..735ffac7c2 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-cosine.pg @@ -256,7 +256,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-sine.pg index 3113299da6..03b13547ce 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Comprehensive/per-phase-sine.pg @@ -258,7 +258,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-cosine.pg index 94e07da8a3..b18e8bdbaa 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-cosine.pg @@ -240,7 +240,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-sine.pg index e1e4b10cb6..1dd7b54a13 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/ggb-period-sine.pg @@ -238,7 +238,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/matching-period.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/matching-period.pg index 47ef18a2b8..4b749dac3a 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/matching-period.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/matching-period.pg @@ -122,7 +122,7 @@ Match the equations given below with their corresponding graphs: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;"]], ['Graph E',['Graph F',rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/short-answer-period.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/short-answer-period.pg index c7803b5b6a..8c6088a5d5 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/short-answer-period.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Period/short-answer-period.pg @@ -126,7 +126,7 @@ Enter an equation for each graph: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;padding-top:2pt;"]], ['\\( y = \\) '.$fChoice[4]->ans_rule,['\\( y = \\) '.$fChoice[5]->ans_rule,rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-cosine.pg index d0e409ead9..01801351fb 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-cosine.pg @@ -251,7 +251,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-sine.pg index 9fdd846c34..d7dcf0cbb6 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/ggb-phaseshift-sine.pg @@ -251,7 +251,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-cosine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-cosine.pg index 1238cdf05c..395643c5f5 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-cosine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-cosine.pg @@ -143,7 +143,7 @@ Enter an equation for each graph: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;padding-top:2pt;"]], ['\\( y = \\) '.$f[4]->ans_rule,['\\( y = \\) '.$f[5]->ans_rule,rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-sine.pg b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-sine.pg index 2468d0bd19..6f8d73e0f8 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-sine.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setTrigonometry_-_Graphing_Phase_Shift/short-answer-phaseshift-sine.pg @@ -142,7 +142,7 @@ Enter an equation for each graph: [image(insertGraph($fIm[4]), width=>200, height=>200, tex_size=>400), [image(insertGraph($fIm[5]), width=>200, height=>200, tex_size=>400), rowcss=>"padding-bottom:2pt;padding-top:2pt;"]], ['\\( y = \\) '.$f[4]->ans_rule,['\\( y = \\) '.$f[5]->ans_rule,rowcss=>"padding:1pt;"]] ], - align => 'c c', + align => 'cc', center => 1, ); @]*** diff --git a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-unit-vector-components.pg b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-unit-vector-components.pg index 6c0db44b5c..56ee128897 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-unit-vector-components.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-unit-vector-components.pg @@ -417,7 +417,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-vector-components.pg b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-vector-components.pg index 938a4a43b4..ac7fa1d4cc 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-vector-components.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Components/ggb-vector-components.pg @@ -415,7 +415,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/ggb-magnitude-direction.pg b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/ggb-magnitude-direction.pg index 73f0ba6623..e3818a20e1 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/ggb-magnitude-direction.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/ggb-magnitude-direction.pg @@ -417,7 +417,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, ))); diff --git a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/vector-magnitude-angle.pg b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/vector-magnitude-angle.pg new file mode 100644 index 0000000000..df13d64be6 --- /dev/null +++ b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Magnitude_and_Direction/vector-magnitude-angle.pg @@ -0,0 +1,44 @@ +DOCUMENT(); +loadMacros("PGstandard.pl","PGML.pl"); +TEXT(beginproblem()); +$ShowPartialCorrectAnswers = 1; + +Context("Numeric"); +Context()->flags->set(reduceConstantFunctions=>0); + +# $variable = random( low, high, interval ); +$cc=random(2,8,1); +$vers=random(1,12,1); #$vers=12; +#1=45,2=135, 3=225, 4=315, 5=30, 6=60, 7=120, 8=150, 9=210, 10=240, 11=300, 12=330 + +if ($vers==1){$aa=$cc; $bb=$cc; $ansMag=Real($cc*sqrt(2)); $ansAng= Real(45)->with(period=>360);} +elsif ($vers==2){$aa=-$cc; $bb=$cc; $ansMag=Real($cc*sqrt(2)); $ansAng= Real(135)->with(period=>360);} +elsif ($vers==3){$aa=-$cc; $bb=-$cc; $ansMag=Real($cc*sqrt(2)); $ansAng= Real(225)->with(period=>360);} +elsif ($vers==4){$aa=$cc; $bb=-$cc; $ansMag=Real($cc*sqrt(2)); $ansAng= Real(315)->with(period=>360);} +elsif ($vers==5){$aa=Formula("$cc*sqrt(3)"); $bb=$cc; $ansMag=Real(2*$cc); $ansAng= Real(30)->with(period=>360);} +elsif ($vers==6){$aa=$cc; $bb=Formula("$cc*sqrt(3)"); $ansMag=Real(2*$cc); $ansAng= Real(60)->with(period=>360);} +elsif ($vers==7){$aa=-$cc; $bb=Formula("$cc*sqrt(3)"); $ansMag=Real(2*$cc); $ansAng= Real(120)->with(period=>360);} +elsif ($vers==8){$aa=Formula("-$cc*sqrt(3)"); $bb=$cc; $ansMag=Real(2*$cc); $ansAng= Real(150)->with(period=>360);} +elsif ($vers==9){$aa=Formula("-$cc*sqrt(3)"); $bb=-$cc; $ansMag=Real(2*$cc); $ansAng= Real(210)->with(period=>360);} +elsif($vers==10){$aa=-$cc; $bb=Formula("-$cc*sqrt(3)"); $ansMag=Real(2*$cc); $ansAng= Real(240)->with(period=>360);} +elsif($vers==11){$aa=$cc; $bb=Formula("-$cc*sqrt(3)"); $ansMag=Real(2*$cc); $ansAng= Real(300)->with(period=>360);} +else {$aa=Formula("$cc*sqrt(3)"); $bb=-$cc; $ansMag=Real(2*$cc); $ansAng= Real(330)->with(period=>360);} + + +# $answer = Object("expression"); +# Basic Object Options: Real, Point, Formula, Interval, Complex +#[```[$ansMag], [$ansAng], [$vers]```] + +BEGIN_PGML + +Find the magnitude and the direction angle in degrees for: +[```v=\langle [$aa],[$bb]\rangle ```] + +Magnitude: [`||v||=`] [__________]{$ansMag} + +Direction angle: [`\theta=`][__________]{$ansAng} + + +END_PGML +ENDDOCUMENT(); + diff --git a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Unit_Vectors/ggb-magnitude-angle.pg b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Unit_Vectors/ggb-magnitude-angle.pg index d4abdf0099..cf18290012 100644 --- a/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Unit_Vectors/ggb-magnitude-angle.pg +++ b/Contrib/CUNY/CityTech/Precalculus/setVectors_-_Unit_Vectors/ggb-magnitude-angle.pg @@ -420,7 +420,7 @@ END_SCRIPT TEXT($PAR, MODES(TeX=>$im, HTML=>$applet->insertAll( debug =>0, - reinitialize_button => 0, + reinitialize_button => 1, includeAnswerBox=>1, )));