diff --git a/Contrib/Wisconsin/EauClaire/calculus/AntiderivativePowerRuleIntroduction.pg b/Contrib/Wisconsin/EauClaire/calculus/AntiderivativePowerRuleIntroduction.pg new file mode 100644 index 0000000000..775d15dbb6 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/AntiderivativePowerRuleIntroduction.pg @@ -0,0 +1,327 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Power Rule') + +## DBsubject('Calculus') +## DBchapter('Derivatives') +## DBsection('Power Rule') +## Date('07/20/2024') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", + "answerHints.pl", + "PGML.pl", + "scaffold.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", + "parserPopUp.pl", # <------ NEEDED FOR DROPDOWN MENUS + "niceTables.pl", + "parserFormulaUpToConstant.pl", + "PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "scaffold.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl", + "freemanMacros.pl", + "AnswerFormatHelp.pl", + "Parser.pl", + "niceTables.pl", + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + #"scaffold.pl", + "unionTables.pl", + "parserPopUp.pl",#NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", # <---- MAKES BOXES PURPLE + #"PGcourse.pl",# Customization file for the course +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +#$same_derivative = PopUp( +# ["Choose one", "yes","no"], +# "yes"); + +Context("Numeric"); +Context()->noreduce('(-x)-y'); +Context()->noreduce('(-x)+y'); +Context()->variables->add(u=>"Real", h=>"Real", n=>"Real", k=>"Real", f=>"Real", g=>"Real"); + +$a1=random(2,4); +$a2=non_zero_random(-4,4); +$a3=non_zero_random(-4,4); +$a4=non_zero_random(-4,4); +$a5=random(2,6); +$a6=non_zero_random(-10,10); +$a7=non_zero_random(-10,10); +while($a7==$a6){$a7=non_zero_random(-10,10);} + +$f1=Formula("$a1*x^4+$a2*x^2")->reduce; +$f1d=Formula("4*$a1*x^3+2*$a2*x")->reduce; +$f2=Formula("$a3*x^5+$a4*x")->reduce; +$f2d=Formula("5*$a3*x^4+$a4")->reduce; +$f3=FormulaUpToConstant("$a5*x^3")->reduce; +$f3d=Formula("3*$a5*x^2")->reduce; +$f4=Formula("$a5*x^3+$a6")->reduce; +$f5=Formula("$a5*x^3+$a7")->reduce; + +$power3=FormulaUpToConstant("(x^4)/4"); +#$y1=non_zero_random(-10,10); + +#$g1d->{limits}=[1,16]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. + +#SRAND($psvn); #FIX RANDOM VARIABLES ACROSS MULTIPLE PROBLEMS + +################################### +# Main text +########################################### +# The scaffold +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Derivatives"); + +Context()->texStrings; +BEGIN_PGML + +We have lots of practice taking derivatives. Given [`f(x)=x^3`], for example, we know that [`f'(x)=3x^2`]. + +But if we were given [`f'(x)=3x^2`] and not told [`f(x)`], could we have figured it out? + +Let's take a few more derivatives for practice: + +[`\frac d{dx}\left([$f1]\right)=`] [_]{$f1d} + +[`\frac d{dx}\left([$f2]\right)=`] [_]{$f2d} + +[`\frac d{dx}\left([$f4]\right)=`] [_]{$f3d} + +[`\frac d{dx}\left([$f5]\right)=`] [_]{$f3d} + +END_PGML +Section::End(); + +Section::Begin("Antiderivatives"); + +BEGIN_PGML + +Notice that the last two functions we looked at had the same derivative! So if we are told that [`f'(x)=[$f3d]`], there is more than one possibility for [`f(x)`]. + +In fact there are infinitely many possibilities! Any function of the form [`f(x)=[$f3]`], where [`C`] is any real number, has this derivative (since the derivative of [`C`] is 0). So we can say [`[$f4]`] is _an_ antiderivative of [`[$f3d]`], but not _the_ antiderivative. + +The full family of antiderivatives, [`[$f3]`], is often called the *general antiderivative*. You can write it by taking any antiderivative and simply adding [`+C`] to the end. + +Find the general antiderivative of [`[$f1d]`]: [_]{FormulaUpToConstant("$f1")->reduce} + +Find the general antiderivative of [`[$f2d]`]: [_]{FormulaUpToConstant("$f2")->reduce} + +END_PGML +Section::End(); + +Section::Begin("Back to \(x^3\) and \(3x^2\)"); + +BEGIN_PGML + +Let's revisit [`f'(x)=3x^2`] and [`f(x)=x^3`]. In other words + +[``\frac d{dx}\big(x^3\big)=3x^2``] + +Let's divide both sides by 3: + +[``\frac13\cdot\frac d{dx}\Big(``][_]{Formula("x^3")}[``\Big)=``] [_]{Formula("x^2")} + +END_PGML +Section::End(); + +Section::Begin("Slight rearrangement"); + +BEGIN_PGML + +Now let's rewrite the left side slightly: + +[``\frac13\cdot\frac d{dx}\big(x^3\big)=x^2``] + +[``\frac d{dx}\Big(``][_]{Formula("(x^3)/3")}[``\Big)=x^2``] + +END_PGML +Section::End(); + +Section::Begin("Another exponent"); + +BEGIN_PGML + +Let's do something similar with some other exponents. First, a derivative: + +[``\frac d{dx}\big(x^4\big)=``] [_]{Formula("4*(x^3)")} + +END_PGML +Section::End(); + +Section::Begin("Another antiderivative"); + +BEGIN_PGML + +[_]{1/4}[``\cdot\frac d{dx}\big(x^4\big)=x^3``] + +[``\frac d{dx}\bigg(``][_]{Formula("(x^4)/4")}[``\bigg)=x^3``] + +END_PGML +Section::End(); + +Section::Begin("Continuing the pattern"); + +BEGIN_PGML + +Do the same for the next few exponents: + +[``\frac d{dx}\bigg(``][_]{Formula("(x^5)/5")}[``\bigg)=x^4``] + +[``\frac d{dx}\bigg(``][_]{Formula("(x^6)/6")}[``\bigg)=x^5``] + +[``\frac d{dx}\bigg(``][_]{Formula("(x^7)/7")}[``\bigg)=x^6``] + +[``\frac d{dx}\bigg(``][_]{Formula("(x^8)/8")}[``\bigg)=x^7``] + +END_PGML +Section::End(); + +Section::Begin("General antiderivatives"); + +BEGIN_PGML + +Don't forget: Each function has an infinite family of antiderivatives, not just one. Enter the general antiderivatives of each function in the table below. + +[@ +DataTable( +[ + ["function","general antiderivative"], + ['\(x^3\)',ans_rule(10)], + ['\(x^4\)',ans_rule(10)], + ['\(x^5\)',ans_rule(10)], + ['\(x^6\)',ans_rule(10)], + ['\(x^7\)',ans_rule(10)], +], +align => '|c | c|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS(FormulaUpToConstant("(x^4)/4")->cmp); +ANS(FormulaUpToConstant("(x^5)/5")->cmp); +ANS(FormulaUpToConstant("(x^6)/6")->cmp); +ANS(FormulaUpToConstant("(x^7)/7")->cmp); +ANS(FormulaUpToConstant("(x^8)/8")->cmp); + +Section::End(); + +Section::Begin("Pattern in terms of \(n\)"); + +BEGIN_PGML + +Based on the pattern, the general antiderivative of [`x^n`] is [_]{FormulaUpToConstant("(x^(n+1))/(n+1)")} + +END_PGML + +Section::End(); + +Section::Begin("Indefinite integral notation"); + +BEGIN_PGML + +We have a notation for the general antiderivative of any function [`f(x)`]. It looks like this: + +[```\int f(x)dx```] + +The [``\int``] is called the *integral* symbol, and an expression like this overall is called an *indefinite integral*. The function [`f(x)`], whose general antiderivative we want, is called the *integrand*. It is always sandwiched between the integral symbol and [`dx`], where [`x`] is the input variable of the function. + +So if [`F(x)`] is one of the antiderivatives of [`f(x)`] (in other words, if [`F'(x)=f(x)`]), then + +[```\int f(x)dx=F(x)+C```] + +We now have everything we need for the... + +[@ openDiv({ "class" => "importantFormula" }) @]* +Power Rule: + +For any constant exponent [`n`]: + +>>[``\int x^n dx=``] [_]{FormulaUpToConstant("x^(n+1)/(n+1)")}<< + +as long as [`n\ne`] [_]{-1} + +[@ closeDiv() @]* + + +END_PGML + +Section::End(); + +Section::Begin("Basic antiderivative rules"); + +BEGIN_PGML + +Here are some more basic rules, besides the power rule: + +[@ openDiv({ "class" => "importantFormula" }) @]* +Sum and Difference Rules: + +>>[``\int\big(f(x)+g(x)\big)dx=\int f(x)dx+\int g(x)dx``]<< + +>>[``\int\big(f(x)-g(x)\big)dx=\int f(x)dx-\int g(x)dx``]<< + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* + +Constant Multiple Rule: + +>>[``\int k\cdot f(x)dx=k\int f(x)dx``]<< + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Exponential Rule: + +>>[``\int e^xdx=e^x+C``]<< + +[@ closeDiv() @]* + +END_PGML + +Section::End(); + + Scaffold::End(); +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/Concavity_problem_1_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/Concavity_problem_1_of_3.pg new file mode 100644 index 0000000000..0f691354ff --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/Concavity_problem_1_of_3.pg @@ -0,0 +1,482 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Rates of change') +## Date('Summer 2023') +## Author('Warren Shull') +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS +); + +loadMacros("customCSS.pl"); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +$increase = PopUp( + ["Choose one", "increasing","decreasing"], + "increasing"); + +$positive = PopUp( + ["Choose one", "positive","negative"], + "positive"); + +$decrease = PopUp( + ["Choose one", "increasing","decreasing"], + "decreasing"); + +$negative = PopUp( + ["Choose one", "positive","negative"], + "negative"); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + + +$unique_div_id = "increasing_concave_up"; +$width = 700; +$height = 400; + + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id2 = "increasing_concave_down"; +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id3 = "decreasing_concave_up"; +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id4 = "decreasing_concave_down"; +$desmos_div4 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->variables->add(t=>'Real'); + + +$x1_mid = non_zero_random(-10,10); #middle, where $a begins +$x2_mid = non_zero_random(-10,10); #middle, where $a begins +$x3_mid = non_zero_random(-10,10); #middle, where $a begins +$x4_mid = non_zero_random(-10,10); #middle, where $a begins +$y1 = non_zero_random(-10,10); #up or down shift from default +$y2 = non_zero_random(-10,10); #up or down shift from default +$y3 = non_zero_random(-10,10); #up or down shift from default +$y4 = non_zero_random(-10,10); #up or down shift from default + +$x1_max = $x1_mid+1.9; +$x1_min = $x1_mid-2; +$x2_max = $x2_mid+2; +$x2_min = $x2_mid-1.9; +$x3_max = $x3_mid+2; +$x3_min = $x3_mid-1.9; +$x4_max = $x4_mid+1.9; +$x4_min = $x4_mid-2; + +$g1 = Formula("$y1-sqrt(16-(x-$x1_min)^2)"); +$g2 = Formula("$y2+sqrt(16-(x-$x2_max)^2)"); +$g3 = Formula("$y3-sqrt(16-(x-$x3_max)^2)"); +$g4 = Formula("$y4+sqrt(16-(x-$x4_min)^2)"); + +$g1_max = $g1->eval(x=>$x1_max); +$g1_min = $g1->eval(x=>$x1_min); +$g2_max = $g2->eval(x=>$x2_max); +$g2_min = $g2->eval(x=>$x2_min); +$g3_max = $g3->eval(x=>$x3_max); +$g3_min = $g3->eval(x=>$x3_min); +$g4_max = $g4->eval(x=>$x4_max); +$g4_min = $g4->eval(x=>$x4_min); + +if ($g1_max<$g1_min){ #swap if they're in the wrong order + $g1_temp=$g1_max; + $g1_max=$g1_min; + $g1_min=$g1_temp; +} + +if ($g2_max<$g2_min){ #swap if they're in the wrong order + $g2_temp=$g2_max; + $g2_max=$g2_min; + $g2_min=$g2_temp; +} + +if ($g3_max<$g3_min){ #swap if they're in the wrong order + $g3_temp=$g3_max; + $g3_max=$g3_min; + $g3_min=$g3_temp; +} + +if ($g4_max<$g4_min){ #swap if they're in the wrong order + $g4_temp=$g4_max; + $g4_max=$g4_min; + $g4_min=$g4_temp; +} + +## THIS IS PROBLEM 1 OF A 3 PROBLEM SERIES INTRODUCING CONCAVITY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); + +## END PASSCODE CODE + +############################################################## +# +# Text +# +# + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +BEGIN_PGML + +[@ openDiv({ "class" => "problemPurpose" }) @]* +Purpose: + +As we have seen, the derivative of a function is _another function_, which almost always has a derivative of its own. You have found second derivatives algebraically before, but can we tell anything about them visually? + +This problem examines the four basic shapes a curve can have, connecting them to the first and second derivatives. + +[@ closeDiv() @]* + +END_PGML + +Section::Begin("Curve 1"); + +BEGIN_PGML + + + +[@ openDiv({ "class" => "promptOrInstruction" }) @]* +Here is a curve and its tangent line. Move the slider to see how the tangent line changes! Then answer the questions below. +[@ closeDiv() @]* + +[@ $desmos_div @]* + +Using the slider for [`a`], estimate the slope of the tangent line when [`x=a`]. + +* When [`x=[$x1_min+1.8]`], the slope is [`g'\big([$x1_min+1.8]\big)=`] [____]{$g1->D->eval(x=>$x1_min+1.8)->cmp(tolType => 'absolute',tolerance => .01)} +* When [`x=[$x1_min+2.8]`], the slope is [`g'\big([$x1_min+2.8]\big)=`] [____]{$g1->D->eval(x=>$x1_min+2.8)->cmp(tolType => 'absolute',tolerance => .05)} +* When [`x=[$x1_min+3.6]`], the slope is [`g'\big([$x1_min+3.6]\big)=`] [____]{$g1->D->eval(x=>$x1_min+3.6)->cmp(tolType => 'absolute',tolerance => .1)} + +--- + +[@ openDiv({ "class" => "importantFormula" }) @]* +For any function [`f`], as long as these derivatives exist: +* [`f'`] is positive where [`f`] is increasing. +* [`f''`] is positive where [`f'`] is increasing +* [`f'''`] is positive where [`f''`] is increasing + +[`\Box'`] is positive where [`\Box`] is increasing. + +⭐️ The second derivative is positive where the first derivative is increasing. + +[@ closeDiv() @]* + +In the graph above, as [`x`] increases (as we move from left to right): + +* [`g(x)`] is [_]{$increase}, so [`g'(x)`] is [_]{$positive}. +* [`g'(x)`] is [_]{$increase}, so [`g''(x)`] is [_]{$positive}. + +END_PGML +Section::End(); + + + + + + + + + +Section::Begin("Curve 2"); + +BEGIN_PGML + + + +[@ $desmos_div2 @]* + +Using the slider for [`a`], estimate the slope of the tangent line when [`x=a`]. + +* When [`x=[$x2_max-3.6]`] the slope is [`g'\big([$x2_max-3.6]\big)=`] [____]{$g2->D->eval(x=>$x2_max-3.6)->cmp(tolType => 'absolute',tolerance => .1)} +* When [`x=[$x2_max-2.8]`] the slope is [`g'\big([$x2_max-2.8]\big)=`] [____]{$g2->D->eval(x=>$x2_max-2.8)->cmp(tolType => 'absolute',tolerance => .05)} +* When [`x=[$x2_max-1.8]`] the slope is [`g'\big([$x2_max-1.8]\big)=`] [____]{$g2->D->eval(x=>$x2_max-1.8)->cmp(tolType => 'absolute',tolerance => .01)} + +As [`x`] increases (as we move from left to right): + +* [`g(x)`] is [_]{$increase}, so [`g'(x)`] is [_]{$positive}. +* [`g'(x)`] is [_]{$decrease}, so [`g''(x)`] is [_]{$negative}. + +END_PGML +Section::End(); + +Section::Begin("Curve 3"); + +BEGIN_PGML + + +[@ $desmos_div3 @]* + +Using the slider for [`a`], estimate the slope of the tangent line when [`x=a`]. + +* When [`x=[$x3_max-3.6]`] the slope is [`g'\big([$x3_max-3.6]\big)=`] [____]{$g3->D->eval(x=>$x3_max-3.6)->cmp(tolType => 'absolute',tolerance => .1)} +* When [`x=[$x3_max-2.8]`] the slope is [`g'\big([$x3_max-2.8]\big)=`] [____]{$g3->D->eval(x=>$x3_max-2.8)->cmp(tolType => 'absolute',tolerance => .05)} +* When [`x=[$x3_max-1.8]`] the slope is [`g'\big([$x3_max-1.8]\big)=`] [____]{$g3->D->eval(x=>$x3_max-1.8)->cmp(tolType => 'absolute',tolerance => .01)} + +As [`x`] increases (as we move from left to right): + +* [`g(x)`] is [_]{$decrease}, so [`g'(x)`] is [_]{$negative}. +* [`g'(x)`] is [_]{$increase}, so [`g''(x)`] is [_]{$positive}. + +END_PGML +Section::End(); + +Section::Begin("Curve 4"); + +BEGIN_PGML + + +[@ $desmos_div4 @]* + +Using the slider for [`a`], estimate the slope of the tangent line when [`x=a`]. + +* When [`x=[$x4_min+1.8]`] the slope is [`g'\big([$x4_min+1.8]\big)=`] [____]{$g4->D->eval(x=>$x4_min+1.8)->cmp(tolType => 'absolute',tolerance => .01)} +* When [`x=[$x4_min+2.8]`] the slope is [`g'\big([$x4_min+2.8]\big)=`] [____]{$g4->D->eval(x=>$x4_min+2.8)->cmp(tolType => 'absolute',tolerance => .05)} +* When [`x=[$x4_min+3.6]`] the slope is [`g'\big([$x4_min+3.6]\big)=`] [____]{$g4->D->eval(x=>$x4_min+3.6)->cmp(tolType => 'absolute',tolerance => .1)} + +As [`x`] increases (as we move from left to right): + +* [`g(x)`] is [_]{$decrease}, so [`g'(x)`] is [_]{$negative}. +* [`g'(x)`] is [_]{$decrease}, so [`g''(x)`] is [_]{$negative}. + +END_PGML +Section::End(); + +Section::Begin("Food for thought"); + +BEGIN_PGML + +We know that increasing functions have positive derivatives, and decreasing functions have negative derivatives. + +* But what about the second derivative? +* Graphs 1 and 3 both had positive second derivatives. What do they have in common visually? And what do graphs 2 and 4 have in common visually? + +Keep those questions in mind as we go forward. + +[% 🔑 The passcode for the next question is [`[$passcode1]`]. Enter it here: [_]{$passcode1} %] + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +$right1 = $x1_max + 2; +$top1 = $g1_max + 2; +$left1 = $x1_min - 2; +$bottom1 = $g1_min - 2; + +$right2 = $x2_max + 2; +$top2 = $g2_max + 2; +$left2 = $x2_min - 2; +$bottom2 = $g2_min - 2; + +$right3 = $x3_max + 2; +$top3 = $g3_max + 2; +$left3 = $x3_min - 2; +$bottom3 = $g3_min - 2; + +$right4 = $x4_max + 2; +$top4 = $g4_max + 2; +$left4 = $x4_min - 2; +$bottom4 = $g4_min - 2; + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'slider', latex: 'a=$x1_mid', sliderBounds: {min: $x1_min, max: $x1_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))', label: '(a,g(a))', showLabel: 'true'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line', secret:'true'}, + { id: 'slope', latex: 'g\'(a)', secret: 'true'}, + { id: 'g_curve', latex: 'g(x)=$y1-\\sqrt{16-(x-$x1_min)^2} \\left\\{$x1_min\\leq x\\leq$x1_max\\right\\}', secret:'true'}, + ]); + + my_calculator.setMathBounds({ + left: $left1, + right: $right1, + bottom: $bottom1, + top: $top1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst2 = document.getElementById("$unique_div_id2"); + + var my_calculator2 = Desmos.Calculator(arstarst2, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator2.setExpressions([ + { id: 'slider', latex: 'a=$x2_mid', sliderBounds: {min: $x2_min, max: $x2_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))', label: 'point of tangency', showLabel:'true'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line', secret:'true'}, + { id: 'slope', latex: 'g\'(a)', secret: 'true'}, + { id: 'g_curve', latex: 'g(x)=$y2+\\sqrt{16-(x-$x2_max)^2} \\left\\{$x2_min\\leq x\\leq$x2_max\\right\\}', secret: 'true'}, + ]); + + my_calculator2.setMathBounds({ + left: $left2, + right: $right2, + bottom: $bottom2, + top: $top2 + }); + + my_calculator2.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator2.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst3 = document.getElementById("$unique_div_id3"); + + var my_calculator3 = Desmos.Calculator(arstarst3, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator3.setExpressions([ + { id: 'slider', latex: 'a=$x3_mid', sliderBounds: {min: $x3_min, max: $x3_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))', label:'is the slope here increasing or decreasing?', showLabel:'true'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line', secret:'true'}, + { id: 'slope', latex: 'g\'(a)', secret: 'true'}, + { id: 'g_curve', latex: 'g(x)=$y3-\\sqrt{16-(x-$x3_max)^2} \\left\\{$x3_min\\leq x\\leq$x3_max\\right\\}', secret: 'true'}, + ]); + + my_calculator3.setMathBounds({ + left: $left3, + right: $right3, + bottom: $bottom3, + top: $top3 + }); + + my_calculator3.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator3.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst4 = document.getElementById("$unique_div_id4"); + + var my_calculator4 = Desmos.Calculator(arstarst4, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator4.setExpressions([ + { id: 'slider', latex: 'a=$x4_mid', sliderBounds: {min: $x4_min, max: $x4_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))', label: 'move left to right. slope increase or decrease?'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line', secret:'true'}, + { id: 'slope', latex: 'g\'(a)', secret: 'true'}, + { id: 'g_curve', latex: 'g(x)=$y4+\\sqrt{16-(x-$x4_min)^2} \\left\\{$x4_min\\leq x\\leq$x4_max\\right\\}', secret: 'true'}, + ]); + + my_calculator4.setMathBounds({ + left: $left4, + right: $right4, + bottom: $bottom4, + top: $top4 + }); + + my_calculator4.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator4.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/PowerRuleIntroduction.pg b/Contrib/Wisconsin/EauClaire/calculus/PowerRuleIntroduction.pg new file mode 100644 index 0000000000..d9b2088cb0 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/PowerRuleIntroduction.pg @@ -0,0 +1,530 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Power Rule') + +## DBsubject('Calculus') +## DBchapter('Derivatives') +## DBsection('Power Rule') +## Date('07/20/2024') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", +"PGML.pl", + "scaffold.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "parserFunction.pl", + "parserFunctionPrime.pl" +); + +loadMacros("niceTables.pl"); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$same_derivative = PopUp( + ["Choose one", "yes","no"], + "yes"); + +Context("Numeric"); +parser::FunctionPrime->Enable(); +parserFunction("f(x)" => "x^3"); # dummy function +parserFunction("g(x)" => "x^4"); # dummy function +Context()->noreduce('(-x)-y'); +Context()->noreduce('(-x)+y'); +Context()->variables->add(u=>"Real", h=>"Real", n=>"Real", k=>"Real"); + +$sum=Compute("f'(x)+g'(x)"); +$difference=Compute("f'(x)-g'(x)"); +$constant_multiple=Compute("k*f'(x)"); + +$y1=non_zero_random(-10,10); +$m1=non_zero_random(-10,10); +while($m1==1){ + $m1=non_zero_random(-10,10); +} +$b1=non_zero_random(-10,10); +$c1=random(2,10); +$c2=random(2,10); +$c3=random(2,10); +$c4=random(2,10); +$c5=random(2,10); + +$f1_nearby=Formula("$m1(x+h)+$b1")->reduce; + +$power_rule=Formula("nx^(n-1)"); +$negative_exponent_derivative=Formula("-x^(-2)")->reduce; +$square_root_derivative=Formula("(1/2)x^(-1/2)"); + +$g1=Formula("x^(1/2)")->reduce; +$g1->{limits}=[1,16]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$cg1=Formula("$c1*$g1")->reduce; +$cg1->{limits}=[1,16]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$g1d=Formula("(1/2)*x^(-1/2)")->reduce; +$g1d->{limits}=[1,16]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. + +$g2=Formula("e^x")->reduce; +$cg2=Formula("$c2*$g2")->reduce; +$g2d=Formula("e^x")->reduce; + +$g3=Formula("x^3")->reduce; +$cg3=Formula("$c3*$g3")->reduce; +$g3d=Formula("3*x^2")->reduce; + +$g4=Formula("x^2")->reduce; +$cg4=Formula("$c4*$g4")->reduce; +$g4d=Formula("2*x")->reduce; + +$g5=Formula("x^(-4)")->reduce; +$cg5=Formula("$c5*$g5")->reduce; +$g5d=Formula("-4*x^(-5)")->reduce; + +#SRAND($psvn); #FIX RANDOM VARIABLES ACROSS MULTIPLE PROBLEMS + +################################### +# Main text +########################################### +# The scaffold +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Definition review & constant"); + +Context()->texStrings; +BEGIN_PGML + +Let's review the definition of the derivative: + +[@ openDiv({ "class" => "importantFormula" }) @]* +[```f'(x)=\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h```] +[@ closeDiv() @]* + +Let's try applying this to some functions we know. We will start with the constant function [`f(x)=[$y1]`]. + +Retype that here: [`f(x)=`] [_]{$y1} + +END_PGML +Section::End(); + +Section::Begin("Slope"); + +BEGIN_PGML + +Based on what you know from algebra, what is the slope of [`y=[$y1]`]? [_]{0} + +[%(If you're not sure, go to Desmos.com, type the equation, and find [`\frac{\mbox{rise}}{\mbox{run}}`] between any two points.)%] + +END_PGML +Section::End(); + +Section::Begin("Does the definition agree?"); + +BEGIN_PGML + +Let's see if the definition of the derivative gives us the same answer! + +If [`f(x)=[$y1]`], then [`f(x+h)=[$y1]`], so: + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{[$y1]-[$y1]}h\\ +&=&\lim_{h\rightarrow0}\frac{0}h\\ +&=&\lim_{h\rightarrow0}(0)=0\\ +\end{eqnarray*} +```] + +Is this the same answer as before? [_]{$same_derivative} + +END_PGML +Section::End(); + +Section::Begin("Other straight lines"); + +BEGIN_PGML + +If [`f(x)=[$m1]x+[$b1]`], then based on what you know from algebra, the slope of the line is [`f'(x)=`] [_]{$m1}. + +Meanwhile, [`f(x+h)=`] [_]{$f1_nearby} + +END_PGML +Section::End(); + +Section::Begin("Does the definition agree?"); + +BEGIN_PGML + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{([$m1](x+h)+[$b1])-([$m1]x+[$b1])}h\\ +&=&\lim_{h\rightarrow0}\frac{[$m1]x+[$m1]h+[$b1]-[$m1]x-[$b1]}h\\ +&=&\lim_{h\rightarrow0}\frac{[$m1]h}h=[$m1]\\ +\end{eqnarray*} +```] + +Is this the same answer as before? [_]{$same_derivative} + +END_PGML +Section::End(); + +Section::Begin("Higher exponents"); + +BEGIN_PGML + +Let's work out [`x^2`], [`x^3`], and [`x^4`] and see if there's a pattern! + +---- + +Let [`f(x)=x^2`]. Then: + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{(x+h)^2-x^2}h\\ +&=&\lim_{h\rightarrow0}\frac{x^2+2xh+h^2-x^2}h\\ +&=&\lim_{h\rightarrow0}\frac{2xh+h^2}h\\ +&=&\lim_{h\rightarrow0}\frac{h(2x+h)}h\\ +&=&\lim_{h\rightarrow0}(2x+h)=2x\\ +\end{eqnarray*} +```] + +---- + +Let [`f(x)=x^3`]. Then: + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{(x+h)^3-x^3}h\\ +&=&\lim_{h\rightarrow0}\frac{(x+h)(x+h)(x+h)-x^3}h\\ +&=&\lim_{h\rightarrow0}\frac{(x+h)(x^2+2xh+h^2)-x^3}h\\ +&=&\lim_{h\rightarrow0}\frac{(x(x^2+2xh+h^2)+h(x^2+2xh+h^2)-x^3}h\\ +&=&\lim_{h\rightarrow0}\frac{x^3+2x^2h+xh^2+x^2h+2xh^2+h^3-x^3}h\\ +&=&\lim_{h\rightarrow0}\frac{3x^2h+3xh^2+h^3}h\\ +&=&\lim_{h\rightarrow0}\frac{h(3x^2+3xh+h^2)}h\\ +&=&\lim_{h\rightarrow0}(3x^2+3xh+h^2)=3x^2\\ +\end{eqnarray*} +```] + +---- + +Let [`f(x)=x^4`]. Then: + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{(x+h)^4-x^4}h\\ +&=&\lim_{h\rightarrow0}\frac{(x+h)(x+h)(x+h)(x+h)-x^4}h\\ +&=&\lim_{h\rightarrow0}\frac{(x^2+2xh+h^2)(x^2+2xh+h^2)-x^4}h\\ +&=&\lim_{h\rightarrow0}\frac{x^2(x^2+2xh+h^2)+2xh(x^2+2xh+h^2)+h^2(x^2+2xh+h^2)-x^4}h\\ +&=&\lim_{h\rightarrow0}\frac{x^4+2x^3h+x^2h^2+2x^3h+4x^2h^2+2xh^3+x^2h^2+2xh^3+h^4-x^4}h\\ +&=&\lim_{h\rightarrow0}\frac{4x^3h+6x^2h^2+4xh^3+h^4}h\\ +&=&\lim_{h\rightarrow0}\frac{h(4x^3+6x^2h+4xh^2+h^3)}h\\ +&=&\lim_{h\rightarrow0}(4x^3+6x^2h+4xh^2+h^3)=4x^3\\ +\end{eqnarray*} +```] + +---- + +Here's what we have so far: + +[`\frac d{dx}(x^2)=2x`] + +[`\frac d{dx}(x^3)=3x^2`] + +[`\frac d{dx}(x^4)=4x^3`] + +What comes next? + +[`\frac d{dx}(x^5)=`] [_]{Formula("5x^4")} + +[`\frac d{dx}(x^6)=`] [_]{Formula("6x^5")} + +So for any exponent [`n`], no matter how large: + +[`\frac d{dx}(x^n)=`] [_]{$power_rule} + +END_PGML +Section::End(); + +Section::Begin("Negative exponents"); + +BEGIN_PGML + +Let's see if [`f(x)=\frac1x=x^{-1}`] also fits this pattern. + +In this case, [`n=-1`], so we should expect + +[`f'(x)=nx^{n-1}=`] [_]{$negative_exponent_derivative} + +Let's see if this matches what we get from the definition: + +END_PGML +Section::End(); + +Section::Begin("Does the definition agree?"); + +BEGIN_PGML + +If [`f(x)=\frac1x=x^{-1}`], then + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{\frac1{x+h}-\frac1x}h\\ +&=&\lim_{h\rightarrow0}\frac{\frac1{x+h}\cdot\frac xx-\frac1x\cdot\frac{x+h}{x+h}}h\\ +&=&\lim_{h\rightarrow0}\frac{\frac x{x(x+h)}-\frac{x+h}{x(x+h)}}h\\ +&=&\lim_{h\rightarrow0}\frac{\frac{x-(x+h)}{x(x+h)}}h\\ +&=&\lim_{h\rightarrow0}\frac{x-x-h}{xh(x+h)}\\ +&=&\lim_{h\rightarrow0}\frac{(-1)h}{xh(x+h)}\\ +&=&\lim_{h\rightarrow0}\frac{-1}{x(x+h)}\\ +&=&\frac{-1}{x(x)}\\ +&=&\frac{-1}{x^2}=-x^{-2}\\ +\end{eqnarray*} +```] + +Is this the same answer as before? [_]{$same_derivative} + +END_PGML +Section::End(); + +Section::Begin("Fractional exponents"); + +BEGIN_PGML + +Let's see if [`f(x)=\sqrt x=x^{\frac12}`] also fits this pattern. + +In this case, [`n=\frac12`], so we should expect + +[`f'(x)=nx^{n-1}=`] [_]{$square_root_derivative} + +Let's see if this matches what we get from the definition: + +END_PGML +Section::End(); + +Section::Begin("Does the definition agree?"); + +BEGIN_PGML + +If [`f(x)=\sqrt x=x^{\frac12}`], then + +[``` +\begin{eqnarray*} +f'(x) +&=&\lim_{h\rightarrow0}\frac{\sqrt{x+h}-\sqrt x}h\\ +&=&\lim_{h\rightarrow0}\frac{\sqrt{x+h}-\sqrt x}h\cdot\frac{\sqrt{x+h}+\sqrt x}{\sqrt{x+h}+\sqrt x}\\ +&=&\lim_{h\rightarrow0}\frac{\big(\sqrt{x+h}-\sqrt x\big)\big(\sqrt{x+h}+\sqrt x\big)}{h(\sqrt{x+h}+\sqrt x)}\\ +&=&\lim_{h\rightarrow0}\frac{\big(\sqrt{x+h}\big)^2-\big(\sqrt x\big)^2}{h(\sqrt{x+h}+\sqrt x)}\\ +&=&\lim_{h\rightarrow0}\frac{(x+h)-x}{h(\sqrt{x+h}+\sqrt x)}\\ +&=&\lim_{h\rightarrow0}\frac{h}{h(\sqrt{x+h}+\sqrt x)}\\ +&=&\lim_{h\rightarrow0}\frac{1}{\sqrt{x+h}+\sqrt x}\\ +&=&\frac{1}{\sqrt{x}+\sqrt x}\\ +&=&\frac{1}{2\sqrt x}\\ +&=&\frac{1}{2x^{\frac12}}\\ +&=&\frac12x^{-\frac12}\\ +\end{eqnarray*} +```] + +Is this the same answer as before? [_]{$same_derivative} + +END_PGML +Section::End(); + +Section::Begin("Power Rule"); + +BEGIN_PGML + +[@ openDiv({ "class" => "importantFormula" }) @]* +Power Rule: + +For any constant exponent [`n`]: + +>>[``\frac d{dx}(x^n)=nx^{n-1}``]<< + +[@ closeDiv() @]* + +Retype it here: + +>>[``\frac d{dx}(x^n)=``] [_]{$power_rule}<< + +END_PGML +Section::End(); + +Section::Begin("Sums and differences"); + +BEGIN_PGML + +What happens when you add or subtract two functions? If you know both separate derivatives, can you find the derivative of the sum or difference? + +Using the definition of a derivative, let's find [``\frac d{dx}[f(x)+g(x)]``]: + +[``` +\begin{eqnarray*} +\frac d{dx}[f(x)+g(x)] +&=&\lim_{h\rightarrow0}\frac{[f(x+h)+g(x+h)]-[f(x)+g(x)]}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)+g(x+h)-f(x)-g(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)+g(x+h)-g(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h+\lim_{h\rightarrow0}\frac{g(x+h)-g(x)}h\\ +&=&f'(x)+g'(x)\\ +\end{eqnarray*} +```] + +Similarly, + +[``` +\begin{eqnarray*} +\frac d{dx}[f(x)-g(x)] +&=&\lim_{h\rightarrow0}\frac{[f(x+h)-g(x+h)]-[f(x)-g(x)]}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)-g(x+h)-f(x)+g(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)-g(x+h)+g(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{[f(x+h)-f(x)]-[g(x+h)-g(x)]}h\\ +&=&\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h-\lim_{h\rightarrow0}\frac{g(x+h)-g(x)}h\\ +&=&f'(x)-g'(x)\\ +\end{eqnarray*} +```] + +Fill in the missing pieces of both answers below: + +[`\frac d{dx}[f(x)+g(x)]=`] [_]{$sum} + +[`\frac d{dx}[f(x)-g(x)]=`] [_]{$difference} + +END_PGML + +Section::End(); + +Section::Begin("Constant multiples"); + +BEGIN_PGML + +As it turns out, the same does not work for multiplication. We will learn more about that in the next section. + +For now, let's see what happens if we multiply a function by a constant. + +Suppose [`f`] is any function and [`k`] is any real number. Using the definition of a derivative, let's find [``\frac d{dx}[k\cdot f(x)]``]: + +[``` +\begin{eqnarray*} +\frac d{dx}[k\cdot f(x)] +&=&\lim_{h\rightarrow0}\frac{k\cdot f(x+h)-k\cdot f(x)}h\\ +&=&\lim_{h\rightarrow0}\frac{k[f(x+h)-f(x)]}h\\ +&=&\lim_{h\rightarrow0}k\cdot\frac{f(x+h)-f(x)}h\\ +&=&k\cdot\lim_{h\rightarrow0}\frac{f(x+h)-f(x)}h=k\cdot f'(x)\\ +\end{eqnarray*} +```] + +Retype the answer here: + +[`\frac d{dx}[k\cdot f(x)]=`] [_]{$constant_multiple} + +END_PGML + +Section::End(); + +Section::Begin("e"); + +BEGIN_PGML + +The video below explains what is special about the number [`e`]: + +[@ youtube("YG15m2VwSjA?start=252"); @]* + +[`\frac d{dx}\left(e^x\right)=`] [_]{Formula("e^x")->reduce} + +END_PGML + +Section::End(); + +Section::Begin("Putting it all together"); + +BEGIN_PGML + +Quick reminder of all the rules: + +[@ openDiv({ "class" => "importantFormula" }) @]* +Power Rule: + +For any constant exponent [`n`]: + +>>[``\frac d{dx}(x^n)=nx^{n-1}``]<< + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Sum and Difference Rules: + +>>[``\frac d{dx}[f(x)+g(x)]=f'(x)+g'(x)``]<< + +>>[``\frac d{dx}[f(x)-g(x)]=f'(x)-g'(x)``]<< + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Constant Multiple Rule: + +>>[``\frac d{dx}[k\cdot f(x)]=k\cdot f'(x)``]<< + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Exponential Rule: + +>>[``\frac d{dx}(e^x)=e^x``]<< + +[@ closeDiv() @]* + + +Let [`g(x)=[$c1]\sqrt{x}-[$c2]e^x+[$c3]x^3-[$c4]x^2+\frac{[$c5]}{x^4}`]. Let's find [`g'(x)`]. Note that if the expression [``\frac d{dx}``] + +[``g'(x)=\frac d{dx}\bigg([$c1]\sqrt{x}-[$c2]e^x+[$c3]x^3-[$c4]x^2+\frac{[$c5]}{x^4}\bigg)``] + +[``=\frac d{dx}\Big(``][_]{$cg1}[``\Big)-\frac d{dx}\Big(``][_]{$cg2}[``\Big)+\frac d{dx}\Big(``][_]{$cg3}[``\Big)-\frac d{dx}\Big(``][_]{$cg4}[``\Big)+\frac d{dx}\bigg(``][_]{$cg5}[``\bigg)``] + +END_PGML + +Section::End(); + +Section::Begin("=..."); + +BEGIN_PGML + +[``=[$c1]\cdot\frac d{dx}\Big(``][_]{$g1}[``\Big)-[$c2]\cdot\frac d{dx}\Big(``][_]{$g2}[``\Big)+[$c3]\cdot\frac d{dx}\Big(``][_]{$g3}[``\Big)-[$c4]\cdot\frac d{dx}\Big(``][_]{$g4}[``\Big)+[$c5]\cdot\frac d{dx}\bigg(``][_]{$g5}[``\bigg)``] + +[``=[$c1]\cdot``][_]{$g1d}[``-[$c2]\cdot``][_]{$g2d}[``+[$c3]\cdot``][_]{$g3d}[``-[$c4]\cdot``][_]{$g4d}[``+[$c5]\cdot``][_]{$g5d} + +Keep these rules in mind as you work on the remaining problems. + +END_PGML + +Section::End(); + + Scaffold::End(); +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/ProductRuleIntroduction.pg b/Contrib/Wisconsin/EauClaire/calculus/ProductRuleIntroduction.pg new file mode 100644 index 0000000000..f9f4df8a34 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/ProductRuleIntroduction.pg @@ -0,0 +1,382 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Product Rule') + +## DBsubject('Calculus') +## DBchapter('Derivatives') +## DBsection('Product Rule') +## Date('06/28/2024') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + +# THERE ARE DERIVATIVES OF SIN AND COS IN THIS PROBLEM, BUT NOT OTHER TRIG FUNCTIONS. I (WARREN SHULL) PLAN ON TEACHING DERIVATIVES OF SINE AND COSINE BEFORE TEACHING THE PRODUCT RULE. + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", +"PGML.pl", + "scaffold.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS +); + +loadMacros("niceTables.pl"); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$productmatches = PopUp( + ["Choose one", "yes","no"], + "no"); +$productrulematches = PopUp( + ["Choose one", "yes","no"], + "yes"); + +Context("Numeric"); +Context()->noreduce('(-x)-y'); +Context()->noreduce('(-x)+y'); + +$b1=non_zero_random(-10,10); +$b2=random(3,9); +$b3=random(2,10); +$b4=random(2,10); +$b5=non_zero_random(-10,10); +$b6=random(2,10); +$b7=non_zero_random(-10,10); +$b8=random(2,10); +while ($b8==$b6){ + $b8=random(2,10); +} +$b9=non_zero_random(-10,10); +$b10=random(2,10); +$b11=non_zero_random(-10,10); +$b12=random(2,10); +while ($b12==$b10 or $b6+$b10==$b8+$b12 or $b6+$b12==$b8+$b10){ + $b12=random(2,10); +} +$b13=non_zero_random(-10,10); +$b14=random(2,10); + +#THE LINES BELOW ARE REPEATED IN COMMENTS NEAR WHERE THEY ARE USED + +$term1=Formula("$b5*$b6*$b9*x^($b6+$b10-1)")->reduce; +$term2=Formula("$b5*$b6*x^($b6-1)*$b11*x^$b12")->reduce; +$term3=Formula("$b7*$b8*x^($b8-1)*$b9*x^$b10")->reduce; +$term4=Formula("$b7*$b8*x^($b8-1)*$b11*x^$b12")->reduce; +$term5=Formula("$b9*$b10*x^($b10-1)*$b5*x^$b6")->reduce; +$term6=Formula("$b9*$b10*x^($b10-1)*$b7*x^$b8")->reduce; +$term7=Formula("$b11*$b12*x^($b12-1)*$b5*x^$b6")->reduce; +$term8=Formula("$b11*$b12*x^($b12-1)*$b7*x^$b8")->reduce; +$new_f=Formula("x^3+$b13")->cmp(); +$new_gp=Formula("$b14*x^($b14-1)")->cmp(); +$fgp=Formula("e^x*(sin(x)+cos(x))")->reduce; +$new_fgp=Formula("[$b14]*x^[$b14-1]*e^x+e^x*x^[$b14]")->reduce; +$newfgp=Formula("3x^2*cos(x)-(x^3+$b13)*sin(x)")->reduce; + + +#SRAND($psvn); #FIX RANDOM VARIABLES ACROSS MULTIPLE PROBLEMS + +Context()->variables->add(u=>"Real"); + +################################### +# Main text +########################################### +# The scaffold +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Sum and Difference review"); + +Context()->texStrings; +BEGIN_PGML + +Let's review how to take derivatives when two or more functions are added or subtracted! + +Let [`f(x)=[$b1]*x^[$b2]-[$b3]\sin x+[$b4]e^x`]. Then + +>>[``f'(x)=``] [_]{Formula("[$b2]*[$b1]*x^([$b2]-1)-[$b3]*cos(x)+[$b4]*e^x")->reduce}<< + +END_PGML +Section::End(); + +Section::Begin("Example of a product"); + +BEGIN_PGML + +As we just saw, if functions are added or subtracted, we can simply add or subtract their derivatives. + +Does the same thing work for multiplication? Let's find out! + +END_PGML + +$f=Formula("$b5*x^$b6+$b7*x^$b8")->reduce; +$fp=Formula("[$b5]*[$b6]*x^([$b6]-1)+$b7*$b8*x^([$b8]-1)")->reduce; +$g=Formula("[$b9]*x^[$b10]+$b11*x^[$b12]")->reduce; +$gp=Formula("[$b9]*[$b10]*x^([$b10]-1)+$b11*$b12*x^([$b12]-1)")->reduce; + +BEGIN_PGML + +Let [`f(x)=[$f]`] and [`g(x)=[$g]`]. Let's try multiplying their derivatives: + +>>[``f'(x)=``] [_]{$fp}<< + +>>[``g'(x)=``] [_]{$gp}<< + +[%[`\$b5=[$b5],\$b6=[$b6],\$b7=[$b7],\$b8=[$b8]`] + +[`\$b9=[$b9],\$b10=[$b10],\$b11=[$b11],\$b12=[$b12]`]%] + +Retype these two answers in the parentheses (in order), and then FOIL them out (in order). + +>>[``f'(x)*g'(x)=\Big(``][_]{Formula("[$b5]*[$b6]*x^([$b6]-1)+[$b7]*[$b8]*x^([$b8]-1)")->reduce}[``\Big)\Big(``][_]{Formula("[$b9]*[$b10]*x^([$b10]-1)+[$b11]*[$b12]*x^([$b12]-1)")->reduce}[``\Big) +=``] [_]{Formula("[$b5]*[$b6]*x^([$b6]-1)*[$b9]*[$b10]*x^([$b10]-1)")->reduce} [`` ++``] [_]{Formula("[$b5]*[$b6]*x^([$b6]-1)*[$b11]*[$b12]*x^([$b12]-1)")->reduce} [`` ++``] [_]{Formula("[$b7]*[$b8]*x^([$b8]-1)*[$b9]*[$b10]*x^([$b10]-1)")->reduce} [`` ++``] [_]{Formula("[$b7]*[$b8]*x^([$b8]-1)*[$b11]*[$b12]*x^([$b12]-1)")->reduce}<< + +Is that the derivative of [`f(x)*g(x)`]? Let's find out! + +END_PGML +Section::End(); + +Section::Begin("Multiplying out the product"); + +BEGIN_PGML + +As before, [`f(x)=[$f]`] and [`g(x)=[$g]`]. Let's multiply them and FOIL them out! Make sure to keep everything in order as before. + +>>[``f(x)*g(x)=\Big(``][_]{Formula("[$b5]*x^[$b6]+[$b7]*x^[$b8]")->reduce} [``\Big)\Big(``][_]{Formula("[$b9]*x^[$b10]+[$b11]*x^[$b12]")->reduce}[``\Big) +=``] [_]{Formula("[$b5]*x^[$b6]*[$b9]*x^[$b10]")->reduce} [`` ++``] [_]{Formula("[$b5]*x^[$b6]*[$b11]*x^[$b12]")->reduce} [`` ++``] [_]{Formula("[$b7]*x^[$b8]*[$b9]*x^[$b10]")->reduce} [`` ++``] [_]{Formula("[$b7]*x^[$b8]*[$b11]*x^[$b12]")->reduce}<< + +>>[``\frac d{dx}[f(x)g(x)]=``] [_]{Formula("[$b5]*[$b9]*([$b6]+[$b10])*x^([$b6]+[$b10]-1) ++ +[$b5]*[$b11]*([$b6]+[$b12])*x^([$b6]+[$b12]-1) ++ +[$b7]*[$b9]*([$b8]+[$b10])*x^([$b8]+[$b10]-1) ++ +[$b7]*[$b11]*([$b8]+[$b12])*x^([$b8]+[$b12]-1) +")->reduce}<< + +Is this the same answer as [`f'(x)*g'(x)`]? [_]{$productmatches} + +END_PGML +Section::End(); + +Section::Begin("Product Rule"); + +BEGIN_PGML + +As we just saw, those two answers are NOT the same. So the derivative of a product is NOT found by multiplying the two separate derivatives! + +So...how do we find it? + +Here is a video describing the product rule visually (watch from 4:12 to 8:40): + +[@ youtube("YG15m2VwSjA?start=252"); @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Product Rule: + +If [`f`] and [`g`] are differentiable functions, then + +>>[``\frac d{dx}[f(x)g(x)]=f'(x)g(x)+g'(x)f(x)``]<< +[@ closeDiv() @]* + +Let's see if this works on the example we just looked at! + +[%WANT TO HAVE F AND G SHOW UP %] + +[@ +DataTable( +[ + ['\( f(x) ='.$f.'\)','\(f\'(x)=\)' . ans_rule(10)], + ['\( g(x) ='.$g.'\)','\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($fp->cmp()); +ANS($gp->cmp()); + +BEGIN_PGML + +Put it all together (in order): + +>>[``(fg)'(x)=\frac d{dx}[f(x)g(x)]=f'(x)\cdot g(x)+g'(x)\cdot f(x)=\Big(``][_]{$fp}[`\Big)\cdot\Big(`][_]{$g}[`\Big)+\Big(`][_]{$gp}[`\Big)\cdot\Big(`][_]{$f}[`\Big)`]<< + +END_PGML + +#$f=Formula("[$b5]*x^[$b6]+$b7*x^[$b8]")->reduce; +#$fp=Formula("[$b5]*[$b6]*x^([$b6]-1)+$b7*$b8*x^([$b8]-1)")->reduce; +#$g=Formula("[$b9]*x^[$b10]+$b11*x^[$b12]")->reduce; +#$gp=Formula("[$b9]*[$b10]*x^([$b10]-1)+$b11*$b12*x^([$b12]-1)")->reduce; + +#$term1=Formula("$b5*$b6*$b9*x^($b6+$b10-1)")->reduce; +#$term2=Formula("$b5*$b6*x^($b6-1)*$b11*x^$b12")->reduce; +#$term3=Formula("$b7*$b8*x^($b8-1)*$b9*x^$b10")->reduce; +#$term4=Formula("$b7*$b8*x^($b8-1)*$b11*x^$b12")->reduce; +#$term5=Formula("$b9*$b10*x^($b10-1)*$b5*x^$b6")->reduce; +#$term6=Formula("$b9*$b10*x^($b10-1)*$b7*x^$b8")->reduce; +#$term7=Formula("$b11*$b12*x^($b12-1)*$b5*x^$b6")->reduce; +#$term8=Formula("$b11*$b12*x^($b12-1)*$b7*x^$b8")->reduce; + +BEGIN_PGML + +Now FOIL out both pairs of factors (in order) + +>>[``(fg)'(x)=\dots=\bigg( ``] +[_]{$term1} +[``+``] +[_]{$term2} +[``+``] +[_]{$term3} +[``+``] +[_]{$term4} +[``\bigg)+\bigg( ``] +[_]{$term5} +[``+``] +[_]{$term6} +[``+``] +[_]{$term7} +[``+``] +[_]{$term8} +[``\bigg)``] +<< + + +END_PGML +Section::End(); + +Section::Begin("Simplify"); + +BEGIN_PGML + +Simplify your previous answer. + +>>[``(fg)'(x)=``][_]{$fp*$g+$gp*$f}<< + +Does this match your answer from the "Multiplying out the product" part? [_]{$productrulematches} + +END_PGML +Section::End(); + +Section::Begin("More practice"); + +BEGIN_PGML + +Let's find the derivative of [`e^x\sin x`] + +[@ +DataTable( +[ + ['\( f(x) = \) ' . ans_rule(10),'\(f\'(x)=\)' . ans_rule(10)], + ['\( g(x) = \) ' . ans_rule(10),'\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + +END_PGML + +ANS(Formula("e^x")->cmp()); +ANS(Formula("e^x")->cmp()); +ANS(Formula("sin(x)")->cmp()); +ANS(Formula("cos(x)")->cmp()); + +#$fgp=Formula("e^x*(sin(x)+cos(x))")->reduce + +BEGIN_PGML + +>>[``(fg)'(x)=f'(x)g(x)+g'(x)f(x)=``][_]{$fgp}<< + +---- + +Let's find the derivative of [`(x^3+[$b13])\cos x`] + +[@ +DataTable( +[ + ['\( f(x) = \) ' . ans_rule(10),'\(f\'(x)=\)' . ans_rule(10)], + ['\( g(x) = \) ' . ans_rule(10),'\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + +END_PGML + +#$new_f=Formula("x^3+$b13")->cmp(); +ANS($new_f); +ANS(Formula("3x^2")->cmp()); +ANS(Formula("cos(x)")->cmp()); +ANS(Formula("-sin(x)")->cmp()); + +#$newfgp=Formula("3x^2*cos(x)-(x^3+$b13)*sin(x)")->reduce; + +BEGIN_PGML + +>>[``(fg)'(x)=f'(x)g(x)+g'(x)f(x)=``][_]{$newfgp}<< + +----- + +Find [`\frac d{dx}\left(x^[$b14]e^x\right)`] + +[@ +DataTable( +[ + ['\( f = \) ' . ans_rule(10),'\(f\'=\)' . ans_rule(10)], + ['\( g = \) ' . ans_rule(10),'\(g\'=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + +END_PGML + +#$new_gp=Formula("$b14*x^($b14-1)")->cmp(); +ANS(Formula("x^$b14")->cmp()); +ANS($new_gp); +ANS(Formula("e^x")->cmp()); +ANS(Formula("e^x")->cmp()); + +#$new_fgp=Formula("[$b14]*x^[$b14-1]*e^x+e^x*x^[$b14]")->reduce; + +BEGIN_PGML + +>>[``(fg)'(x)=``][_]{$new_fgp}<< + +END_PGML +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + +Section::End(); + + Scaffold::End(); + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/SubstitutionIntroduction.pg b/Contrib/Wisconsin/EauClaire/calculus/SubstitutionIntroduction.pg new file mode 100644 index 0000000000..4aac8b6ce1 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/SubstitutionIntroduction.pg @@ -0,0 +1,395 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Integration, Substitution') + +## DBsubject('Calculus') +## DBchapter('Integrals') +## DBsection('Integration by substitution') +## Date('6/28/2023') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + +DOCUMENT(); # This should be the first executable line in the problem. + + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", +"PGML.pl", + "scaffold.pl", + "PGcourse.pl", # Customization file for the course +); + +loadMacros("niceTables.pl", "parserFormulaUpToConstant.pl"); + +Context("Numeric"); + +Context()->variables->add(u=>"Real", dx=>"Real", du=>"Real"); + +Context()->noreduce('(-x)-y'); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$b2=non_zero_random(-10,10); +$b3=non_zero_random(-10,10); +$b4=non_zero_random(-10,10); +$b5=non_zero_random(-10,10); +#$b6=non_zero_random(-10,10); +$b8=random(2,10); +$b8down1=$b8-1; +$b9=random(2,10); +$b9down1=$b9-1; +while ($b9==$b8){ + $b9=random(2,10); +} + +$b1=non_zero_random(-6,6); +$b0=random(2,6); +$b10=non_zero_random(-10,10); +$b11=non_zero_random(-10,10); +#$b12=non_zero_random(-10,10); + +$a1=$b4*$b2; +$a2=$b4*$b3+$b5; +$a3=$b2*$b5+$b3; + + +$ans3 = Formula("$a1*x+$a3")->reduce; +$ans4 = Formula("$a1*x+$a2")->reduce; +$ans1 = Formula("$b11*sin^$b8(x)*cos^$b8(x)+$b10*sin^$b9(x)*cos^$b9(x)")->reduce; +$ans2 = Formula("sin($b11*x^$b8+$b10*x^$b9)*cos($b11*x^$b8+$b10*x^$b9)")->reduce; +$ans8 = Formula("sqrt(u)"); +$ans10 = Formula("sin u cos u")->reduce; +#$ans11 = Formula("$b14/u")->reduce; +#$ans11d = Formula("-$b14/u^2")->reduce; +#$ans12 = Formula("[$b17]*x+[$b13]")->reduce; +#$ans12d = Formula("1")->reduce; +$ans13 = Formula("u^3-4u^2+5")->reduce; +$ans14 = Formula("tan x")->reduce; +$ans15 = 2*$b0; + + +$g3=Formula("$b11*x^$b8+$b10*x^$b9")->reduce; +$g3d=Formula("($b11*$b8)*x^($b8-1)+($b10*$b9)*x^($b9-1)")->reduce; + +SRAND($psvn); + +$b7=non_zero_random(-10,10); +$ans5 = Formula("sqrt(x^2+$b7)")->reduce; +$ans5a = FormulaUpToConstant("sqrt(x^2+$b7)")->reduce; + + +$ans5->{limits}=[4,8]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$ans5a->{limits}=[4,8]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$ans5d=Formula("x/(sqrt(x^2+[$b7]))")->reduce; +$ans6 = Formula("x+$b7")->reduce; +$ans9 = Formula("x^2+[$b7]")->reduce; +$b13=non_zero_random(-10,10); +$b14=non_zero_random(-10,10); +$b16=random(2,10); +$b15=random(2,10); +$b17=random(2,10); +$ans7 = Formula("$b14/([$b16]*x+[$b13])")->reduce; + +################################### +# Main text +########################################### +# The scaffold + +BEGIN_PGML + +[@ openDiv({ "class" => "problemPurpose" }) @]* +This problem teaches a technique for "undoing the chain rule" -- integration of functions that are derivatives of compositions. +[@ closeDiv() @]* + +END_PGML + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Part 1: Recall the chain rule for derivatives"); + +Context()->texStrings; +BEGIN_PGML + +Use the Chain Rule to differentiate: + +[`h(x)=e^{x^2}`] + +Write [`h(x)=f(g(x))`], with [`f = f(u)`] and [`u = g(x)`]: + +[@ +DataTable( +[ + ['\( f(u) =\)',ans_rule(10),'\(\hspace{1cm}\)','\(f\'(u)=\)',ans_rule(10)], + ['\( u=g(x) =\)',ans_rule(10),'\(\hspace{1cm}\)','\(g\'(x)=\)',ans_rule(100)] +], +align => 'r l l l', +); +@]*** + +END_PGML + +ANS(Formula("e^u")->reduce->cmp()); +ANS( Compute("e^u")->reduce->cmp() ); +ANS( Compute("x^2")->reduce->cmp() ); +ANS( Compute("2x")->reduce->cmp() ); + +BEGIN_PGML + +Now compute the derivatives with the Chain Rule: + +[`f'(u)\cdot g'(x)=`] [_]{Formula("2x*e^u")->reduce} + +[`h'(x)=f'(g(x))\cdot g'(x)=`] [_]{Formula("2xe^{x^2}")->reduce} + +END_PGML +Section::End(); + + + + +Section::Begin("Part 2: Complete example of 'undoing the Chain Rule'"); + +BEGIN_PGML + +Suppose you are asked to evaluate + +[```\int 2xe^{x^2}\,dx```] + +This seems kinda complicated, so we're going to re-write the integral to make it simpler, in a more familiar form. + +Let's try using the letter [`u`] for [`x^2`], just like before! If we set [`u=x^2`], we can replace [`x^2`] with [`u`]: + +[``` +\int 2xe^{x^2}\,dx +=\int 2xe^{u}\,dx +```] + +We *cannot* evaluate this integral in its current form. It mixes two variables, [`x`] and [`u`], and this course is *single* variable calculus. + +However, since we wrote [`u`] as a function of [`x`], we can find its derivative: + +[``` +\begin{eqnarray*} +u&=&x^2\\ +\frac{du}{dx}&=&2x\\ +\end{eqnarray*} +```] + +Then we can _multiply both sides by_ [`dx`]: + +[``` +\begin{eqnarray*} +\frac{du}{dx}&=&2x\\ +du&=&2x\,dx\\ +\end{eqnarray*} +```] + +Now we have what we need to rewrite the integral *only* in terms of [`u`]: + +[``` +\begin{aligned} +\int 2xe^{x^2}\,dx &=\int 2xe^{u}\,dx & \quad & \textnormal{substitute } u = x^2\\ +&=\int e^{u}2x\,dx & & \textnormal{re-order }\\ +&=\int e^{u}\,du & & \textnormal{substitute } 2x \, dx = du\\ +\end{aligned} +```] + +Now that the integral contains just one variable, we can evaluate it! + +[```\int 2xe^{x^2}\,dx=\cdots=\int e^{u}\,du=e^u+C```] + +Since the problem was given with only [`x`], we can't leave [`u`] in our final answer. So we un-substitute [`u = x^2`]: + +[```\int 2xe^{x^2}\,dx=\cdots=e^u+C=e^{x^2}+C```] + +And as we showed in Part 1 of this problem, the derivative of our answer is the integrand we were given, just as it should be! + +Here is a video demonstrating this example in handwritten form: + +[@ +kalturaShull("1_g908rb6q") +@]* + +🎯 Retype the final answer here: + +[``\int2xe^{x^2}\,dx=``][_]{FormulaUpToConstant("e^(x^2)")->reduce} + +END_PGML +Section::End(); + +Section::Begin("Part 3a: Change variable to \(u\)"); + +BEGIN_PGML + +Let's solve this integral: + +[```\int\frac x{\sqrt{x^2+[$b7]}}\,dx```] + +[@ openDiv({ "class" => "importantFormula" }) @]* +If one function looks like it's "inside" another, that inside function is often a good choice for [`u`]. +[@ closeDiv() @]* + +In this case, let's choose [`u=x^2+[$b7]`]. 🎯 Replace [`x^2+[$b7]`] with [`u`] in the integral: + +>>[``\int\frac x{\sqrt{x^2+[$b7]}}\,dx=\int``][_]{Formula("x/sqrt(u)")->reduce}[``dx``]<< + +🎯 Find the derivative of [`u`]: + +>>[``\frac{du}{dx}=``][_]{Formula("2x")->reduce}<< + +🎯 Multiply both sides by [`dx`]: + +>>[``du=``][_]{Formula("2x*dx")->reduce}<< + +END_PGML +Section::End(); + + +Section::Begin("Part 3b: Integrate simpler function"); + +BEGIN_PGML + +At the moment, our integral can be written as + +[```\int\frac1{\sqrt u}x\,dx```] + +There is no [`2x\,dx`] in the integral. However, we can do one more rearrangement. Previously we had + +[```du=2x\,dx```] + +Now we will _divide both sides by 2_: + +[```\frac12\,du=x\,dx```] + +Now we have what we need! + +[```\int\frac x{\sqrt{x^2+[$b7]}}\,dx +=\int\frac x{\sqrt{u}}\,dx +=\int\frac1{\sqrt{u}}x\,dx +=\int\frac1{\sqrt{u}}\left(\frac12\,du\right) +=\frac12\int\frac1{\sqrt{u}}\,du +```] + +Now we find the antiderivative in terms of [`u`]: + +>>[`\displaystyle\int\frac x{\sqrt{x^2+[$b7]}}\,dx=\dots +=\frac12\int\frac1{\sqrt{u}}\,du +=\frac12\int\frac1{u^{\frac12}}\,du +=\frac12\int u^{-\frac12}\,du +=`] [_]{FormulaUpToConstant("sqrt(u)")->reduce}<< + +END_PGML +Section::End(); + +Section::Begin("Part 3c: Un-substitute back to \(x\)"); + +BEGIN_PGML + +Express your previous answer in terms of [`x`]: + +>>[`\displaystyle\int\frac x{\sqrt{x^2+[$b7]}}\,dx=\dots +=u^{\frac12}+C +=\sqrt u+C +=`] [_]{$ans5a}<< + +[%Can I include a point-testing limit in-line?%] + +We are finished! Notice that the derivative of your answer is the integrand we started with! + +END_PGML +Section::End(); + +Section::Begin("Part 4a: Another practice problem"); + +#$g3=Formula("$b11*x^$b8+$b10*x^$b9")->reduce; +#$g3d=Formula("($b11*$b8)*x^($b8-1)+($b10*$b9)*x^($b9-1)")->reduce; + +BEGIN_PGML + +Using a similar process, find + +[```\displaystyle\int([$g3d])\cos([$g3])\,dx +```] + +[`u=`] [_]{Formula("[$b11]*x^[$b8]+[$b10]*x^[$b9]")->reduce} + +[`du=\Big(`][_]{Formula("[$b11]*[$b8]x^([$b8]-1)+[$b10]*[$b9]x^([$b9]-1)")->reduce}[`\Big)\,dx`] + +Rewrite the integral in terms of [`u`]: + +>>[`\displaystyle\int([$g3d])\cos([$g3])\,dx=\int`][_]{Formula("cos(u)*du")->reduce}<< + +END_PGML +Section::End(); + +Section::Begin("Part 4b: antidifferentiate and un-substitute"); + +BEGIN_PGML + +Take the antiderivative in terms of [`u`]: + +>>[`\displaystyle\int\cos u\,du=`] [_]{FormulaUpToConstant("sin(u)")->reduce}<< + +And rewrite it in terms of [`x`]: + +>>[`\dots=`] [_]{FormulaUpToConstant("sin([$b11]*x^[$b8]+[$b10]*x^[$b9])")}<< + +END_PGML +Section::End(); + +Section::Begin("Part 5: Two more practice problems"); + +BEGIN_PGML + +Let's see if we can solve + +[```\int(3\tan^2x-[$b15*2]\tan x)\sec^2x\,dx```] [%WHY DOES ORDER OF 2 AND $b15 MATTER???%] + +>>[`u=`] [_]{Formula("tan(x)")->reduce}<< + +>>[`du=`] [_]{Formula("sec^2(x)*dx")->reduce}<< + +In the next three boxes: first rewrite the integral in terms of [`u`], then take the antiderivative, then rewrite the answer in terms of [`x`]. + +[``\int(3\tan^2x-[$b15*2]\tan x)\sec^2x\,dx=\int``] [_]{Formula("(3*u^2-2*[$b15]*u)*du")->reduce} [`=`] [_]{FormulaUpToConstant("u^3-[$b15]*u^2")->reduce} [`=`] [_]{FormulaUpToConstant("tan^3(x)-[$b15]*tan^2(x)")->reduce} + +----- + +Let's solve + +[```\int\frac{[$b17*$b14*-1]}{([$b17]x+[$b13])^2}\,dx```] + +[`u=`] [_]{Formula("[$b17]*x+[$b13]")->reduce} + +[`du=`] [_]{Formula("[$b17]*dx")->reduce} + +The next steps: 🎯 transform into [`u`]; integrate in terms of [`u`]; un-substitute and get final answer: + +>>[``\int\frac{[$b17*$b14*-1]}{([$b17]x+[$b13])^2}\,dx=\int``] [_]{Formula("[$b14*-1]/(u^2)*du")->reduce} [`=`] [_]{FormulaUpToConstant("[$b14]/u")->reduce} [`=`] [_]{FormulaUpToConstant("[$b14]/([$b17]*x+[$b13])")->reduce}<< + +END_PGML +Section::End(); + +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + + Scaffold::End(); + + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_1_of_2_composition_review.pg b/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_1_of_2_composition_review.pg new file mode 100644 index 0000000000..f52c8dcfe5 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_1_of_2_composition_review.pg @@ -0,0 +1,299 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Trig') + +## DBsubject('Calculus') +## DBchapter('Derivatives') +## DBsection('Chain Rule') +## Date('6/28/2023') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", +"PGML.pl", + "scaffold.pl", + "PGcourse.pl", # Customization file for the course +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$b2=non_zero_random(-10,10); +$b3=non_zero_random(-10,10); +$b4=non_zero_random(-10,10); +$b5=non_zero_random(-10,10); +#$b6=non_zero_random(-10,10); + +$b8=random(2,10); + +$b9=random(2,10); + +while ($b9==$b8){ + $b9=random(-10,10); +} + +Context()->noreduce('(-x)-y'); + +$f=Formula("$b2*x+$b3")->reduce; +$g=Formula("$b4*x+$b5")->reduce; + +$b1=non_zero_random(-10,10); +$b10=non_zero_random(-10,10); +$b11=non_zero_random(-10,10); +#$b12=non_zero_random(-10,10); + +$a1=$b4*$b2; +$a2=$b4*$b3+$b5; +$a3=$b2*$b5+$b3; + +Context("Numeric"); + +Context()->variables->add(u=>"Real"); + +$ans3 = Formula("$a1*x+$a3")->reduce; +$ans4 = Formula("$a1*x+$a2")->reduce; +$ans1 = Formula("$b11*sin^$b8(x)*cos^$b8(x)+$b10*sin^$b9(x)*cos^$b9(x)")->reduce; +$ans2 = Formula("sin($b11*x^$b8+$b10*x^$b9)*cos($b11*x^$b8+$b10*x^$b9)")->reduce; +$ans8 = Formula("sqrt(u)"); + +$ans10 = Formula("sin u cos u")->reduce; +$ans13 = Formula("u^3-4u^2+5")->reduce; +$ans14 = Formula("tan x")->reduce; +Context()->noreduce('(-x)-y'); +$g3=Formula("$b11*x^$b8+$b10*x^$b9")->reduce; + + +## THIS IS PROBLEM 1 OF A 2 PROBLEM SERIES INTRODUCING THE CHAIN RULE. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); + +## END PASSCODE CODE + +$b7=non_zero_random(-10,10); + +$ans5 = Formula("sqrt(x^2+$b7)")->reduce; +$ans5->{limits}=[4,8]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$ans6 = Formula("x+$b7")->reduce; +$ans9 = Formula("x^2+[$b7]")->reduce; +$b13=non_zero_random(-10,10); +$b14=non_zero_random(-10,10); +$b17=random(2,10); +$ans11 = Formula("$b14/u")->reduce; +$ans12 = Formula("[$b17]*x+[$b13]")->reduce; +$ans7 = Formula("$b14/([$b17]*x+[$b13])")->reduce; + + +################################### +# Main text + +BEGIN_PGML + +In this section, we will find the derivatives of compositions of functions, such as [`f(g(x))`]. Here is a quick refresher on what compositions are (this video also appeared in the composition review homework set): + +END_PGML + +Scaffold::Begin(can_open => "always", is_open => "never"); +Section::Begin("Function composition (7:41)"); + +BEGIN_PGML + +[@ +kalturaShull("1_3fssli1q") +@]* + +END_PGML + +Section::End(); + +Scaffold::End(); + +BEGIN_TEXT +$PAR +END_TEXT + +BEGIN_PGML + +In this problem, we will practice finding compositions. In the next one, we will see how to take their derivatives. + +END_PGML + +# The scaffold +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Basic compositions"); + +Context()->texStrings; +BEGIN_PGML +Suppose [` f(x)=x^2 `] and [` g(x)=x + [$b1] `]. Then + +[``` f(g(x))=f(x+[$b1])=(x+[$b1])^2 ```] + +while + +[``` g(f(x))=g\left(x^2\right)=x^2+[$b1] ```] + +END_PGML +Context()->noreduce('(-x)-y'); +BEGIN_PGML +----- + +Let [` f(x)=[$f]`] and [` g(x)=[$g]`]. + +What is [` f(g(x)) `] ? [____]{$ans3} + +What is [` g(f(x)) `] ? [____]{$ans4} + +----- + +Let [` f(x)=\sqrt{x} `] and [` g(x)=x^2+[$b7] `] + +What is [` f(g(x)) `] ? [____]{$ans5} + +What is [` g(f(x)) `] ? [____]{$ans6} + +----- + +Let [` f(x)=\sin x\cos x `] and [` g(x)=[$g3] `]. + +What is [` f(g(x))`]? [_]{Formula("sin($g3)cos($g3)")} + +What is [`g(f(x))`]? [_]{$ans1} + +END_PGML +Section::End(); + +Section::Begin("Part 2: Different variable names"); + +BEGIN_PGML + +Part of the confusion with these problems is: you have to replace the variable [`x`] with a whole function [`f(x)`] or [`g(x)`]. In the first example, we had [` f(x)=x^2`] and [`g(x)=x+[$b1]`]. To find [`f(g(x))`], we had to replace [`x`] with [`g(x)=x+[$b1]`], even though [`x`] and [`x+[$b1]`] are NEVER the same. + +A great way around this problem is to use another letter for the inside function. Let's try using [`u`] to equal [`g(x)`], so that [`f(g(x))`] is really [`f(u)`]. If you are given + +[```f(u)=u^2```] + +and + +[```g(x)=x+[$b1]```] + +then [`u=g(x)=x+[$b1]`], so [`f(g(x))=f(u)=u^2=(x+[$b1])^2`]. + +----- + +Let [` f(u)=[$b2]u+[$b3] `] and [` g(x)=[$b4]x+[$b5] `]. + +What is [` f(g(x)) `] ? [____]{$ans3} + +----- + +Let [` f(u)=\sqrt{u} `] and [` g(x)=x^2+[$b7] `] + +What is [` f(g(x)) `] ? [____]{$ans5} + +----- + +Let [` f(u)=\sin u\cos u `] and [` g(x)=[$g3] `]. + +What is [` f(g(x))`]? [_]{$ans2} + +----- + +Let [` f(u)=\frac{[$b14]}{u} `] and [` g(x)=[$b17]*x+[$b13]`]. + +What is [` f(g(x))`]? [_]{$ans7} + +END_PGML + +Section::End(); + +Section::Begin("Part 3: Separating a composition into 2 parts"); + +BEGIN_PGML + +But we often won't be given [`f`] and [`g`] separately. Sometimes we are given the composition as a whole, and we need to separate it. In fact, that will be an essential skill to find derivatives! + +Suppose you are given [`(x+[$b1])^2`] and asked to express it as [`f(g(x))`]. I recommend using [`u`] for the inside function. In this case, + +[```u=g(x)=x+[$b1]```] + +and + +[```f(g(x))=f(u)=u^2```]. + +then [`u=g(x)=x+[$b1]`], so [`f(g(x))=f(u)=u^2=(x+[$b1])^2`]. + +For the next few exercises, use [`u=g(x)`], and rewrite [`f(g(x))`] as [`f(u)`]. + +----- + +Suppose [`f(g(x))=[$ans5]`]. + +[` f(u)=`][_]{$ans8} + +[` g(x)=`][_]{$ans9} + + +----- + +Suppose [`f(g(x))=\sin([$g3])\cos([$g3])`]. + +[`f(u)=`][_]{$ans10} + +[` g(x)=`][_]{$g3} + +----- + +Suppose [`f(g(x))=[$ans7]`]. + +[`f(u)=`][_]{$ans11} + +[`g(x)=`][_]{$ans12} + +----- + +Suppose [`f(g(x))=\tan^3(x)-4\tan^2(x)+5`]. + +[`f(u)=`][_]{$ans13} + +[`g(x)=`][_]{$ans14} + +END_PGML + +Section::End(); + +#Section::Begin("Part 4: Passcode"); + +#BEGIN_PGML + +#The passcode for this question is [$passcode1]. + +#Enter it here: [_]{$passcode1} + +#END_PGML +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + +#Section::End(); + + Scaffold::End(); + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_2_of_2_introduction.pg b/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_2_of_2_introduction.pg new file mode 100644 index 0000000000..c2892d248b --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/chain_rule_problem_2_of_2_introduction.pg @@ -0,0 +1,355 @@ +## DESCRIPTION +## **** +## ENDDESCRIPTION + +## KEYWORDS('Chain Rule') + +## DBsubject('Calculus') +## DBchapter('Derivatives') +## DBsection('Chain Rule') +## Date('06/28/2023') +## Author('W. Shull') +## Institution('UWEC') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') + +DOCUMENT(); # This should be the first executable line in the problem. + + +loadMacros( + "PGstandard.pl", + "MathObjects.pl", # the new parser + "contextFraction.pl", + "parserMultiAnswer.pl", + "answerHints.pl", + "PGML.pl", + "scaffold.pl", + "customCSS.pl", + "PGcourse.pl", # Customization file for the course +); + +loadMacros("niceTables.pl"); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$b2=non_zero_random(-10,10); +$b3=non_zero_random(-10,10); +$b4=non_zero_random(-10,10); +$b5=non_zero_random(-10,10); +#$b6=non_zero_random(-10,10); +$b8=random(2,10); + +$b9=random(2,10); + +while ($b9==$b8){ + $b9=random(-10,10); +} + +$b1=non_zero_random(2,8); +$b0=random(2,6); +$b10=non_zero_random(-10,10); +$b11=non_zero_random(-10,10); +$b12=non_zero_random(-10,10); +$b13=non_zero_random(-10,10); +$b14=non_zero_random(-10,10); +$b15=random(2,10); +$b16=random(2,10); + +$a1=$b4*$b2; +$a2=$b4*$b3+$b5; +$a3=$b2*$b5+$b3; + +## THIS IS PROBLEM 2 OF A 2 PROBLEM SERIES INTRODUCING THE CHAIN RULE. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); + +## END PASSCODE CODE + +$b7=non_zero_random(-10,10); + + +Context("Numeric"); + +Context()->variables->add(u=>"Real"); + +Context()->noreduce('(-x)-y'); + +$ans3 = Formula("$a1*x+$a3")->reduce; +$ans4 = Formula("$a1*x+$a2")->reduce; +$ans5 = Formula("sqrt(x^2+$b7)")->reduce; +$ans5->{limits}=[4,8]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$ans5d=Formula("x/(sqrt(x^2+[$b7]))")->reduce; +$ans5d->{limits}=[4,8]; #Which x values are tested? We only want x values that are guaranteed to be in the domain. +$ans6 = Formula("x+$b7")->reduce; +$ans1 = Formula("$b11*sin^$b8(x)*cos^$b8(x)+$b10*sin^$b9(x)*cos^$b9(x)")->reduce; +$ans2 = Formula("sin($b11*x^$b8+$b10*x^$b9)*cos($b11*x^$b8+$b10*x^$b9)")->reduce; +$ans8 = Formula("sqrt(u)"); +$ans9 = Formula("x^2+[$b7]")->reduce; +$ans10 = Formula("sin u cos u")->reduce; +$ans13 = Formula("u^3-4u^2+5")->reduce; +$ans14 = Formula("tan x")->reduce; +$ans15 = 2*$b0; + + +$g3=Formula("$b11*x^$b8+$b10*x^$b9")->reduce; +$g3d=Formula("($b11*$b8)*x^($b8-1)+($b10*$b9)*x^($b9-1)")->reduce; + +################################### +# Main text +########################################### +# The scaffold +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); +########################################### +Section::Begin("Passcode"); + +Context()->texStrings; +BEGIN_PGML + +How do we take a derivative of something like [`[$ans5]`] ? None of the rules we know so far are enough to find this derivative. + +[% Enter the passcode from the previous question: [_]{$passcode1} %] + +END_PGML +Section::End(); + +Section::Begin("Introducing the Chain Rule!"); + +BEGIN_PGML + +We know we can write it as a composition [`f(g(x))`]. In this case, [`u=g(x)=x^2+[$b7]`] and [`f(g(x))=f(u)=\sqrt u=u^{1/2}`]. + +Here are a couple videos introducing the Chain Rule! I recommend watching all of the first one... + +[@ +kalturaShull("1_ro5sw2il") +@]* + +...and I recommend watching this next one from about 8:40 to 14:35. + +[@ youtube("YG15m2VwSjA?start=521"); @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* +Chain Rule: + +If [`f`] and [`g`] are differentiable functions, then + +[```\frac d{dx}[f(g(x))]=f'(g(x))*g'(x)```] +[@ closeDiv() @]* + +Or, if [`u=g(x)`], then + +[```\frac d{dx}[f(g(x))]=f'(u)*g'(x)```] + +Let's find the derivative of [`\sqrt{x^2+[$b7]}`] using the Chain Rule! + +First we write down the outside and inside function: + +[``f(u)=\sqrt u=u^{1/2}``] + +[``g(x)=x^2+[$b7]``] + +Then we find their derivatives: + +[``f'(u)=\frac12 u^{-1/2}``] + +[``g'(x)=2x``] + +Then we put it all together! + +[``` +\begin{eqnarray*} +\frac d{dx}[f(g(x))] +&=&f'(u)*g'(x)\\ +&=&\frac12 u^{-1/2}*2x\\ +&=&x*u^{-1/2}\\ +\end{eqnarray*} +```] + +Since the problem was given with only [`x`], we can't leave [`u`] in our final answer. So we continue... + +[```\frac d{dx}[f(g(x))]=\dots=x*u^{-1/2}=x*(x^2+[$b7])^{-1/2}```] + +And in case we need to simplify more... + +[```\frac d{dx}[f(g(x))]=\dots=x*(x^2+[$b7])^{-1/2}=\frac x{(x^2+[$b7])^{1/2}}=\frac x{\sqrt{x^2+[$b7]}}```] + +Retype that final answer here: + +[``\frac d{dx}[f(g(x))]=``][_]{$ans5d} + +END_PGML +Section::End(); + +Section::Begin("Chain Rule practice"); + +BEGIN_PGML + +Suppose [`f(g(x))=\sin([$g3])`]. As we did in the previous example, decompose this into [`f(u)`] and [`g(x)`]. + +[`f(u)=`][_]{Formula("sin(u)")} + +[`g(x)=`][_]{$g3} + +Then find both their derivatives: + +[`f'(u)=`][_]{Formula("cos(u)")} + +[`g'(x)=`][_]{$g3d} + +Multiply [`f(u)`] by [`g(x)`] (leaving [`u`] in your answer): + +END_PGML +Context()->normalStrings; + +# were generating warnings, so factored out. +$arst = Formula("cos(u)*[$g3d]"); +$qwfp = Formula("cos([$g3])*[$g3d]"); + +Context()->texStrings; +BEGIN_PGML + +[`f'(u)g'(x)=`][_]{$arst} ## HERE + + +Now replace [`u`] with [`g(x)`]: + +[`f'(g(x))*g'(x)=`][_]{$qwfp} ##HERE + +We are finished! This is the derivative of [`\sin([$g3])`]. + +----- + +Suppose [`f(g(x))=\tan^3(x)-[$b15]\tan^2(x)+[$b16]`]. + +[@ +DataTable( +[ + ['\( f(u) = \) ' . ans_rule(10),'\(f\'(u)=\)' . ans_rule(10)], + ['\( g(x) = \) ' . ans_rule(10),'\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + + +END_PGML + +ANS(Formula("u^3-[$b15]u^2+[$b16]")->reduce->cmp()); +ANS( Compute("3u^2-(2*[$b15])u")->cmp() ); +ANS( Compute("tan(x)")->cmp() ); +ANS( Compute("sec^2(x)")->cmp() ); + +BEGIN_PGML + +[`f'(u)g'(x)=`][_]{Formula("(3u^2-(2*[$b15])u)*sec^2(x)")->reduce} + + +[`f'(g(x))\cdot g'(x)=`][_]{Formula("(3tan^2(x)-(2*[$b15])tan(x))*sec^2(x)")->reduce} + + +----- + +Suppose [``f(g(x))=\frac{[$b14]}{[$b12]x+[$b13]}``]. + + +[@ +DataTable( +[ + ['\( f(u) = \) ' . ans_rule(10),'\(f\'(u)=\)' . ans_rule(10)], + ['\( g(x) = \) ' . ans_rule(10),'\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + + +END_PGML + +ANS(Formula("$b14/u")->reduce->cmp()); +ANS( Compute("-$b14/u^2")->cmp() ); +ANS( Compute("[$b12]x+[$b13]")->cmp() ); +ANS( Compute("[$b12]")->cmp() ); + +BEGIN_PGML + +[`f'(u)g'(x)=`][_]{Formula("-[$b14]*[$b12]/u^2")->reduce} + +[`f'(g(x))g'(x)=`][_]{Formula("-[$b14]*[$b12]/([$b12]x+[$b13])^2")->reduce} + +END_PGML + + +Section::End(); + +Section::Begin("The Chain Rule agrees with other methods"); + +BEGIN_PGML + +Suppose we want the derivative of [`([$b0]x+[$b1])^2`]. Let's find this derivative a few different ways: + +First, FOIL the expression out: + +>>[_]{Formula("[$b0]^2")->reduce}[`x^2+`][_]{Formula("2*[$b0]*[$b1]")->reduce}[`x+`][_]{Formula("[$b1]^2")->reduce}<< + +Now take the derivative: [_]{Formula("(2*[$b0]^2)x+(2*[$b0]*[$b1])")->reduce} + +Let's find the same derivative, but with the Chain Rule! + +[@ +DataTable( +[ + ['\( f(u) = \) ' . ans_rule(10),'\(f\'(u)=\)' . ans_rule(10)], + ['\( g(x) = \) ' . ans_rule(10),'\(g\'(x)=\)' . ans_rule(100)] +], +align => 'l l', +tablecss => "border:solid 1px; border-spacing:50px 5px; border-radius: 5px; border-collapse:separate;" +); +@]*** + +END_PGML + +ANS(Formula("u^2")->reduce->cmp()); +ANS( Compute("2u")->cmp() ); +ANS( Compute("[$b0]x+[$b1]")->cmp() ); +ANS( Compute("[$b0]")->cmp() ); + +BEGIN_PGML + + +[`f'(u)\cdot g'(x)=`][_]{Formula("(2*[$b0])u")->reduce} + +END_PGML +Section::End(); + +Section::Begin("..."); + +BEGIN_PGML + + +[`f'(g(x))\cdot g'(x)=[$ans15]\Big(`][_]{Formula("[$b0]x+[$b1]")->reduce}[`\Big)`] + +Now simplify this! + +[`f'(g(x))\cdot g'(x)=`][_]{Formula("2*[$b0]^2")->reduce}[`x+`][_]{Formula("2*[$b0]*[$b1]")->reduce} + +END_PGML + + +Context()->normalStrings; + +$showPartialCorrectAnswers = 1; + +Section::End(); + + Scaffold::End(); +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_2_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_2_of_3.pg new file mode 100644 index 0000000000..900c4e229a --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_2_of_3.pg @@ -0,0 +1,439 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Curve Sketching') +## Date('7/23/2023') +## Author('Warren Shull') # also modified by silviana amethyst +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +loadMacros("customCSS.pl"); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +$number_line_image = createTikZImage(); +$number_line_image->tikzLibraries("arrows.meta"); + +$number_line2 = createTikZImage(); +$number_line2->tikzLibraries("arrows.meta"); + +$number_line3 = createTikZImage(); +$number_line3->tikzLibraries("arrows.meta"); + +$number_line4 = createTikZImage(); +$number_line4->tikzLibraries("arrows.meta"); + +# Randomization +$a = non_zero_random(-6, 6); # horizonatal translation +$b = random(-4, 4); # vertical translation +$z1 = -9; #first zero +$z2 = -3; #second zero +$m1=($z1+$z2)/2; #average of them + +$positive = PopUp( + ["Choose one", "positive","negative"], + "positive"); + +$negative = PopUp( + ["Choose one", "positive","negative"], + "negative"); + +$increasing = PopUp( + ["Choose one", "increasing","decreasing"], + "increasing"); + +$decreasing = PopUp( + ["Choose one", "increasing","decreasing"], + "decreasing"); + +$minimum = PopUp( + ["Choose one", "minimum","maximum"], + "minimum"); + +$maximum = PopUp( + ["Choose one", "minimum","maximum"], + "maximum"); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + +$unique_div_id = "increasing_concave_up"; +$width = 700; +$height = 400; + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +############################################################## +# +# Setup +# +# + +Context("Numeric"); +Context()->variables->add(t=>'Real'); + +## THIS IS PROBLEM 2 OF A 3 PROBLEM SERIES INTRODUCING CONCAVITY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); + +## END PASSCODE CODE + + +$i1= non_zero_random(-10,10); +$spacing=random(2,5); +$c1left=$i1-$spacing; +$c1right=$i1+$spacing; +$y1=non_zero_random(-3,3); + +$f=Formula("x^3-3*$i1*x^2+3*$c1left*$c1right*x+$y1")->reduce; +$fp=Formula("3*x^2-6*$i1*x+3*$c1left*$c1right")->reduce; + +$tx1=$c1left-1; +$td1=$fp->eval(x=>$tx1); +$tx2=$i1; +$td2=$fp->eval(x=>$tx2); +$tx3=$c1right+1; +$td3=$fp->eval(x=>$tx3); + +$number_line_image->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f(x)\)}; +\draw[thick] (-4,10pt) -- (-4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (4,10pt) -- (4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +END_TIKZ + +$number_line2->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f'(x)\)}; +\draw[thick] (-4,10pt) -- (-4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (4,10pt) -- (4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +\draw[thick] (-8,0pt) -- (-8,0pt) node[font={\Huge},above,outer sep=10pt]{\(+\)}; +END_TIKZ + +$number_line3->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f'(x)\)}; +\draw[thick] (-4,10pt) -- (-4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (4,10pt) -- (4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +\draw[thick] (-8,0pt) -- (-8,0pt) node[font={\Huge},above,outer sep=10pt]{\(+\)}; +\draw[thick] (0,0pt) -- (0,0pt) node[font={\Huge},above,outer sep=10pt]{\(-\)}; +END_TIKZ + +$number_line4->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f'(x)\)}; +\draw[thick] (-4,10pt) -- (-4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (4,10pt) -- (4,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +\draw[thick] (-8,0pt) -- (-8,0pt) node[font={\Huge},above,outer sep=10pt]{\(+\)}; +\draw[thick] (0,0pt) -- (0,0pt) node[font={\Huge},above,outer sep=10pt]{\(-\)}; +\draw[thick] (8,0pt) -- (8,0pt) node[font={\Huge},above,outer sep=10pt]{\(+\)}; +END_TIKZ + + +############################################################## +# +# Text +# +# + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +BEGIN_PGML + +This is the second in a sequence of three problems developing the first and second derivative tests. + +[@ openDiv({ "class" => "problemPurpose" }) @]* +Purpose: + +In this problem we label a partitioned number line with the sign of the first derivative, and lead to the "first derivative test", which lets us classify critical points as optima or saddle points --- just from the first derivative. + +[@ closeDiv() @]* + +END_PGML + +Section::Begin("🔑 Segue from previous problem"); + +BEGIN_PGML + +Recall that a *critical number* is an [`x`]-value, commonly called [`c`], where either [`f'(c)=0`] or [`f'(c)`] does not exist. + +In this problem, we will see what happens _in-between_ the critical numbers. + +[% Enter the passcode from the previous question: [_]{$passcode1} %] + +END_PGML +Section::End(); +Section::Begin("Compute the critical numbers"); + +BEGIN_PGML + +As we have seen, when [`f'`] is positive, it means [`f`] is increasing, and when [`f'`] is negative, it means [`f`] is decreasing. + +Let [`f(x)=[$f]`]. + +🎯 Compute the first derivative, and the critical numbers. + +* The first derivative is [`f'(x)=`] [_]{$fp} +* The critical numbers ([`x`]-values) of [`f`] are [_]{List("$c1left,$c1right")} + +END_PGML + +Section::End(); + + + + + + + + + +Section::Begin("Use test numbers for intervals of increasing/decreasing"); + +BEGIN_PGML + +The critical numbers are the only places where the derivative is zero (or nonexistent, but that doesn't happen in this case). Everywhere else, it is either positive or negative! + +Furthermore, the critical points are the only places the function can _switch_ between increasing and decreasing. + +Let's make a number line to keep track of what we know. Notice that we put tick marks *only* at the critical numbers. + +>> [@ image($number_line_image, width => 400, tex_size => 600) @]* << + +👀 As you can see, the two critical numbers divide the number line into three parts. Within each part, [`f`] will either increase the whole time or decrease the whole time. To decide which, we need only test one number from that part. + +🎯 Let's begin by testing a number from the left part, where [`x<[$c1left]`] (any [`x`] left of [`[$c1left]`] will do, so we *arbitrarily* chose [`[$tx1]`]). + +[`f'([$tx1])=`] [_]{$td1} + +Since [`f'([$tx1])`] is [_]{$positive}, [`f`] is [_]{$increasing} at [`x=[$tx1]`] + +END_PGML + +Section::End(); + + + + + + + + +Section::Begin("Label the middle interval with the sign of \(f'\)"); + +BEGIN_PGML + +Since [`f'([$tx1])`] is positive, [`f'(x)`] must be positive for all [`x<[$c1left]`]. We show this with a [`+`] sign on that part of the number line: + +>> [@ image($number_line2, width => 400, tex_size => 600) @]* << + +Now let's do something similar for the middle part of the number line. We can test any number between [`[$c1left]`] and [`[$c1right]`]. Let's try testing [`[$tx2]`]: + +[`f'([$tx2])=`] [_]{$td2} + +When [`[$c1left]> [@ image($number_line3, width => 400, tex_size => 600) @]* << + +🎯 Let's solve the last part, adding the rightmost label to the graph! + +[`f'([$tx3])=`] [_]{$td3}, which is [_]{$positive} so [`f`] is [_]{$increasing} when [`x>[$c1right]`]. + +END_PGML + +Section::End(); + + + + + + + + +Section::Begin("Associate a \(f'\)-signed number line with intervals of increasing/decreasing"); + +BEGIN_PGML + +Here's the full picture of where [`f'`] is positive and where it's negative. + +>> [@ image($number_line4, width => 400, tex_size => 600) @]* << + +🎯 Correlate increasing/decreasing with the sign of [`f'`]. + +* [`f`] is [_]{$increasing} on [`\Big(-\infty,`] [_]{$c1left}[`\Big)`] +* [`f`] is [_]{$decreasing} on [`\Big(`][_]{$c1left}[`,`] [_]{$c1right}[`\Big)`] +* [`f`] is [_]{$increasing} on [`\Big(`][_]{$c1right}[`,\infty\Big)`] + +Think about it: + +[@ openDiv({ "class" => "importantFormula" }) @]* +When a person has a fever 🤒 their temperature 🌡️ goes up, and when the fever "breaks" their tempurature goes down. Increasing, then decreasing. A person's highest temperature is when it switches from increasing to decreasing. + +Overnight 🌌, we usually experience the "nightly low" temperature. The tempurature falls through the evening, and then it starts rising again as the sun comes up. The minimum tempurature is when it switches from decreasing to increasing. +[@ closeDiv() @]* + +🎯 Classify the two critical points using this reasoning. + +[`f`] has a local [_]{$maximum} at [`x=[$c1left]`] and a local [_]{$minimum} at [`x=[$c1right]`]. + +END_PGML + +Section::End(); + + + + + + + + + + +Section::Begin("The first derivative test 🔑"); + +BEGIN_PGML + +[@ openDiv({ "class" => "importantFormula" }) @]* +*First Derivative Test*: + +Let [`c`] be a critical point of [`f`]. + +* If [`f'(x)<0`] when [`x`] is slightly less than [`c`] and [`f'(x)>0`] when [`x`] is slightly greater than [`c`], then [`(c,f(c))`] is a local minimum. + +* If [`f'(x)>0`] when [`x`] is slightly less than [`c`] and [`f'(x)<0`] when [`x`] is slightly greater than [`c`], then [`(c,f(c))`] is a local maximum. +[@ closeDiv() @]* + +We can also use the second derivative to classify a critical point as local min or max. That's the next problem. + +[% The passcode for the next question is [`[$passcode2]`]. 🎯 Enter it here: [_]{$passcode2}. %] + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +#$right1 = $x1_max + 2; +#$top1 = $g1_max + 2; +#$left1 = $x1_min - 2; +#$bottom1 = $g1_min - 2; + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'slider', latex: 'y=x', sliderBounds: {min: 1, max: ,4 step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))'}, + { id: 'tangent_line', latex: 'y = 3x-5', label: 'tangent line'}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'g_curve', latex: 'g(x)=x^2 \\left\\{1\\leq x\\leq4\\right\\}'}, + ]); + + my_calculator.setMathBounds({ + left: $left1, + right: $right1, + bottom: $bottom1, + top: $top1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_3_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_3_of_3.pg new file mode 100644 index 0000000000..a5092e46fb --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/concavity_problem_3_of_3.pg @@ -0,0 +1,746 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Curve Sketching') +## Date('7/23/2023') +## Author('Warren Shull') +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "unionTables.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +loadMacros("customCSS.pl"); + +# Print problem number and point value (weight) for the problem +TEXT(beginproblem()); + +Context("Numeric"); +Context()->variables->add(t=>'Real'); + +$second_line1 = createTikZImage(); +$second_line1->tikzLibraries("arrows.meta"); + +$second_line2 = createTikZImage(); +$second_line2->tikzLibraries("arrows.meta"); + +$both_lines = createTikZImage(); +$both_lines->tikzLibraries("arrows.meta"); + +$combined_line = createTikZImage(); +$combined_line->tikzLibraries("arrows.meta"); + +$positive = PopUp( + ["Choose one", "positive","negative"], + "positive"); + +$negative = PopUp( + ["Choose one", "positive","negative"], + "negative"); + +$increasing = PopUp( + ["Choose one", "increasing","decreasing"], + "increasing"); + +$decreasing = PopUp( + ["Choose one", "increasing","decreasing"], + "decreasing"); + +$minimum = PopUp( + ["Choose one", "minimum","maximum"], + "minimum"); + +$maximum = PopUp( + ["Choose one", "minimum","maximum"], + "maximum"); + +$concave_up = PopUp( + ["Choose one", "concave up","concave down"], + "concave up"); + +$concave_down = PopUp( + ["Choose one", "concave up","concave down"], + "concave down"); + +$increasing_concave_up = PopUp( + ["Choose one", "increasing concave up","increasing concave down","decreasing concave up","decreasing concave down"], + "increasing concave up"); + +$decreasing_concave_up = PopUp( + ["Choose one", "increasing concave up","increasing concave down","decreasing concave up","decreasing concave down"], + "decreasing concave up"); + +$increasing_concave_down = PopUp( + ["Choose one", "increasing concave up","increasing concave down","decreasing concave up","decreasing concave down"], + "increasing concave down"); + +$decreasing_concave_down = PopUp( + ["Choose one", "increasing concave up","increasing concave down","decreasing concave up","decreasing concave down"], + "decreasing concave down"); + +# Show which answers are correct and which ones are incorrect +$showPartialCorrectAnswers = 1; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + +$width = 300; +$height = 300; + + +$x1_mid = non_zero_random(-10,10); #middle, where $a begins +$x2_mid = non_zero_random(-10,10); #middle, where $a begins +$x3_mid = non_zero_random(-10,10); #middle, where $a begins +$x4_mid = non_zero_random(-10,10); #middle, where $a begins +$y1 = non_zero_random(-10,10); #up or down shift from default +$y2 = non_zero_random(-10,10); #up or down shift from default +$y3 = non_zero_random(-10,10); #up or down shift from default +$y4 = non_zero_random(-10,10); #up or down shift from default + +$x1_max = $x1_mid+1.9; +$x1_min = $x1_mid-2; +$x2_max = $x2_mid+2; +$x2_min = $x2_mid-1.9; +$x3_max = $x3_mid+2; +$x3_min = $x3_mid-1.9; +$x4_max = $x4_mid+1.9; +$x4_min = $x4_mid-2; + +$g1 = Formula("$y1-sqrt(16-(x-$x1_min)^2)"); +$g2 = Formula("$y2+sqrt(16-(x-$x2_max)^2)"); +$g3 = Formula("$y3-sqrt(16-(x-$x3_max)^2)"); +$g4 = Formula("$y4+sqrt(16-(x-$x4_min)^2)"); + +$g1_max = $g1->eval(x=>$x1_max); +$g1_min = $g1->eval(x=>$x1_min); +$g2_max = $g2->eval(x=>$x2_max); +$g2_min = $g2->eval(x=>$x2_min); +$g3_max = $g3->eval(x=>$x3_max); +$g3_min = $g3->eval(x=>$x3_min); +$g4_max = $g4->eval(x=>$x4_max); +$g4_min = $g4->eval(x=>$x4_min); + +if ($g1_max<$g1_min){ #swap if they're in the wrong order + $g1_temp=$g1_max; + $g1_max=$g1_min; + $g1_min=$g1_temp; +} + +if ($g2_max<$g2_min){ #swap if they're in the wrong order + $g2_temp=$g2_max; + $g2_max=$g2_min; + $g2_min=$g2_temp; +} + +if ($g3_max<$g3_min){ #swap if they're in the wrong order + $g3_temp=$g3_max; + $g3_max=$g3_min; + $g3_min=$g3_temp; +} + +if ($g4_max<$g4_min){ #swap if they're in the wrong order + $g4_temp=$g4_max; + $g4_max=$g4_min; + $g4_min=$g4_temp; +} + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$unique_div_id = "increasing_concave_up"; +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id2 = "increasing_concave_down"; +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id3 = "decreasing_concave_up"; +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id4 = "decreasing_concave_down"; +$desmos_div4 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id5 = "function_graph"; +$desmos_div5 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +############################################################## +# +# Setup +# +# + +## THIS IS PROBLEM 3 OF A 3 PROBLEM SERIES INTRODUCING CONCAVITY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); + +## END PASSCODE CODE + +$i1= non_zero_random(-10,10); +$spacing=random(2,5); +$c1left=$i1-$spacing; +$c1right=$i1+$spacing; +$y0=non_zero_random(-3,3); + +$f=Formula("x^3-3*$i1*x^2+3*$c1left*$c1right*x+$y0")->reduce; +$fp=Formula("3*x^2-6*$i1*x+3*$c1left*$c1right")->reduce; +$fpp=Formula("6*x-6*$i1")->reduce; + +$y5min=$f->eval(x=>$c1right); +$y5max=$f->eval(x=>$c1left); +$y5inf=$f->eval(x=>$i1); + +$t2x1=$i1-1; +$t2d1=$fpp->eval(x=>$t2x1); +$t2x2=$i1+1; +$t2d2=$fpp->eval(x=>$t2x2); + +$second_line1->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f''(x)\)}; +\draw[thick] (0,10pt) -- (0,-10pt) node[font={\Huge},below,outer sep=4pt]{\($i1\)}; +END_TIKZ + +$second_line2->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,2); +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f''(x)\)}; +\draw[thick] (0,10pt) -- (0,-10pt) node[font={\Huge},below,outer sep=4pt]{\($i1\)}; +\draw[thick] (-6,0pt) -- (-6,0pt) node[font={\Huge},above,outer sep=4pt]{\(-\)}; +\draw[thick] (6,0pt) -- (6,0pt) node[font={\Huge},above,outer sep=4pt]{\(+\)}; +END_TIKZ + +$both_lines->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,6); +\draw[<->,thick] (12,4) -- (-12,4) node[left,font={\Huge},outer sep=4pt]{\(f'(x)\)}; +\draw[thick] (-6,125pt) -- (-6,105pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (6,125pt) -- (6,105pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +\draw[thick] (-9,115pt) -- (-9,115pt) node[font={\Huge},above,outer sep=4pt]{\(+\)}; +\draw[thick] (0,115pt) -- (0,115pt) node[font={\Huge},above,outer sep=4pt]{\(-\)}; +\draw[thick] (9,115pt) -- (9,115pt) node[font={\Huge},above,outer sep=4pt]{\(+\)}; +\draw[<->,thick] (12,0) -- (-12,0) node[left,font={\Huge},outer sep=4pt]{\(f''(x)\)}; +\draw[thick] (0,10pt) -- (0,-10pt) node[font={\Huge},below,outer sep=4pt]{\($i1\)}; +\draw[thick] (-6,0pt) -- (-6,0pt) node[font={\Huge},above,outer sep=4pt]{\(-\)}; +\draw[thick] (6,0pt) -- (6,0pt) node[font={\Huge},above,outer sep=4pt]{\(+\)}; +END_TIKZ + +$combined_line->BEGIN_TIKZ +\tikzset{>={Stealth[scale=2]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-15,-2) rectangle (15,6); +\draw[<->,thick] (12,0) -- (-12,0); +\draw[thick] (0,10pt) -- (0,-10pt) node[font={\Huge},below,outer sep=4pt]{\($i1\)}; +\draw[thick] (-6,10pt) -- (-6,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1left\)}; +\draw[thick] (6,10pt) -- (6,-10pt) node[font={\Huge},below,outer sep=4pt]{\($c1right\)}; +\draw[thick] (-9,0pt) -- (-9,0pt) node[font={\Huge},above,outer sep=45pt]{\(f'+\)}; +\draw[thick] (-9,0pt) -- (-9,0pt) node[font={\Huge},above,outer sep=10pt]{\(f''-\)}; +\draw[thick] (-3,0pt) -- (-3,0pt) node[font={\Huge},above,outer sep=45pt]{\(f'-\)}; +\draw[thick] (-3,0pt) -- (-3,0pt) node[font={\Huge},above,outer sep=10pt]{\(f''-\)}; +\draw[thick] (3,0pt) -- (3,0pt) node[font={\Huge},above,outer sep=45pt]{\(f'-\)}; +\draw[thick] (3,0pt) -- (3,0pt) node[font={\Huge},above,outer sep=10pt]{\(f''+\)}; +\draw[thick] (9,0pt) -- (9,0pt) node[font={\Huge},above,outer sep=45pt]{\(f'+\)}; +\draw[thick] (9,0pt) -- (9,0pt) node[font={\Huge},above,outer sep=10pt]{\(f''+\)}; +END_TIKZ + +############################################################## +# +# Text +# +# + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +BEGIN_PGML + +[@ openDiv({ "class" => "problemPurpose" }) @]* +Purpose: + +In this problem, we will build tools to know how each part of a graph is shaped, focusing on the second derivative. + +[@ closeDiv() @]* +END_PGML + +Section::Begin("Passcode"); + +BEGIN_PGML + +In this problem, we will focus on the same function from the previous problem: + +[`f(x)=[$f]`] + +[% 🎯🔑 Enter the passcode from the previous question: [_]{$passcode2} %] + +END_PGML +Section::End(); + + + +Section::Begin("Second derivative"); + +BEGIN_PGML + +🎯 Begin by finding the first and second derivative. + +[`f(x)=[$f]`] + +* [`f'(x)=`] [_]{$fp} +* [`f''(x)=`] [_]{$fpp} + +There is one number [`c`] such that [`f''(c)=0`]. 🎯 Compute it + +[`f''\Big(`] [_]{$i1} [`\Big)=0`] + +END_PGML + +Section::End(); + + + + + + + +Section::Begin("Second derivative number line"); + +BEGIN_PGML + +In the previous problem, we made a number line for the first derivative. Now, we will make one for the second derivative! As before, we only need tick marks where the second derivative is either 0 or does not exist. + +>> [@ image($second_line1, width => 400, tex_size => 600) @]* << + +This time, the tick mark only divides the number line into two parts. As before, we only need to test one number from each part. + +🎯 "Test" the signs of the derivatives using [`[$t2x1]`] for the left part and [`[$t2x2]`] for the right part. + +* [`f''([$t2x1])=`] [_]{$t2d1}, so [`f''(x)`] is [_]{$negative} when [`x<[$i1]`]. +* [`f''([$t2x2])=`] [_]{$t2d2}, so [`f''(x)`] is [_]{$positive} when [`x>[$i1]`]. + +END_PGML + +Section::End(); + + + + + + + +Section::Begin("Number line finished"); + +BEGIN_PGML + +🎉 We now have what we need for a second derivative number line: + +>> [@ image($second_line2, width => 400, tex_size => 600) @]* << + +🧠 But how does this affect the shape of the graph? + +END_PGML + +Section::End(); +Section::Begin("Problem 5 pictures"); + +$column1 = $desmos_div ."$PAR $PAR $PAR $PAR ". $desmos_div2; + +$column2 = $desmos_div3 ."$PAR $PAR $PAR $PAR ". $desmos_div4; + +BEGIN_PGML + +Recall these pictures from Problem 5: + +END_PGML + +TEXT(ColumnTable($column1,$column2)); + +BEGIN_PGML +The two at the top had [_]{$positive} second derivatives, and the two at the bottom had [_]{$negative} second derivatives. + +🧠 Do you see anything visually different about the top two versus the bottom two? + +END_PGML + +Section::End(); +Section::Begin("Concavity"); + +BEGIN_PGML + +Here's a tip to help remember concavity direction: + +[@ openDiv({ "class" => "importantFormula" }) @]* +* We say the top two pictures are *concave up* because they are shaped like a smile! +* The other two are *concave down* because they are shaped like a frown. They rhyme! +[@ closeDiv() @]* + + +(In other words, [`f`] was concave up when [`f'`] was increasing, and [`f`] was concave down when [`f'`] was decreasing.) + +So getting back to our number line: + +>> [@ image($second_line2, width => 400, tex_size => 600) @]* << + +🎯 Connect the sign of [`f'`] with increasing / decreasing. + +* On the interval [`\Big(-\infty,`] [_]{$i1}[`\Big)`], [`f''`] is [_]{$negative}, so the graph of [`f`] is [_]{$concave_down}. +* On the interval [`\Big(`] [_]{$i1}[`,\infty\Big)`], [`f''`] is [_]{$positive}, so the graph of [`f`] is [_]{$concave_up}. + +END_PGML + +Section::End(); + +Section::Begin("Combining concavity with increase/decrease"); + +BEGIN_PGML + +Here are the number lines for both the first and second derivative: + +>> [@ image($both_lines, width => 400, tex_size => 600) @]* << + +We can combine them into one! On the combined number line, we need a tick mark wherever _either_ of the two lines had a tick mark. 🎯 List the numbers where either of the two lines (or both) have a tick mark, *in increasing order*: + +END_PGML + +BEGIN_PGML + +[@ ans_rule(10) @]* + +Now let's combine the two number lines... +END_PGML + +Context()->normalStrings; +COMMENT("TODO: this flag of ordered=>0 isn't working, and it's only accepting them in this order. "); +$combined_points = List( "$c1left,$i1,$c1right" ); +ANS($combined_points->cmp(ordered=>0,showLengthHints => 1)); + +Context()->texStrings; + +Section::End(); + +Section::Begin("Combined number line"); + +BEGIN_PGML + +>> [@ image($combined_line, width => 400, tex_size => 600) @]* << + +We have divided the number line into 4 intervals. 🎯 Fill them in, in order from left to right: + +* [`\Big(-\infty,`] [_]{$c1left}[`\Big)`] +* [`\Big(`][_]{$c1left}[`,`] [_]{$i1}[`\Big)`] +* [`\Big(`][_]{$i1}[`,`] [_]{$c1right}[`\Big)`] +* [`\Big(`][_]{$c1right}[`,\infty\Big)`] + +END_PGML + +Section::End(); + +Section::Begin("Assigning shapes to each interval"); + +BEGIN_PGML + +>> [@ image($combined_line, width => 400, tex_size => 600) @]* << + +🎯 Connect the combinations of signs of [`f'`] and [`f''`] using the dropdowns. + +* On the interval [`(-\infty,[$c1left])`], the graph of [`f`] is [_]{$increasing_concave_down} +* On the interval [`([$c1left],[$i1])`], the graph of [`f`] is [_]{$decreasing_concave_down} +* On the interval [`([$i1],[$c1right])`], the graph of [`f`] is [_]{$decreasing_concave_up} +* On the interval [`([$c1right],\infty)`], the graph of [`f`] is [_]{$increasing_concave_up} + +Let's look at the graph to see if it agrees with these statements! + +END_PGML + +Section::End(); + +Section::Begin("Graph and new rule!"); + +BEGIN_PGML + +[@ $desmos_div5 @]* + +As you can see, the graph of [`y=f(x)`] agrees with the combined number line above. + +In the previous problem, we found the local maximum (shown in green) and the local minimum (shown in blue). Notice the _concavity_ at both of these points. + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Second Derivative Test*: + +Let [`c`] be a critical number of [`f`]. 🎯 Connect direction of concavity to local optima using the dropdowns. + +* If [`f''(c)>0`], then [`f`] is [_]{$concave_up} and has a local [_]{$minimum}. + +* If [`f''(c)<0`], then [`f`] is [_]{$concave_down} and has a local [_]{$maximum}. + +[@ closeDiv() @]* + +But what about the point shown in red? That's where the concavity changes, so we call it an *inflection point*. 🎯 Enter the coordinates of that point here: + +[`\Big(`][_]{$i1}[`,`] [_]{$y5inf}[`\Big)`] + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +$right1 = $x1_max + 2; +$top1 = $g1_max + 2; +$left1 = $x1_min - 2; +$bottom1 = $g1_min - 2; + +$right2 = $x2_max + 2; +$top2 = $g2_max + 2; +$left2 = $x2_min - 2; +$bottom2 = $g2_min - 2; + +$right3 = $x3_max + 2; +$top3 = $g3_max + 2; +$left3 = $x3_min - 2; +$bottom3 = $g3_min - 2; + +$right4 = $x4_max + 2; +$top4 = $g4_max + 2; +$left4 = $x4_min - 2; +$bottom4 = $g4_min - 2; + +$right5 = $c1right + 4; +$top5 = $y5max + (($y5max-$y5min)/10); +$left5 = $c1left - 4; +$bottom5 = $y5min - (($y5max-$y5min)/10); + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true, + zoomButtons: false + }); + + my_calculator.setExpressions([ + { id: 'slider', latex: 'a=$x1_mid', sliderBounds: {min: $x1_min, max: $x1_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line'}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'g_curve', latex: 'g(x)=$y1-\\sqrt{16-(x-$x1_min)^2} \\left\\{$x1_min\\leq x\\leq$x1_max\\right\\}'}, + ]); + + my_calculator.setMathBounds({ + left: $left1, + right: $right1, + bottom: $bottom1, + top: $top1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: false }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst2 = document.getElementById("$unique_div_id2"); + + var my_calculator2 = Desmos.Calculator(arstarst2, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true, + zoomButtons: false + }); + + my_calculator2.setExpressions([ + { id: 'slider', latex: 'a=$x2_mid', sliderBounds: {min: $x2_min, max: $x2_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line'}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'g_curve', latex: 'g(x)=$y2+\\sqrt{16-(x-$x2_max)^2} \\left\\{$x2_min\\leq x\\leq$x2_max\\right\\}'}, + ]); + + my_calculator2.setMathBounds({ + left: $left2, + right: $right2, + bottom: $bottom2, + top: $top2 + }); + + my_calculator2.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator2.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst3 = document.getElementById("$unique_div_id3"); + + var my_calculator3 = Desmos.Calculator(arstarst3, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: false, + zoomButtons: false + }); + + my_calculator3.setExpressions([ + { id: 'slider', latex: 'a=$x3_mid', sliderBounds: {min: $x3_min, max: $x3_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line'}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'g_curve', latex: 'g(x)=$y3-\\sqrt{16-(x-$x3_max)^2} \\left\\{$x3_min\\leq x\\leq$x3_max\\right\\}'}, + ]); + + my_calculator3.setMathBounds({ + left: $left3, + right: $right3, + bottom: $bottom3, + top: $top3 + }); + + my_calculator3.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator3.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst4 = document.getElementById("$unique_div_id4"); + + var my_calculator4 = Desmos.Calculator(arstarst4, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true, + zoomButtons: false + }); + + my_calculator4.setExpressions([ + { id: 'slider', latex: 'a=$x4_mid', sliderBounds: {min: $x4_min, max: $x4_max, step: 0.1}}, + { id: 'base_point', latex: '(a, g(a))'}, + { id: 'tangent_line', latex: 'y = g\'(a)*(x-a) + g(a)', label: 'tangent line'}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'g_curve', latex: 'g(x)=$y4+\\sqrt{16-(x-$x4_min)^2} \\left\\{$x4_min\\leq x\\leq$x4_max\\right\\}'}, + ]); + + my_calculator4.setMathBounds({ + left: $left4, + right: $right4, + bottom: $bottom4, + top: $top4 + }); + + my_calculator4.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator4.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst5 = document.getElementById("$unique_div_id5"); + + var my_calculator5 = Desmos.Calculator(arstarst5, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true, + zoomButtons: false + }); + + my_calculator5.setExpressions([ + { id: 'f_curve', latex: 'f(x)=$f', color: Desmos.Colors.BLACK}, + { id: 'left_cp', latex: '($c1left, $y5max)', color: Desmos.Colors.GREEN}, + { id: 'right_cp', latex: '($c1right, $y5min)', color: Desmos.Colors.BLUE}, + { id: 'inflection', latex: '($i1, $y5inf)', color: Desmos.Colors.RED}, + ]); + + my_calculator5.setMathBounds({ + left: $left5, + right: $right5, + bottom: $bottom5, + top: $top5 + }); + + my_calculator5.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator5.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_1_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_1_of_3.pg new file mode 100644 index 0000000000..8ba6a571ef --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_1_of_3.pg @@ -0,0 +1,457 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Rates of change') +## Date('Summer 2023') +## Author('Warren Shull') +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "desmos.pl", +); + +loadMacros("customCSS.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; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + +$unique_div_id = "parabola_unrestricted"; +$unique_div_id2 = "parabola_restricted"; +$unique_div_id3 = "fifth_restricted"; +$unique_div_id4 = "fifth_unrestricted"; +$unique_div_id5 = "fifth_unrestricted_tangent_line"; +$unique_div_id6 = "tangent_line_with_dragable_point"; +$width = 400; +$height = 400; + +desmos_enable_construct_new(); + +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div4 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div5 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div6 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + + +############################################################## +# +# Setup + +Context("Numeric"); +Context()->variables->add(t=>'Real'); + +$x1 = non_zero_random(-10,10); #middle, where $a begins +$y1 = non_zero_random(-10,10); #up or down shift from default + +$x1_max = $x1+1; +$x1_min = $x1-2; + +$f1 = Formula("(x-$x1)^2+$y1"); +$y1_left = $f1->eval(x=>$x1_min); +$y1_right = $f1->eval(x=>$x1_max); + +$x2 = non_zero_random(-10,10); +$y2 = non_zero_random(-100,100,10); +$x2_top = $x2-2; +$x2_bottom = $x2+2; +$x2_left = $x2-2.5; +$x2_right = $x2+2.5; +$x2_start = $x2-1; +$x2_fake = $x2+1; + +$f2_str = "3*(x-$x2)^5-20*(x-$x2)^3+$y2"; +$f2 = Formula($f2_str); +$y2_left = $f2->eval(x=>$x2_left); +$y2_right = $f2->eval(x=>$x2_right); +$y2_bottom = $f2->eval(x=>$x2_bottom); +$y2_top = $f2->eval(x=>$x2_top); +$y2_start = $f2->eval(x=>$x2_start); +$y2_fake = $f2->eval(x=>$x2_fake); + + +## THIS IS PROBLEM 1 OF A 3 PROBLEM SERIES INTRODUCING THE EXTREME VALUE THEOREM. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); + +## END PASSCODE CODE + +############################################################## +# +# Text + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +BEGIN_PGML + +[@ openDiv({ "class" => "problemPurpose" }) @]* +Purpose: + +How do we tell when a function reaches its highest or lowest value? What about its lowest? We can use derivatives to help figure that out! But first, some terminology: + +[@ closeDiv() @]* + +[@ openDiv({ "class" => "importantFormula" }) @]* + +Let [`f`] be a function and let [`a`] be any number in the domain of [`f`]. We say [`f(a)`] is the + +* *absolute minimum* of [`f`] if [`f(a)\leq f(x)`] for all [`x`] in the domain of [`f`]. +* *absolute maximum* of [`f`] if [`f(a)\geq f(x)`] for all [`x`] in the domain of [`f`]. + +[@ closeDiv() @]* + +The word *extremum* refers collectively to either a maximum or a minimum. The plurals of these words are *maxima*, *minima*, and *extrema*. + +END_PGML + +Section::Begin("Function 1a"); + +BEGIN_PGML + +The function graphed below has no absolute maximum, but it does have an absolute minimum! + +[@ $desmos_div @]* + +* What is the absolute minimum of [`f`]? That is, what is the lowest y-value [`f`] ever reaches? [_]{$y1} + +* At what [`x`]-value does [`f`] reach its absolute minimum? [`x\,=`] [_]{$x1} + +END_PGML +Section::End(); + +Section::Begin("Function 1b"); + +BEGIN_PGML + +Rather than looking at the entire domain of a function, we can limit our attention to a narrower interval: + +[@ openDiv({ "class" => "importantFormula" }) @]* + +Let [`f`] be a function defined on an interval [`I`] and let [`a\in I`]. We say [`f(a)`] is the + +* *absolute minimum* of [`f`] on [`I`] if [`f(a)\leq f(x)`] for all [`x\in I`]. +* *absolute maximum* of [`f`] on [`I`] if [`f(a)\geq f(x)`] for all [`x\in I`]. + +[@ closeDiv() @]* + +Here we see the same function as before, but restricted to the interval [`[[$x1_min],[$x1_max]]`]. + +[@ $desmos_div2 @]* + +Absolute maxima and minima (that's the plural form of the word) can also be expressed as _ordered pairs_. + +* Fill in the ordered pair for the absolute minimum of [`f`]: [`\big(`][_]{$x1}[`,`][_]{$y1}[`\big)`]. + +* Fill in the ordered pair for the absolute maximum of [`f`]: [`\big(`][_]{$x1_min}[`,`][_]{$y1_left}[`\big)`]. + +END_PGML +Section::End(); + +Section::Begin("Function 2a"); + +BEGIN_PGML + +Here is a new function [`g`], restricted to the interval [`[[$x2_left],[$x2_right]]`]. + +[@ $desmos_div3 @]* + +* Fill in the ordered pair for the absolute minimum of [`g`]: [`\big(`][_]{$x2_bottom}[`,`][_]{$y2_bottom}[`\big)`]. + +* Fill in the ordered pair for the absolute maximum of [`g`]: [`\big(`][_]{$x2_top}[`,`][_]{$y2_top}[`\big)`]. + +END_PGML +Section::End(); + +Section::Begin("Function 2b"); + +BEGIN_PGML + +Here we see the same function as before, without any restriction. + +[@ $desmos_div4 @]* + +This has _no absolute maximum or minimum_. Any point you choose on the graph, I can find other points both higher and lower (scrolling or zooming out if necessary). + +Look at the point [`([$x2_top],[$y2_top])`] (shown in red). Even though it is not an absolute maximum, in some ways it "looks" like a maximum compared to the other points near it. + +Similarly, the point [`([$x2_bottom],[$y2_bottom])`] (shown in blue) "looks" like a minimum compared to other points near it. + +Thus, we call these points a *local maximum* and a *local minimum*. + +[@ openDiv({ "class" => "importantFormula" }) @]* + +Let [`f`] be a function and let [`c`] be in its domain. We say the point [`(c,f(c))`] is a + +* *local minimum* of [`f`] if there is some open interval [`I`] containing [`c`] such that [`f(x)`] is never less than [`f(c)`] for any [`x\in I`]. +* *local maximum* of [`f`] if there is some open interval [`I`] containing [`c`] such that [`f(x)`] is never greater than [`f(c)`] for any [`x\in I`]. + +[@ closeDiv() @]* + +As a reminder, an _open_ interval is one with round parentheses on (both,numbers). If we did not require [`I`] to be open, we could use an interval like [`[[$x2_start],[$x2_fake]]`] and call the point [`([$x2_start],[$y2_start])`] (purple) a "local maximum" and [`([$x2_fake],[$y2_fake])`] (black) a "local minimum." + +In other words, open intervals are just a way of formalizing the idea of being higher (or lower) than any "nearby" points. + +Here's the same graph again, but with a tangent line: + +[@ $desmos_div5 @]* + +What is the slope of the tangent line at the local maximum? [_]{0} What about at the local minimum? [_]{0} + +END_PGML +Section::End(); + +Section::Begin("One more tangent line, then the passcode"); + +BEGIN_PGML + +As we just saw, the tangent lines were horizontal at the local maximum and minimum. That means the derivative is zero at those points! + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Fermat's Theorem*: + +If [`(c,f(c))`] is a local maximum or minimum, then either [`f'(c)=0`] or [`f'(c)`] does not exist. +[@ closeDiv() @]* + +However, the reverse is NOT true. Sometimes [`f'(c)=0`] even when [`(c,f(c))`] is not a local extremum. + +There's one such point on the graph above: [`\big(`][_]{$x2}[`,`][_]{$y2}[`\big)`] + +[% The passcode for the next question is [`[$passcode1]`]. + +Enter it here: [_]{$passcode1} %] + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +$right1 = $x1 + 4; +$top1 = $y1 + 6; +$left1 = $x1 - 4; +$bottom1 = $y1 - 2; + +$right2 = $x2_right + 2; +$top2 = $y2_top + 5; +$left2 = $x2_left - 2; +$bottom2 = $y2_bottom - 5; + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'function', latex: 'f(x) = $f1', color: Desmos.Colors.BLUE}, + ]); + + my_calculator.setMathBounds({ + left: $left1, + right: $right1, + bottom: $bottom1, + top: $top1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, authorFeatures: true, expressions: false }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id2"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'left_endpoint', latex: '($x1_min,$y1_left),($x1_max,$y1_right)', color: Desmos.Colors.BLUE}, + { id: 'function', latex: 'f(x) = $f1 \\left\\{ $x1_min\\leq x\\leq $x1_max\\right\\}', color: Desmos.Colors.BLUE}, + ]); + + my_calculator.setMathBounds({ + left: $left1, + right: $right1, + bottom: $bottom1, + top: $top1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id3"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'left_endpoint', latex: '($x2_left,$y2_left),($x2_right,$y2_right)', color: Desmos.Colors.GREEN}, + { id: 'function', latex: 'f(x) = $f2 \\left\\{ $x2_left\\leq x\\leq $x2_right\\right\\}', color: Desmos.Colors.GREEN}, + ]); + + my_calculator.setMathBounds({ + left: $left2, + right: $right2, + bottom: $bottom2, + top: $top2 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id4"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'function', latex: 'f(x) = $f2', color: Desmos.Colors.GREEN}, + { id: 'local_max', latex: '($x2_top,$y2_top)', color: Desmos.Colors.RED}, + { id: 'local_min', latex: '($x2_bottom,$y2_bottom)', color: Desmos.Colors.BLUE}, + { id: 'fake_max', latex: '($x2_start,$y2_start)', color: Desmos.Colors.PURPLE}, + { id: 'fake_min', latex: '($x2_fake,$y2_fake)', color: Desmos.Colors.BLACK}, + ]); + + my_calculator.setMathBounds({ + left: $left2, + right: $right2, + bottom: $bottom2, + top: $top2 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id5"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'slider', latex: 'a=$x2_start', sliderBounds: {min: $x2_left-2, max: $x2_right+2, secret:'true', step: 0.1}}, + { id: 'function', latex: 'f(x) = $f2_str', color: Desmos.Colors.GREEN}, + { id: 'local_max', latex: '($x2_top,$y2_top)', color: Desmos.Colors.RED}, + { id: 'local_min', latex: '($x2_bottom,$y2_bottom)', color: Desmos.Colors.BLUE}, + { id: 'base_point', latex: '(a, f(a))', color: Desmos.Colors.BLACK}, + { id: 'tangent_line', latex: 'y = f\'(a)*(x-a) + f(a)', label: 'tangent line', color: Desmos.Colors.BLACK}, + ]); + + my_calculator.setMathBounds({ + left: $left2, + right: $right2, + bottom: $bottom2, + top: $top2 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_2_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_2_of_3.pg new file mode 100644 index 0000000000..9731fa751e --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_2_of_3.pg @@ -0,0 +1,370 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Rates of change') +## Date('Summer 2023') +## Author('Warren Shull') +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS +); + +loadMacros("customCSS.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; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + +$unique_div_id = "nonexistent_derivative"; +$unique_div_id2 = "sloping_tangents"; +$unique_div_id3 = "absolute_yes_or_no"; +$width = 700; +$height = 400; + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +############################################################## +# +# Setup + +Context("Point"); +Context("Numeric"); +Context()->variables->add(t=>'Real'); + +$x1 = non_zero_random(-10,10); #middle, where $a begins +$y1 = non_zero_random(-10,10); #up or down shift from default +$x2 = non_zero_random(-10,10); #middle, where $a begins +$y2_up = non_zero_random(-10,10); #up or down shift from default +$x2_left = $x2-1; +$x2_right = $x2+1; +$y2 = $y2_up-1; + +$x1_max = $x1+1; +$x1_min = $x1-2; + +$f1 = Formula("(x-$x1)^2+$y1"); +$y1_left = $f1->eval(x=>$x1_min); +$y1_right = $f1->eval(x=>$x1_max); + +$k2 = 3; +$m2 = 2; +$n2 = 12; +$C2 = 2; +$x2cp1 = $m2-sqrt($n2/$k2); +$x2cp2 = $m2+sqrt($n2/$k2); +$x2_mid = ($x2cp1+$x2cp2)/2; +$x2_min = $x2cp1-1; +$x2_max = $x2cp2+1; + +$f2 = Formula("$k2(x-$m2)^3/3-$n2*x+$C2"); +$y2_left = $f2->eval(x=>$x2_min); +$y2_right = $f2->eval(x=>$x2_max); +$y2_min = $f2->eval(x=>$x2cp2); +$y2_max = $f2->eval(x=>$x2cp1); +$y2_mid = $f2->eval(x=>$x2_mid); + +$a1 = random(-5,-1); +$b1 = random(-5,-1); +$c1 = random(1,5); +$d1 = random(1,5); +$m1top = $d1-$b1; +$m1bottom=$c1-$a1; + +$x3=random(-10,10); +$y3=random(-10,10); + +$color_choice = PopUp( + ["Choose one", "red","black","blue","green","orange","purple"], + "purple"); + +## THIS IS PROBLEM 2 OF A 3 PROBLEM SERIES INTRODUCING THE EXTREME VALUE THEOREM. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); + +## END PASSCODE CODE + + +############################################################## +# +# Text + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +Section::Begin("Passcode"); + +BEGIN_PGML + +At the end of the previous problem, we saw... + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Fermat's Theorem*: + +If [`(c,f(c))`] is a local maximum or minimum, then either [`f'(c)=0`] or [`f'(c)`] does not exist. +[@ closeDiv() @]* + +[% Enter the passcode from the previous question: + +[_]{$passcode1} %] + +END_PGML +Section::End(); + +Section::Begin("Derivatives that don't exist???"); + +BEGIN_PGML + +On the graph below, there are no points with horizontal tangent lines. + +[@ $desmos_div @]* + +However, there is still a local maximum and a local minimum. + +* Local minimum: [`\big(`][_]{$a1}[`,`][_]{$b1}[`\big)`] + +* Local maximum: [`\big(`][_]{$c1}[`,`][_]{$d1}[`\big)`] + +* Find the derivative at the local minimum point. If it does not exist, write DNE. [_]{String('DNE')->cmp} + +* Find the derivative at the local maximum point. If it does not exist, write DNE. [_]{String('DNE')->cmp} + +END_PGML +Section::End(); + +Section::Begin("Why is Fermat's Theorem true?"); + +BEGIN_PGML + +There are just 4 possibilities for a derivative at any point. It can be positive, negative, zero, or not exist. + +If it is positive or negative, we have a tangent line sloping either up or down. + +[@ $desmos_div2 @]* + +If you zoom in to either the blue or green point, the graph should look similar to its tangent line. (If you like, you can click to turn the tangent lines on and off.) As you can see, there are nearby points both above and below the point in question, so it cannot be a local maximum or minimum. (That is why the derivative must either equal 0 or not exist.) + +END_PGML +Section::End(); + +Section::Begin("Is there an absolute maximum or minimum?"); + +BEGIN_PGML + +As we have seen, not every function has an absolute maximum or minimum. Looking at each of these graphs, decide whether an absolute maximum exists or not, and whether an absolute minimum exists. + +[@ $desmos_div3 @]* + +For each color, enter the absolute maximum and minimum ([`y`]-values only) if they exist. If they don't exist, write "none". + +Red absolute maximum: [_]{String('none')->cmp} Red absolute minimum: [_]{$y3-3} + +Black absolute maximum: [_]{$y3-2} Black absolute minimum: [_]{String('none')->cmp} + +Blue absolute maximum: [_]{String('none')->cmp} Blue absolute minimum: [_]{$y3-1} + +Green absolute maximum: [_]{$y3+3} Green absolute minimum: [_]{String('none')->cmp} + +Orange absolute maximum: [_]{$y3+6} Orange absolute minimum: [_]{String('none')->cmp} + +Purple absolute maximum: [_]{$y3+4} Purple absolute minimum: [_]{$y3-6} + +Only one of these has both an absolute maximum and minimum. Which one? [_]{$color_choice} + +END_PGML +Section::End(); + +Section::Begin("When MUST absolute extrema exist?"); + +BEGIN_PGML + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Extreme Value Theorem*: + +If a function [`f`] is continuous on a closed interval [`[a,b]`], then [`f`] has both an absolute minimum and an absolute maximum on [`[a,b]`]. +[@ closeDiv() @]* + +[% The passcode for the next question is [`[$passcode2]`]. Enter it here: [_]{$passcode2} %] + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +$right1 = $x1 + 4; +$top1 = $y1 + 6; +$left1 = $x1 - 4; +$bottom1 = $y1 - 2; + +$right2 = $x3 + 6; +$top2 = $y3 + 7; +$left2 = $x3 - 5; +$bottom2 = $y3 - 7; + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'left1', latex: 'y = -2(x-$a1)+$b1 \\left\\{x\\leq$a1\\right\\}', color: Desmos.Colors.BLUE}, + { id: 'middle1', latex: 'y = $m1top/$m1bottom(x-$a1)+$b1 \\left\\{$a1\\leq x\\leq$c1\\right\\}', color: Desmos.Colors.BLUE}, + { id: 'right1', latex: 'y = -2(x-$c1)+$d1 \\left\\{x\\geq$c1\\right\\}', color: Desmos.Colors.BLUE}, + ]); + + my_calculator.setMathBounds({ + left: $a1-5, + right: $c1+5, + bottom: $b1-1, + top: $d1+1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id2"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'negative slope', latex: 'y-$y2_up = -2(x-$x2_left)', color: Desmos.Colors.BLUE}, + { id: 'positive slope', latex: 'y-$y2_up = 2(x-$x2_right)', color: Desmos.Colors.GREEN}, + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'parabola', latex: 'y = (x-$x2)^2+$y2', color: Desmos.Colors.BLACK}, + { id: 'negative slope point', latex: '($x2_left,$y2_up)', color: Desmos.Colors.BLUE}, + { id: 'positive slope point', latex: '($x2_right,$y2_up)', color: Desmos.Colors.GREEN}, + ]); + + my_calculator.setMathBounds({ + left: $x2-1.5, + right: $x2+1.5, + bottom: $y2+0.5, + top: $y2+3 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id3"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + expressions: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '},{ latex: ' '}, + { id: 'black', latex: 'y = \\frac{16}{(x-$x3)^2-16}-1+$y3 \\left\\{$x3-4 +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_3_of_3.pg b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_3_of_3.pg new file mode 100644 index 0000000000..c025fecfd0 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/extreme_value_theorem_problem_3_of_3.pg @@ -0,0 +1,295 @@ +##DESCRIPTION +## Training problem on the relationship between rates of change and slopes of lines +##ENDDESCRIPTION + +##KEYWORDS('secant line', 'tangent line', 'slope', 'average rate of change', 'instantaneous rate of change') + +## DBsubject('Calculus') +## DBchapter('Limits, Derivatives') +## DBsection('Rates of change') +## Date('Summer 2023') +## Author('Warren Shull') +## Institution('UWEC') + +######################################################################## + +DOCUMENT(); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + "PGcourse.pl", # Customization file for the course + "scaffold.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS +); + +loadMacros("customCSS.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; + +################################ +# Desmos setup +# +# In html mode, load the Desmos api script and create the
to attach the Desmos graph to. +# In tex mode, print a message to direct the student to the html version. +# Desmos API reference: https://www.desmos.com/api/v1.7/docs/index.html + + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +############################################################## +# +# Setup + +Context("Point"); +Context("Numeric"); +Context()->variables->add(t=>'Real',c=>'Real'); + +$x1 = random(-5,2); +$x2 = $x1+3; +$a = 3*$x1+3*$x2; +$b = 6*$x1*$x2; +$y1 = random(-10,10); +$c = random(-10,10); +$c_left = $c-1; +$c_right = $c+1; +$d = random(1,10); + +$f = Formula("2*x^3-$a*x^2+$b*x+$y1")->reduce; +$fp = Formula("6*x^2-2*$a*x+$b")->reduce; +$fpc = Formula("6*c^2-2*$a*c+$b")->reduce; +$g_partial = Formula("x-$c")->reduce; +$g_partial_c = Formula("c-$c")->reduce; +$g = Formula("x-3*((x-$c)^2)^(1/3)+$d"); #displays badly; only using to evaluate +$gp = Formula("1-2*(x-$c)^(-1/3)"); +$gpc = Formula("1-2*(c-$c)^(-1/3)"); + +$left=$x1-1; +$right=$x2+2; + +$y2 = $f->eval(x=>$left); +$y3 = $f->eval(x=>$x1); +$y4 = $f->eval(x=>$x2); +$y5 = $f->eval(x=>$right); + +$y_max = $y5; #underscore for f +if ($y2>$y_max){$y_max=$y2}; +if ($y3>$y_max){$y_max=$y3}; +if ($y4>$y_max){$y_max=$y4}; + +$y_min = $y4; #underscore for f +if ($y2<$y_min){$y_min=$y2}; +if ($y3<$y_min){$y_min=$y3}; +if ($y5<$y_min){$y_min=$y5}; + +$y7 = $g->eval(x=>$c); +$y6 = $g->eval(x=>$c_left); +$y8 = $g->eval(x=>$c_right); + +$ymax = $y7; #no underscore for g +if ($y6>$ymax){$ymax=$y6}; +if ($y8>$ymax){$ymax=$y8}; + +$ymin = $y6; #no underscore for g +if ($y7<$ymin){$ymin=$y7}; +if ($y8<$ymin){$ymin=$y8}; + +#$list1=List(1,3); + +$dropmenu = PopUp( + ["Choose one", "wrong1","wrong2","correct"], + "correct"); + +## THIS IS PROBLEM 3 OF A 3 PROBLEM SERIES INTRODUCING THE EXTREME VALUE THEOREM. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); + +## END PASSCODE CODE + + + +############################################################## +# +# Text + +Scaffold::Begin( + can_open => "when_previous_correct", + is_open => "first_incorrect" +); + +Section::Begin("Passcode"); + +BEGIN_PGML + +At the end of the previous problem, we saw... + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Extreme Value Theorem*: + +If a function [`f`] is continuous on a closed interval [`[a,b]`], then [`f`] has both an absolute minimum and an absolute maximum on [`[a,b]`]. +[@ closeDiv() @]* + +[% Enter the passcode from the previous problem: [_]{$passcode2} %] + +So far, we have been finding the absolute maximum and minimum from graphs. How do we find them from an algebraic expression? + +END_PGML +Section::End(); + +Section::Begin("Closed Interval Method"); + +BEGIN_PGML + +[@ openDiv({ "class" => "importantFormula" }) @]* +*Fermat's Theorem*: + +If [`(c,f(c))`] is a local maximum or minimum, then either [`f'(c)=0`] or [`f'(c)`] does not exist. +[@ closeDiv() @]* + +If [`f'(c)=0`] or [`f'(c)`] does not exist, we call the point [`(c,f(c))`] a _critical point_ (or [`c`] a _critical number_). The absolute maximum of [`f`] on a closed interval [`[a,b]`] can be [`a`], or [`b`], or one of the critical points. Anywhere else, the tangent line would slope up or down, so there would be nearby points both above and below (see "Why is Fermat's Theorem true?" in the previous problem). + +If we can find the [`x`]-values for these points, we can plug them in and get the [`y`]-values. One will be the highest, and one will be the lowest! + +[% Enter the passcode again: [_]{$passcode2} %] + +END_PGML +Section::End(); + +Section::Begin("Finding critical numbers"); + +BEGIN_PGML + +Let [`f(x)=[$f]`]. Let's find the absolute maximum and minimum of [`f`] on [`[[$x1-1],[$x2+2]]`]. + +[`f'(x)=`] [_]{$fp} + +We need all values of [`c`] such that [`f'(c)=0`] or [`f'(c)`] does not exist. In this case, [`f'(c)`] will always exist, but we can set [`f'(c)=0`]. Type [`f'(c)`] in the box below (same as your previous answer, but replace each [`x`] with [`c`]): + +[_]{$fpc} [` =0`] + +Now let's factor it! The first box should be a constant, and the others should be [`(c+\mbox{something})`] or [`(c-\mbox{something})`]. (If WebWork won't accept your factors, try swapping the order.) + +[_]{6}[`\cdot\Big(`][_]{Formula("c-$x1")}[`\Big)\cdot\Big(`][_]{Formula("c-$x2")}[`\Big)=0`] + +Now solve for [`c`]. Enter the lower value first, and the higher one second: [`c=`] [_]{$x1} or [`c=`] [_]{$x2}. + +These are our critical numbers! + +END_PGML +Section::End(); + +Section::Begin("Choosing the correct maximum and minimum"); + +BEGIN_PGML + +Recall that the interval is [`[[$left],[$right]]`]. + +To find the maximum and minimum, we test the critical numbers and the endpoints of the interval. List those four [`x`] values, separated by commas: [_]{List("$left,$x1,$x2,$right")}; + +Now we evaluate [`f`] at each of these [`x`]-values. Enter the [`x`]-values in increasing order on the left, then enter the correct [`y`]-value in each box on the right. + +Enter the [`x`]-value at the left endpoint (the first number in the interval). Then find the [`y`]-value. of the interval: + +[`f\Big(`][_]{$left}[`\Big)=`] [_]{$y2}; + +[`f\Big(`][_]{$x1}[`\Big)=`] [_]{$y3}; + +[`f\Big(`][_]{$x2}[`\Big)=`] [_]{$y4}; + +[`f\Big(`][_]{$right}[`\Big)=`] [_]{$y5}; + +The absolute maximum is the highest [`y`]-value: [_]{$y_max} + +The absolute maximum is the lowest [`y`]-value: [_]{$y_min} + +END_PGML +Section::End(); + +Section::Begin("Another example"); + +BEGIN_PGML + +Let [`g(x)=x-3([$g_partial])^{\frac23}+[$d]`]. Let's find the absolute maximum and minimum of [`g`] on [`[[$c-1],[$c+1]]`]. + +[`g'(x)=`] [_]{$gp} + +END_PGML +Section::End(); + +Section::Begin("Zero derivative"); + +BEGIN_PGML + +Now let's solve the equation [`g'(c)=0`]. Fill in [`g'(c)`] in the box. Express it without any negative or fractional exponents (introducing fractions and roots as needed). + +[_]{$gpc} [`=0`] + +Now solve it for [`c`]. + +[`c=`] [_]{$c+8} + + +END_PGML +Section::End(); + +Section::Begin("Nonexistent derivative"); + +BEGIN_PGML + +But we also need the values where [`g'(c)`] does not exist. In this case, that will happen when [`\sqrt[3]{[$g_partial_c]}=0`]. Solve this for [`c`]. + +[`c=`] [_]{$c} + +END_PGML +Section::End(); + +Section::Begin("Finishing the job"); + +BEGIN_PGML + +Recall that the interval is [`[[$c-1],[$c+1]]`]. + +List the four [`x`] values that are either a critical number or an endpoint (separated by commas): [_]{List("$c-1,$c,$c+1,$c+8")} + +You may have noticed that one of these numbers is outside the interval. We don't need to worry about that one! List the other three: [_]{List("$c-1,$c,$c+1")} + +Now we evaluate [`g`] at each of these [`x`]-values (in increasing order), as before. + +[`g\Big(`][_]{$c-1}[`\Big)=`] [_]{$y6}; + +[`g\Big(`][_]{$c}[`\Big)=`] [_]{$y7}; + +[`g\Big(`][_]{$c+1}[`\Big)=`] [_]{$y8}; + +The absolute maximum is the highest [`y`]-value: [_]{$ymax} + +The absolute maximum is the lowest [`y`]-value: [_]{$ymin} + +END_PGML +Section::End(); + +Scaffold::End(); + +Context()->normalStrings; + +################################## +# Desmos graph (via the API) +# Execute this only after the $desmos_div object has been put on the html page. + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_1_of_4.pg b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_1_of_4.pg new file mode 100644 index 0000000000..ab43bb0109 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_1_of_4.pg @@ -0,0 +1,523 @@ +# DESCRIPTION +## DBsubject('Calculus') +## DBchapter('Limits') +## DBsection('Investigating Limits') +## KEYWORDS('Limits') +## TitleText1('Calculus: Early Transcendentals') +## EditionText1('4') +## AuthorText1('Rogawski') +## Section1('2.2') +## Institution('UW Eau Claire') +## Copied and modified by Warren Shull (UWEC) July 29, 2023 + +DOCUMENT(); +loadMacros("PG.pl", + "PGcourse.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "scaffold.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl", + "freemanMacros.pl", + "AnswerFormatHelp.pl", + "Parser.pl"); + +loadMacros("niceTables.pl"); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + #"PGcourse.pl", # Customization file for the course + #"scaffold.pl", + "unionTables.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +Context("Numeric"); + +$dne = String("DNE"); + +$a3=random(30,40,1); +$a=random(1,3,1); + +$a2=Formula(".5+$a"); +$aa1=Formula("$a+.01"); +$aa2=Formula("$a+.001"); +$aa3=Formula("$a+.0001"); +$aa4=Formula("$a-.01"); +$aa5=Formula("$a-.001"); +$aa6=Formula("$a-.0001"); + +$av1=Real("($a3*$aa1-4.9*(($aa1)^2)-($a3 *$a -4.9* (($a)^2)))/0.01"); +$av2=Real("($a3*$aa2-4.9*(($aa2)^2)-($a3 *$a -4.9* (($a)^2)))/0.001"); +$av3=Real("($a3*$aa3-4.9*(($aa3)^2)-($a3 *$a -4.9* (($a)^2)))/0.0001"); +$av4=Real("($a3*$a-4.9*(($a)^2)-($a3 *$aa4 -4.9* (($aa4)^2)))/0.01"); +$av5=Real("($a3*$a-4.9*(($a)^2)-($a3 *$aa5 -4.9* (($aa5)^2)))/0.001"); +$av6=Real("($a3*$a-4.9*(($a)^2)-($a3 *$aa6 -4.9* (($aa6)^2)))/0.0001"); +$answ=Real("$a3-9.8*$a"); + +$b=non_zero_random(-5,5); +$b_example=$b+2.5; +$c=non_zero_random(-5,5); + +$f_top=Formula("x^2-([$b+$c])x+$b*$c")->reduce; +$f_bottom=Formula("x-$b")->reduce; + +$f=Formula("$f_top/$f_bottom")->reduce; +$fp=Formula("x"); +$gp=Formula("x"); + +$b1=$b-.2; +$b2=$b-.05; +$b3=$b-.01; +$b4=$b+.2; +$b5=$b+.05; +$b6=$b+.01; + +$fb1 = $f->eval(x=>$b1); +$fb2 = $f->eval(x=>$b2); +$fb3 = $f->eval(x=>$b3); +$fb4 = $f->eval(x=>$b4); +$fb5 = $f->eval(x=>$b5); +$fb6 = $f->eval(x=>$b6); + +$j=random(-7,-1); +$d=$j+2; +$i=$j+random(1,10-$j,2); +#while($i==$j){$i=non_zero_random(-10,10);} + +$g_top=Formula("x^2-([$d+$i])x+$d*$i")->reduce; +$g_bottom=Formula("x^2-([$d+$j])x+$d*$j")->reduce; + +$g=Formula("$g_top/$g_bottom"); + +$d1=$d-.01; +$d2=$d-.001; +$d3=$d-.0001; +$d4=$d+.01; +$d5=$d+.001; +$d6=$d+.0001; + +$gd1 = $g->eval(x=>$d1); +$gd2 = $g->eval(x=>$d2); +$gd3 = $g->eval(x=>$d3); +$gd4 = $g->eval(x=>$d4); +$gd5 = $g->eval(x=>$d5); +$gd6 = $g->eval(x=>$d6); + +$p=random(1,5); +while($p==3){ + $p=random(1,5); +} + +$p1=-.15; +$p2=-.06; +$p3=-.02; +$p4=.15; +$p5=.06; +$p6=.02; + +$h_top=Formula("1-cos(x)")->reduce; +$h_bottom=Formula("$p*x^2")->reduce; + +$h=Formula("$h_top/$h_bottom")->reduce; + +$hp1 = $h->eval(x=>$p1); +$hp2 = $h->eval(x=>$p2); +$hp3 = $h->eval(x=>$p3); +$hp4 = $h->eval(x=>$p4); +$hp5 = $h->eval(x=>$p5); +$hp6 = $h->eval(x=>$p6); + +$width = 200; +$height = 200; + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$unique_div_id = "evaluating_f"; +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id2 = "evaluating_g"; +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id3 = "evaluating_h"; +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +## THIS IS PROBLEM 1 OF A 4 PROBLEM SERIES INTRODUCING LIMITS ALGEBRAICALLY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); + +## END PASSCODE CODE + +TEXT(beginproblem()); +Context()->texStrings; + +Scaffold::Begin(can_open => "when_previous_correct", is_open => "first_incorrect"); +########################################### +Section::Begin("Close, but not exact"); + +BEGIN_PGML +Throughout the previous section, we looked at average rates of change (such as average velocities) between a "base point" and another point. We wanted the other point to be _close_ to the first one, but *not the exact same point*. (If it were the exact same point, finding the slope would involve dividing by zero.) + +As a reminder, here is one of the tables you filled out in the previous section (with the answer boxes removed, and possibly with different numbers): + +[@ +DataTable( +[ + ["time interval","average velocity" ], + ['\( ['.$a.', '.$aa1.'] \)',''], + ['\( ['.$a.', '.$aa2.'] \)',""], + ['\( ['.$a.', '.$aa3.'] \)',""], + ['\( ['.$aa4.', '.$a.'] \)',""], + ['\( ['.$aa5.', '.$a.'] \)',""], + ['\( ['.$aa6.', '.$a.'] \)',""], +], +align => '|l | l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +[%BEGIN_TEXT (OLD VERSION OF THE TABLE) + +$PAR +\{begintable(2)\} + \{row("time interval","average velocity",@firstrow)\} + \{row("\( [$a, $aa1]\)","\(\qquad \qquad\)",@secondrow)\} + \{row("\([$a, $aa2]\)","\(\qquad \qquad\)",@thirdrow)\} + \{row("\([$a, $aa3]\)","\(\qquad \qquad\)",@fourthrow)\} + \{row("\([$aa6, $a]\)","\(\qquad \qquad\)",@fifthrow)\} + \{row("\([$aa5, $a]\)","\(\qquad \qquad\)",@sixthrow)\} + \{row("\([$aa4, $a]\)","\(\qquad \qquad\)",@seventhrow)\} +\{endtable()\}$PAR + +END_TEXT%] + +After filling out the table, you estimated what number your answers were getting _close_ to, even though they were not exactly the same. However, it was *not possible* to find the "average velocity" over [`[[$a],[$a]]`] as the rise and run would both be 0. + +We would like more precise language for talking about inputs and outputs that are _close_ to certain numbers, but not exactly equal. As an example, let [``f(x)=[$f]``]. Retype the numerator and denominator here: + +[`f(x)=\Big(`][_]{Formula("$f_top")->reduce}[`\Big)/\Big(`][_]{Formula("$f_bottom")->reduce}[`\Big)`] + +END_PGML + +Section::End(); + +Section::Begin("Filling in a table"); + +BEGIN_PGML + +Fill in the table below. You can use the window on the right as a calculator; simply backspace out the [`[$b_example]`] and replace it with any other value of [`x`]. + +END_PGML + +$table=DataTable( +[ + ['\(x\)','\(f(x)\)'], + ['\('.$b1.'\)',ans_rule(10)], + ['\('.$b2.'\)',ans_rule(10)], + ['\('.$b3.'\)',ans_rule(10)], + ['\('.$b4.'\)',ans_rule(10)], + ['\('.$b5.'\)',ans_rule(10)], + ['\('.$b6.'\)',ans_rule(10)], +], +align => '|l | l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div)); + +#[@ $desmos_div @]* + +#ANS($fb1->cmp(tolType => 'absolute',tolerance => .5)); + +ANS($fb1->cmp()); + +ANS($fb2->cmp()); + +ANS($fb3->cmp()); + +ANS($fb4->cmp()); + +ANS($fb5->cmp()); + +#Context()->{format}{number} = "%.1f"; + +ANS($fb6->cmp()); + +#Context()->{format}{number} = "%g"; + +BEGIN_PGML +As [`x`] gets closer to [`[$b]`], what number is [`f(x)`] getting closer to? [_]{Formula("$b-$c")->reduce} +END_PGML + +Section::End(); + +Section::Begin("Introducing Limits!"); + +BEGIN_PGML + +Since [`f(x)`] gets closer to [`[$b-$c]`] as [`x`] gets closer to [`[$b]`], we write: + +[``\lim_{x\rightarrow[$b]}f(x)=[$b-$c]``] + +which we say out loud as: + +"The limit of [`f(x)`] as [`x`] approaches [`[$b]`] equals [`[$b-$c]`]." + +Meanwhile, what is [`f([$b])`]? If it does not exist, you may write DNE. + +[`f([$b])=`] [_]{$dne} + +END_PGML + +Section::End(); + +Section::Begin("More examples"); + +BEGIN_PGML + +Let [`g(x)=[$g]`]. Let's try to find [``\lim_{x\rightarrow[$d]}g(x)``]. Round each answer to as many decimal places as the number in the "rounding" column. (You can still type [`g(`]any number[`)`] in line 2 of the window on the right as a calculator.) + +END_PGML +#[@ $desmos_div2 @]* + + +$table=DataTable( +[ + ['\(x\)',"rounding",'\(g(x)\)'], + ['\('.$d1.'\)',3,ans_rule(10)], + ['\('.$d2.'\)',4,ans_rule(10)], + ['\('.$d3.'\)',5,ans_rule(10)], + ['\('.$d4.'\)',3,ans_rule(10)], + ['\('.$d5.'\)',4,ans_rule(10)], + ['\('.$d6.'\)',5,ans_rule(10)], +], +align => '|l | c|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div2)); + +#Context()->{format}{number} = "%18.15f"; +Context()->{format}{number} = "%.3f"; + +ANS(Real(sprintf("%.3f",$gd1))->cmp()); + +Context()->{format}{number} = "%.4f"; + +ANS(Real(sprintf("%.4f",$gd2))->cmp()); + +#ANS(Real(sprintf("%.3f",$gd2->value))->cmp(tolType => 'absolute',tolerance => .01)); +Context()->{format}{number} = "%.5f"; + +ANS(Real(sprintf("%.5f",$gd3))->cmp()); + +Context()->{format}{number} = "%.3f"; + +ANS(Real(sprintf("%.3f",$gd4))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$gd5))->cmp()); +Context()->{format}{number} = "%.5f"; + +ANS(Real(sprintf("%.5f",$gd6))->cmp()); + +#ANS(Real(sprintf("%.8f",$gd6))->cmp(tolType => 'absolute',tolerance => 1e-7)); +Context()->{format}{number} = "%g"; + +#ANS($gd6->cmp()); + +BEGIN_PGML + +[``\lim_{x\rightarrow[$d]}g(x)=``] [_]{Formula("($d-$i)/($d-$j)")->reduce} + +[`g([$d])=`] [_]{$dne} + +-------- + +Let [`h(x)=[$h]`]. Let's try to find [``\lim_{x\rightarrow0}h(x)``]. Again, round to as many decimal places as the number in the "rounding" column. + +END_PGML + +$table=DataTable( +[ + ['\(x\)',"rounding",'\(h(x)\)'], + ['\('.$p1.'\)',4,ans_rule(10)], + ['\('.$p2.'\)',5,ans_rule(10)], + ['\('.$p3.'\)',6,ans_rule(10)], + ['\('.$p4.'\)',4,ans_rule(10)], + ['\('.$p5.'\)',5,ans_rule(10)], + ['\('.$p6.'\)',6,ans_rule(10)], +], +align => '|l | c|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div3)); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hp1))->cmp()); + +Context()->{format}{number} = "%.5f"; +ANS(Real(sprintf("%.5f",$hp2))->cmp()); + +Context()->{format}{number} = "%.6f"; +ANS(Real(sprintf("%.6f",$hp3))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hp4))->cmp()); + +Context()->{format}{number} = "%.5f"; +ANS(Real(sprintf("%.5f",$hp5))->cmp()); + +Context()->{format}{number} = "%.6f"; +ANS(Real(sprintf("%.6f",$hp6))->cmp()); + +Context()->{format}{number} = "%g"; + +BEGIN_PGML + +[``\lim_{x\rightarrow0}h(x)=``] [_]{Formula("1/(2*$p)")->reduce} + +[`h(0)=`] [_]{$dne} + +END_PGML + +Section::End(); + +#Section::Begin("Passcode"); + +#BEGIN_PGML + +#In the examples you just saw, [``\lim_{x\rightarrow a}f(x)``] always existed even though [`f(a)`] did not. Not all limits exist, however! In the next problem, you will see some limits that do not exist, and some problems where [`f(a)`] and [``\lim_{x\rightarrow a}f(x)``] are two different numbers! + +#The passcode for the next problem is [`[$passcode1]`]. Enter it here: [_]{$passcode1} + +#END_PGML + +#Section::End(); + + Scaffold::End(); + +Context()->normalStrings; + +#ANS( num_cmp( $answ, tol=>0.001, tolType=>"absolute" )); + +#ANS($dq->cmp); + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + graphpaper: false, + expressions: true, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'function', latex: 'f(x)=\\frac{$f_top}{$f_bottom}'}, + { id: 'plugin', latex: 'f($b_example)'}, + ]); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id2"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + graphpaper: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'function', latex: 'g(x)=\\frac{$g_top}{$g_bottom}'}, + ]); + + my_calculator.setMathBounds({ + left: 99, + right: 101, + bottom: 99, + top: 101 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id3"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + graphpaper: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'function', latex: 'h(x)=\\frac{1-\\cos x}{$p x^2}'}, + ]); + + my_calculator.setMathBounds({ + left: 99, + right: 101, + bottom: 99, + top: 101 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_2_of_4.pg b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_2_of_4.pg new file mode 100644 index 0000000000..f3e5774826 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_2_of_4.pg @@ -0,0 +1,523 @@ +# DESCRIPTION +## DBsubject('Calculus') +## DBchapter('Limits') +## DBsection('Investigating Limits') +## KEYWORDS('Limits', 'one-sided', 'infinity') +## TitleText1('Calculus: Early Transcendentals') +## EditionText1('4') +## AuthorText1('Rogawski') +## Section1('2.2') +## Institution('UW Eau Claire') + +# Copied and modified by Warren Shull (UWEC) August 7, 2023 + +DOCUMENT(); +loadMacros("PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "scaffold.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl", + "freemanMacros.pl", + "AnswerFormatHelp.pl", + "Parser.pl"); + +loadMacros("niceTables.pl"); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + #"PGcourse.pl", # Customization file for the course + #"scaffold.pl", + "unionTables.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +loadMacros( + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", # <---- MAKES BOXES PURPLE +); + +Context("Numeric"); + +$yes = PopUp( + ["Choose one", "yes","no"], + "yes"); + +$no = PopUp( + ["Choose one", "yes","no"], + "no"); + +$dne = String("DNE"); + +#$contin = String('continuous'); + +$a=random(-3,3,2); + +$a1=$a-.1; +$a2=$a-.01; +$a3=$a-.001; +$a4=$a+.1; +$a5=$a+.01; +$a6=$a+.001; + +$f=Formula("cos(pi/x)")->reduce; + +$fa = $f->eval(x=>$a); +$fa1 = $f->eval(x=>$a1); +$fa2 = $f->eval(x=>$a2); +$fa3 = $f->eval(x=>$a3); +$fa4 = $f->eval(x=>$a4); +$fa5 = $f->eval(x=>$a5); +$fa6 = $f->eval(x=>$a6); + +$b1=2; +$b2=2/3; +$b3=2/5; +$b4=-2; +$b5=-2/3; +$b6=-2/5; + +$fb1 = $f->eval(x=>$b1); +$fb2 = $f->eval(x=>$b2); +$fb3 = $f->eval(x=>$b3); +$fb4 = $f->eval(x=>$b4); +$fb5 = $f->eval(x=>$b5); +$fb6 = $f->eval(x=>$b6); + +$c1=-1; +$c2=-1/3; +$c3=-1/5; +$c4=1; +$c5=1/3; +$c6=1/5; + +$fc1 = $f->eval(x=>$c1); +$fc2 = $f->eval(x=>$c2); +$fc3 = $f->eval(x=>$c3); +$fc4 = $f->eval(x=>$c4); +$fc5 = $f->eval(x=>$c5); +$fc6 = $f->eval(x=>$c6); + +$d1=-1/2; +$d2=-1/4; +$d3=-1/6; +$d4=1/2; +$d5=1/4; +$d6=1/6; + +$fd1 = $f->eval(x=>$d1); +$fd2 = $f->eval(x=>$d2); +$fd3 = $f->eval(x=>$d3); +$fd4 = $f->eval(x=>$d4); +$fd5 = $f->eval(x=>$d5); +$fd6 = $f->eval(x=>$d6); + +$j=random(-7,-1); +$d=$j+2; +$i=$j+random(1,10-$j,2); +#while($i==$j){$i=non_zero_random(-10,10);} + + +$p1=-1; +$p2=-.2; +$p3=-.05; +$p4=1; +$p5=.2; +$p6=.05; + +## THIS IS PROBLEM 2 OF A 4 PROBLEM SERIES INTRODUCING LIMITS ALGEBRAICALLY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); +#$passcode3 = random(1000,9999); + +## END PASSCODE CODE + + + + +$p=non_zero_random(-5,5); +$g=Formula("$p*x/|x|"); + +$gp1 = $g->eval(x=>$p1); +$gp2 = $g->eval(x=>$p2); +$gp3 = $g->eval(x=>$p3); +$gp4 = $g->eval(x=>$p4); +$gp5 = $g->eval(x=>$p5); +$gp6 = $g->eval(x=>$p6); + +$width = 200; +$height = 200; + +HEADER_TEXT(MODES( + HTML=>'', + TeX=>'' +)); + +$unique_div_id = "evaluating_f"; +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + + +TEXT(beginproblem()); +Context()->texStrings; + +Scaffold::Begin(can_open => "when_previous_correct", is_open => "first_incorrect"); +########################################### +Section::Begin("New function!"); + +BEGIN_PGML + +The next function we will look at is [``f(x)=\cos\left(\frac\pi x\right)``]. + +[% Enter the passcode from the previous problem: [_]{$passcode1} %] + +END_PGML + +Section::End(); + +Section::Begin('x approaching ' . $a); + +BEGIN_PGML + +First, let's find [``\lim_{x\rightarrow[$a]}\cos\left(\frac\pi x\right)``]: + +END_PGML + +$table=DataTable( +[ + ['\(x\)',"rounding",'\(f(x)\)'], + ['\('.$a1.'\)',2,ans_rule(10)], + ['\('.$a2.'\)',4,ans_rule(10)], + ['\('.$a3.'\)',6,ans_rule(10)], + ['\('.$a4.'\)',2,ans_rule(10)], + ['\('.$a5.'\)',4,ans_rule(10)], + ['\('.$a6.'\)',6,ans_rule(10)], +], +align => '|l | c|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div)); + + +Context()->{format}{number} = "%.2f"; +ANS(Real(sprintf("%.2f",$fa1))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$fa2))->cmp()); + +Context()->{format}{number} = "%.6f"; +ANS(Real(sprintf("%.6f",$fa3))->cmp()); + +Context()->{format}{number} = "%.2f"; +ANS(Real(sprintf("%.2f",$fa4))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$fa5))->cmp()); + +Context()->{format}{number} = "%.6f"; +ANS(Real(sprintf("%.6f",$fa6))->cmp()); + +Context()->{format}{number} = "%g"; + +# EXTRA LINES OF CODE FOR OTHER PURPOSES: +# Context()->{format}{number} = "%18.15f"; +# ANS(Real(sprintf("%.3f",$gd2->value))->cmp(tolType => 'absolute',tolerance => .01)); +# ANS(Real(sprintf("%.8f",$gd6))->cmp(tolType => 'absolute',tolerance => 1e-7)); +# ANS($fb1->cmp(tolType => 'absolute',tolerance => .5)); +# ANS($gd6->cmp()); + +BEGIN_PGML + +[``\lim_{x\rightarrow[$a]}f(x)=``] [_]{$fa} + +[``f([$a])=``] [_]{$fa} + +Are these the same? [_]{$yes} + +END_PGML + +Section::End(); + +Section::Begin("Continuity"); + +# DESMOS NEXT TO TABLE OF VALUES (hopefully): +# $column1 = $desmos_div ."$PAR $PAR $PAR $PAR ". $desmos_div2; + +BEGIN_PGML + +Since [``\lim_{x\rightarrow[$a]}f(x)=f([$a])``], we say [`f`] is *continuous* at [`[$a]`] (or "continuous at [`x=[$a]`]"). + +[@ openDiv({ "class" => "importantFormula" }) @]* +Continuity: + +If [``\lim_{x\rightarrow c}f(x)=f(c)``], then [`f`] is *continuous* at [`x=c`]. +[@ closeDiv() @]* + +Keep this in mind for the future. [%Retype the word "continuous" here: [_]{$contin}%] +END_PGML + +Section::End(); + +Section::Begin("x approaching 0"); + +BEGIN_PGML + +Let's look at the same function, but as [`x`] approaches [`0`]. + +[@ +DataTable( +[ + ['\(x\)','\(f(x)\)'], + ['\(-2\)',ans_rule(10)], + ['\(-\frac23\)',ans_rule(10)], + ['\(-\frac25\)',ans_rule(10)], + ['\(2\)',ans_rule(10)], + ['\(\frac23\)',ans_rule(10)], + ['\(\frac25\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($fb1->cmp()); + +ANS($fb2->cmp()); + +ANS($fb3->cmp()); + +ANS($fb4->cmp()); + +ANS($fb5->cmp()); + +ANS($fb6->cmp()); + +BEGIN_PGML + +What number does [`f(x)`] seem to be approaching? [_]{0} + +END_PGML +Section::End(); + +Section::Begin("Trying other numbers"); + +BEGIN_PGML + +Seems like the limit might be 0. But just in case, let's try different numbers: + +[@ +DataTable( +[ + ['\(x\)','\(f(x)\)'], + ['\(-1\)',ans_rule(10)], + ['\(-\frac13\)',ans_rule(10)], + ['\(-\frac15\)',ans_rule(10)], + ['\(1\)',ans_rule(10)], + ['\(\frac13\)',ans_rule(10)], + ['\(\frac15\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($fc1->cmp()); + +ANS($fc2->cmp()); + +ANS($fc3->cmp()); + +ANS($fc4->cmp()); + +ANS($fc5->cmp()); + +ANS($fc6->cmp()); + +BEGIN_PGML + +What do these answers seem to be approaching? [_]{-1} + +END_PGML + +Section::End(); + +Section::Begin("More numbers!"); + +BEGIN_PGML + +It seems like [`f(x)`] is approaching two different numbers! + +Let's try a few more values of [`x`]: + +[@ +DataTable( +[ + ['\(x\)','\(f(x)\)'], + ['\(-\frac12\)',ans_rule(10)], + ['\(-\frac14\)',ans_rule(10)], + ['\(-\frac16\)',ans_rule(10)], + ['\(\frac12\)',ans_rule(10)], + ['\(\frac14\)',ans_rule(10)], + ['\(\frac16\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($fd1->cmp()); + +ANS($fd2->cmp()); + +ANS($fd3->cmp()); + +ANS($fd4->cmp()); + +ANS($fd5->cmp()); + +ANS($fd6->cmp()); + +BEGIN_PGML + +What are these approaching? [_]{1} + +END_PGML +Section::End(); + +Section::Begin("Another function"); +BEGIN_PGML + +This function is very strange! It seems to be approaching a bunch of different numbers all at once! + +If we use an expression like [``\lim_{x\rightarrow c}f(x)``], we want it to refer to _one_ number, not a bunch of numbers at the same time. So if the function approaches more than one number, we say the limit *does not exist*. + +Let's look at one more function: + +[``g(x)=\frac{[$p]x}{|x|}``] + +(Recall that [`|x|`] is [`x`] if [`x\geq0`], and it's [`-x`] if [`x<0`].) + +This time, you can calculate [`g(x)`] yourself for these values of [`x`]: + +[@ +DataTable( +[ + ['\(x\)','\(g(x)\)'], + ['\(-1\)',ans_rule(10)], + ['\(-.2\)',ans_rule(10)], + ['\(-.05\)',ans_rule(10)], + ['\(1\)',ans_rule(10)], + ['\(.2\)',ans_rule(10)], + ['\(.05\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($gp1->cmp()); + +ANS($gp2->cmp()); + +ANS($gp3->cmp()); + +ANS($gp4->cmp()); + +ANS($gp5->cmp()); + +ANS($gp6->cmp()); + +#Context()->{format}{number} = "%18.15f"; +#ANS(Real(sprintf("%.3f",$gd2->value))->cmp(tolType => 'absolute',tolerance => .01)); +#ANS(Real(sprintf("%.8f",$gd6))->cmp(tolType => 'absolute',tolerance => 1e-7)); + +Section::End(); + +Section::Begin("Limit existence?"); + +BEGIN_PGML + +Based on the table we just filled in, do you think [``\lim_{x\rightarrow0}g(x)``] exists? [_]{$no} + +END_PGML + +Section::End(); + +Section::Begin("Passcode"); + +BEGIN_PGML + +In this problem, we saw two nonexistent limits! In both cases, they did not exist because the function approached _more than one number_. But you may notice some differences between them. We will explore that in the next problem. + +[% The passcode for the next problem is [`[$passcode2]`]. Enter it here: [_]{$passcode2} %] + +END_PGML + +Section::End(); + + Scaffold::End(); + +Context()->normalStrings; + +#ANS( num_cmp( $answ, tol=>0.001, tolType=>"absolute" )); + +#ANS($dq->cmp); + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + graphpaper: false, + settingsMenu: true, + expressionsTopbar: true + }); + + my_calculator.setExpressions([ + { id: 'function', latex: 'f(x)=\\cos(\\pi/x)'}, + ]); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +ENDDOCUMENT(); diff --git a/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_3_of_4.pg b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_3_of_4.pg new file mode 100644 index 0000000000..f455c68705 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_3_of_4.pg @@ -0,0 +1,604 @@ +# DESCRIPTION +## DBsubject('Calculus') +## DBchapter('Limits') +## DBsection('Investigating Limits') +## KEYWORDS('Limits', 'one-sided', 'infinity') +## TitleText1('Calculus: Early Transcendentals') +## EditionText1('4') +## AuthorText1('Rogawski') +## Section1('2.2') +## Institution('UW Eau Claire') +## Copied and modified by Warren Shull (UWEC) August 8, 2023 + +DOCUMENT(); +loadMacros("PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "scaffold.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl", + "freemanMacros.pl", + "AnswerFormatHelp.pl", + "Parser.pl", "desmos.pl",); + +loadMacros("niceTables.pl"); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + #"PGcourse.pl", # Customization file for the course + #"scaffold.pl", + "unionTables.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +loadMacros( + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", # <---- MAKES BOXES PURPLE +); + +Context("Numeric"); + +$yes = PopUp( + ["Choose one", "yes","no"], + "yes"); + +$no = PopUp( + ["Choose one", "yes","no"], + "no"); + +$dne = String("DNE"); + +$width = 200; +$height = 350; + +desmos_enable_construct_new(); +$unique_div_id = "evaluating_f"; +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id2 = "evaluating_h"; +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +#$contin = String('continuous'); + +$p1=-1; +$p2=-.2; +$p3=-.05; +$p4=1; +$p5=.2; +$p6=.05; + +$a=random(2,6); #left piece $a*x +$b=random(-5,-1); #left to middle +#middle piece x^2 +$c=random(1,5); #middle to right +$d=random(1,5); #right piece $d-x +while($d-$c==$c*$c){$d=random(1,5);} + +$f1=Formula("$a*x")->reduce; #left +$f2=Formula("x^2")->reduce; #middle +$f3=Formula("$d-x")->reduce; #right + +$b1=$b-.1; +$b2=$b-.01; +$b3=$b-.001; + +$fb1 = $f1->eval(x=>$b1); +$fb2 = $f1->eval(x=>$b2); +$fb3 = $f1->eval(x=>$b3); + +$b4=$b+.1; +$b5=$b+.01; +$b6=$b+.001; + +$fb4 = $f2->eval(x=>$b4); +$fb5 = $f2->eval(x=>$b5); +$fb6 = $f2->eval(x=>$b6); + +$fb_left = $f1->eval(x=>$b); +$fb_right = $f2->eval(x=>$b); + +$c1=$c-.1; +$c2=$c-.01; +$c3=$c-.001; + +$fc1 = $f2->eval(x=>$c1); +$fc2 = $f2->eval(x=>$c2); +$fc3 = $f2->eval(x=>$c3); + +$c4=$c+.1; +$c5=$c+.01; +$c6=$c+.001; + +$fc4 = $f3->eval(x=>$c4); +$fc5 = $f3->eval(x=>$c5); +$fc6 = $f3->eval(x=>$c6); + +$fc_left = $f2->eval(x=>$c); +$fc_right = $f3->eval(x=>$c); + +SRAND($psvn); + +$i=random(-7,-2); #left-to-middle +$j=random(1,5); #vertical asymptote on the right +$j_less=$j-2; #middle-to-right + +$h1 = Formula("2^(x-$i)")->reduce; #left piece +$h3 = Formula("(($j+2)*x-($j*$j+2*$j-2))/(x-$j)")->reduce; #right piece; x=j asymptote + +$hi_left=$h1->eval(x=>$i); +$hj_right=$h3->eval(x=>$j-2); #j-2 not j; should equal j+1 + +Context("Fraction"); + +$h_slope = Fraction("$hj_right/($j-2-$i)")->reduce; + +Context("Numeric"); + +$h2_partial = Formula("(x-$i)")->reduce; #just the x-i part without the slope + +$h2=Formula("$h_slope*$h2_partial"); + +$hi_right=$h2->eval(x=>$i); +$hj_left=$h2->eval(x=>$j-2); #j-2 not j + +$k=random(-10,10); +while($k==$hj_left){$k=random(-10,10);} + +$i1=$i-.02; +$i2=$i-.005; +$i3=$i-.001; + +$hi1=$h1->eval(x=>$i1); +$hi2=$h1->eval(x=>$i2); +$hi3=$h1->eval(x=>$i3); + +$i4=$i+.1; +$i5=$i+.01; +$i6=$i+.001; + +$hi4=$h2->eval(x=>$i4); +$hi5=$h2->eval(x=>$i5); +$hi6=$h2->eval(x=>$i6); + +$j1=$j-2-.1; +$j2=$j-2-.01; +$j3=$j-2-.001; + +$hj1=$h2->eval(x=>$j1); +$hj2=$h2->eval(x=>$j2); +$hj3=$h2->eval(x=>$j3); + +$j4=$j-2+.1; +$j5=$j-2+.01; +$j6=$j-2+.001; + +$hj4=$h3->eval(x=>$j4); +$hj5=$h3->eval(x=>$j5); +$hj6=$h3->eval(x=>$j6); + +## THIS IS PROBLEM 3 OF A 4 PROBLEM SERIES INTRODUCING LIMITS ALGEBRAICALLY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); + +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); +#$passcode3 = random(1000,9999); + +## END PASSCODE CODE + +$p=non_zero_random(-5,5); +$g=Formula("$p*x/|x|"); + +$gp1 = $g->eval(x=>$p1); +$gp2 = $g->eval(x=>$p2); +$gp3 = $g->eval(x=>$p3); +$gp4 = $g->eval(x=>$p4); +$gp5 = $g->eval(x=>$p5); +$gp6 = $g->eval(x=>$p6); + +$cts_neither = PopUp( + ["Choose one", 'x='.$i,"x=".$j_less,"both","neither"], + "neither"); + +TEXT(beginproblem()); +Context()->texStrings; + +Scaffold::Begin(can_open => "when_previous_correct", is_open => "first_incorrect"); +########################################### +Section::Begin("Passcode"); + +BEGIN_PGML + +In the previous problem, we looked at + +[```g(x)=[$g]```] + +[% Enter the passcode from the previous problem: [_]{$passcode2} %] + +END_PGML + +Section::End(); + +Section::Begin("Previous table"); + +BEGIN_PGML + +Here is the table we made for [``\lim_{x\rightarrow0}g(x)``]. I've added a few rows; go ahead and fill them in! + +[@ +DataTable( +[ + ['\(x\)','\(g(x)\)'], + ['\(-1\)','\('.$gp1.'\)'], + ['\(-.2\)','\('.$gp2.'\)'], + ['\(-.05\)','\('.$gp3.'\)'], + ['\(-.02\)',ans_rule(10)], + ['\(-.005\)',ans_rule(10)], + ['\(1\)','\('.$gp4.'\)'], + ['\(.2\)','\('.$gp5.'\)'], + ['\(.05\)','\('.$gp6.'\)'], + ['\(.02\)',ans_rule(10)], + ['\(.005\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); +@]* + +END_PGML + +ANS($gp2->cmp()); + +ANS($gp3->cmp()); + +ANS($gp5->cmp()); + +ANS($gp6->cmp()); + +BEGIN_PGML + +As we established in the previous problem, [``\lim_{x\rightarrow0}g(x)``] does not exist. However, if you look *only* at [`x`]-values *less than* 0, [`g(x)`] is approaching what number? [_]{$gp1} + +Similarly, for [`x`]-values *greater than* 0, what number is [`g(x)`] approaching? [_]{$gp4} + +END_PGML + +Section::End(); + +Section::Begin("One-sided limits"); + +BEGIN_PGML + +We call these numbers *one-sided limits*! For [`x`]-values less than any number [`c`], we write + +[```\lim_{x\rightarrow c^-}g(x)```] + +and for [`x`]-values greater than [`c`], we write + +[```\lim_{x\rightarrow c^+}g(x)```] + +So, in this example, + +[``\lim_{x\rightarrow0^-}g(x)=``][_]{$gp1} + +and + +[``\lim_{x\rightarrow0^+}g(x)=``] [_]{$gp4} + +One-sided limits will be especially common in _piecewise functions_. We will look at one next! If you would like a refresher on what piecewise functions are, the next scaffold bar (which should appear green instead of yellow) has a video about it from Prof. Shull. (Feel free to skip if you remember piecewise functions well.) + +END_PGML + +Section::End(); + +Section::Begin("Piecewise function review video (20:45)"); + +BEGIN_PGML + +[@ +kalturaShull("1_4ver89yh") +@]* + +END_PGML +Section::End(); + + +Section::Begin("Piecewise function limits"); + +BEGIN_PGML + +Let's find some limits for this piecewise function! + +You can use the window on the right as a calculator, but you need to type the function yourself! Don't try to type the whole piecewise function; just type the piece you need for each value of [`x`]. + +[```f(x)= +\begin{cases} +[$a]x&x<[$b]\\ +x^2&[$b]\leq x\leq[$c]\\ +[$d]-x&x>[$c]\\ +\end{cases}```] + +END_PGML + +$table=DataTable( +[ + ['\(x\)','\(f(x)\)'], + ['\('.$b1.'\)',ans_rule(10)], + ['\('.$b2.'\)',ans_rule(10)], + ['\('.$b3.'\)',ans_rule(10)], + ['\('.$b4.'\)',ans_rule(10)], + ['\('.$b5.'\)',ans_rule(10)], + ['\('.$b6.'\)',ans_rule(10)], + ['\('.$c1.'\)',ans_rule(10)], + ['\('.$c2.'\)',ans_rule(10)], + ['\('.$c3.'\)',ans_rule(10)], + ['\('.$c4.'\)',ans_rule(10)], + ['\('.$c5.'\)',ans_rule(10)], + ['\('.$c6.'\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div)); + +#Context()->{format}{number} = "%.2f"; +#ANS(Real(sprintf("%.2f",$fb1))->cmp()); +ANS($fb1->cmp()); + +#Context()->{format}{number} = "%.4f"; +#ANS(Real(sprintf("%.4f",$fb2))->cmp()); +ANS($fb2->cmp()); + +#Context()->{format}{number} = "%.6f"; +#ANS(Real(sprintf("%.6f",$fb3))->cmp()); +ANS($fb3->cmp()); + +#Context()->{format}{number} = "%.2f"; +#ANS(Real(sprintf("%.2f",$fb4))->cmp()); +ANS($fb4->cmp()); + +#Context()->{format}{number} = "%.4f"; +#ANS(Real(sprintf("%.4f",$fb5))->cmp()); +ANS($fb5->cmp()); + +#Context()->{format}{number} = "%.6f"; +#ANS(Real(sprintf("%.6f",$fb6))->cmp()); +ANS($fb6->cmp()); + +#Context()->{format}{number} = "%g"; + +ANS($fc1->cmp()); +ANS($fc2->cmp()); +ANS($fc3->cmp()); +ANS($fc4->cmp()); +ANS($fc5->cmp()); +ANS($fc6->cmp()); + +BEGIN_TEXT +$PAR $PAR $PAR +END_TEXT + +BEGIN_PGML + +Use your answers in the table to evaluate these four one-sided limits, then evaluate [`f`] at the two numbers listed. + +[``\lim_{x\rightarrow[$b]^-}f(x)=``] [_]{$fb_left} + +[``\lim_{x\rightarrow[$b]^+}f(x)=``] [_]{$fb_right} + +[``\lim_{x\rightarrow[$c]^-}f(x)=``] [_]{$fc_left} + +[``\lim_{x\rightarrow[$c]^+}f(x)=``] [_]{$fc_right} + +[``f([$b])=``] [_]{$fb_right} + +[``f([$c])=``] [_]{$fc_left} + +END_PGML + +Section::End(); + +Section::Begin("Another piecewise function"); + +BEGIN_PGML + +Here's another piecewise function: + +[```h(x)= +\begin{cases} +[$h1]&x\leq[$i]\\ +[$h_slope]([$h2_partial])&[$i][$j-2]\\ +\end{cases}```] + +Fill in the table, rounding as indicated. + +END_PGML + +$table=DataTable( +[ + ['\(x\)',"rounding",'\(h(x)\)'], + ['\('.$i1.'\)',2,ans_rule(10)], + ['\('.$i2.'\)',3,ans_rule(10)], + ['\('.$i3.'\)',4,ans_rule(10)], + ['\('.$i4.'\)',3,ans_rule(10)], + ['\('.$i5.'\)',4,ans_rule(10)], + ['\('.$i6.'\)',5,ans_rule(10)], + ['\('.$j1.'\)',2,ans_rule(10)], + ['\('.$j2.'\)',3,ans_rule(10)], + ['\('.$j3.'\)',4,ans_rule(10)], + ['\('.$j4.'\)',2,ans_rule(10)], + ['\('.$j5.'\)',3,ans_rule(10)], + ['\('.$j6.'\)',4,ans_rule(10)], +], +align => '|l | c|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div2)); + +Context()->{format}{number} = "%.2f"; +ANS(Real(sprintf("%.2f",$hi1))->cmp()); + +Context()->{format}{number} = "%.3f"; +ANS(Real(sprintf("%.3f",$hi2))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hi3))->cmp()); + +Context()->{format}{number} = "%.3f"; +ANS(Real(sprintf("%.3f",$hi4))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hi5))->cmp()); + +Context()->{format}{number} = "%.5f"; +ANS(Real(sprintf("%.5f",$hi6))->cmp()); + +Context()->{format}{number} = "%.2f"; +ANS(Real(sprintf("%.2f",$hj1))->cmp()); + +Context()->{format}{number} = "%.3f"; +ANS(Real(sprintf("%.3f",$hj2))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hj3))->cmp()); + +Context()->{format}{number} = "%.2f"; +ANS(Real(sprintf("%.2f",$hj4))->cmp()); + +Context()->{format}{number} = "%.3f"; +ANS(Real(sprintf("%.3f",$hj5))->cmp()); + +Context()->{format}{number} = "%.4f"; +ANS(Real(sprintf("%.4f",$hj6))->cmp()); + +Context()->{format}{number} = "%g"; + +BEGIN_PGML + +Based on the table, answer the following questions (write "DNE" if something does not exist): + +[``\lim_{x\rightarrow[$i]^-}h(x)=``] [_]{$hi_left} + +[``\lim_{x\rightarrow[$i]^+}h(x)=``] [_]{$hi_right} + +[``\lim_{x\rightarrow[$i]}h(x)=``] [_]{$dne} + +[``\lim_{x\rightarrow[$j-2]^-}h(x)=``] [_]{$hj_left} + +[``\lim_{x\rightarrow[$j-2]^+}h(x)=``] [_]{$hj_right} + +[``\lim_{x\rightarrow[$j-2]}h(x)=``] [_]{$hj_left} + +[`h([$i])=`] [_]{$hi_left} + +[`h([$j-2])=`] [_]{$k} + +END_PGML + +Section::End(); + +Section::Begin("Continuity & passcode"); + +BEGIN_PGML + +As you just saw, one of the two-sided limits in the previous part _did_ exist, and one did not. But what about continuity? Based on what we know so far, [`h(x)`] is continuous at [_]{$cts_neither}. + +[% The passcode for the next question is [`[$passcode3]`]. Enter it here: [_]{$passcode3} %] + +END_PGML + +Section::End(); + +# EXTRA LINES OF CODE FOR OTHER PURPOSES: +# Context()->{format}{number} = "%18.15f"; +# ANS(Real(sprintf("%.3f",$gd2->value))->cmp(tolType => 'absolute',tolerance => .01)); +# ANS(Real(sprintf("%.8f",$gd6))->cmp(tolType => 'absolute',tolerance => 1e-7)); +# ANS($fb1->cmp(tolType => 'absolute',tolerance => .5)); +# ANS($gd6->cmp()); + +# SIDE BY SIDE CODE: +# $column1 = $desmos_div ."$PAR $PAR $PAR $PAR ". $desmos_div2; + + Scaffold::End(); + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id2"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +Context()->normalStrings; + +ENDDOCUMENT(); + diff --git a/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_4_of_4.pg b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_4_of_4.pg new file mode 100644 index 0000000000..e4f34fbb97 --- /dev/null +++ b/Contrib/Wisconsin/EauClaire/calculus/limits_with_formulas_problem_4_of_4.pg @@ -0,0 +1,573 @@ +# DESCRIPTION +## DBsubject('Calculus') +## DBchapter('Limits') +## DBsection('Investigating Limits') +## KEYWORDS('Limits', 'one-sided', 'infinity') +## TitleText1('Calculus: Early Transcendentals') +## EditionText1('4') +## AuthorText1('Rogawski') +## Section1('2.2') +## Institution('UW Eau Claire') +## Copied and modified by Warren Shull (UWEC) August 8, 2023 + +DOCUMENT(); +loadMacros("PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "scaffold.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl", + "freemanMacros.pl", + "AnswerFormatHelp.pl", + "Parser.pl", "desmos.pl",); + +loadMacros("niceTables.pl"); + +loadMacros( + "PGstandard.pl", # Standard macros for PG language + "MathObjects.pl", + "PGML.pl", + #"source.pl", # allows code to be displayed on certain sites. + #"PGcourse.pl", # Customization file for the course + #"scaffold.pl", + "unionTables.pl", + "parserPopUp.pl", # <--------------------------------------NEEDED FOR DROPDOWN MENUS + "PGtikz.pl", +); + +loadMacros( + "contextFraction.pl", + "parserMultiAnswer.pl", +"answerHints.pl", + "PGcourse.pl", # Customization file for the course + "customCSS.pl", # <---- MAKES BOXES PURPLE +); + +Context("Numeric"); + +$Inf = Infinity; +$NInf = -(Infinity); + +$yes = PopUp( + ["Choose one", "yes","no"], + "yes"); + +$no = PopUp( + ["Choose one", "yes","no"], + "no"); + +$negative_infinity = PopUp( + ["Choose one", "Approaches more than one number", "Goes up forever","Goes down forever", "Jumps around unpredictably", "Stops existing"], + "Goes down forever"); + +$positive_infinity = PopUp( + ["Choose one", "Approaches more than one number", "Goes up forever","Goes down forever", "Jumps around unpredictably", "Stops existing"], + "Goes up forever"); + +$dne = String("DNE"); + +#$contin = String('continuous'); + +#a,b,c,d available + +$width = 200; +$height = 200; + +desmos_enable_construct_new(); + +$unique_div_id = "evaluating_h_5_left"; +$desmos_div = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id2 = "evaluating_h_5_right"; +$desmos_div2 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id3 = "evaluating_h_inf"; +$desmos_div3 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$unique_div_id4 = "evaluating_h_neg_inf"; +$desmos_div4 = MODES( + HTML=>qq(
), + TeX=>'Interactive graph best viewed online' +); + +$p1=-1; +$p2=-.2; +$p3=-.05; +$p4=1; +$p5=.2; +$p6=.05; + +SRAND($psvn); + +$i=random(-7,-2); #left-to-middle +$j=random(1,5); #vertical asymptote on the right +$j_less=$j-2; #middle-to-right + +$h1 = Formula("2^(x-$i)")->reduce; #left piece +$h3 = Formula("(($j+2)*x-($j*$j+2*$j-2))/(x-$j)")->reduce; #right piece; x=j asymptote + +$hi_left=$h1->eval(x=>$i); +$hj_right=$h3->eval(x=>$j-2); #j-2 not j; should equal j+1 + +Context("Fraction"); + +$h_slope = Fraction("$hj_right/($j-2-$i)")->reduce; + +Context("Numeric"); + +$h2_partial = Formula("(x-$i)")->reduce; #just the x-i part without the slope + +$h2=Formula("$h_slope*$h2_partial"); + +$hi_right=$h2->eval(x=>$i); +$hj_left=$h2->eval(x=>$j-2); #j-2 not j + +$k=random(-10,10); +while($k==$hj_left){$k=random(-10,10);} + +$i1=$i-.02; +$i2=$i-.005; +$i3=$i-.001; + +$hi1=$h1->eval(x=>$i1); +$hi2=$h1->eval(x=>$i2); +$hi3=$h1->eval(x=>$i3); + +$i4=$i+.1; +$i5=$i+.01; +$i6=$i+.001; + +$hi4=$h2->eval(x=>$i4); +$hi5=$h2->eval(x=>$i5); +$hi6=$h2->eval(x=>$i6); + +$j1=$j-2-.1; +$j2=$j-2-.01; +$j3=$j-2-.001; + +$hj1=$h2->eval(x=>$j1); +$hj2=$h2->eval(x=>$j2); +$hj3=$h2->eval(x=>$j3); + +$j4=$j-2+.1; +$j5=$j-2+.01; +$j6=$j-2+.001; + +$hj4=$h3->eval(x=>$j4); +$hj5=$h3->eval(x=>$j5); +$hj6=$h3->eval(x=>$j6); + + +## THIS IS PROBLEM 4 OF A 4 PROBLEM SERIES INTRODUCING LIMITS ALGEBRAICALLY. IF YOU USE THEM TOGETHER, YOU CAN USE PASSCODES TO ALLOW YOU TO REQUIRE THE PROBLEMS BE DONE IN ORDER. BELOW IS SOME OF THE CODE YOU'LL NEED: + +#SRAND($psvn); + +#$passcode1 = random(1000,9999); +#$passcode2 = random(1000,9999); +#$passcode3 = random(1000,9999); + +## END PASSCODE CODE + + +$p=non_zero_random(-5,5); +$g=Formula("$p*x/|x|"); + +$gp1 = $g->eval(x=>$p1); +$gp2 = $g->eval(x=>$p2); +$gp3 = $g->eval(x=>$p3); +$gp4 = $g->eval(x=>$p4); +$gp5 = $g->eval(x=>$p5); +$gp6 = $g->eval(x=>$p6); + +$cts_neither = PopUp( + ["Choose one", 'x='.$i,"x=".$j_less,"both","neither"], + "neither"); + +$ja0=$j-.2; +$ja1=$j-.05; +$ja2=$j-.01; +$ja3=$j-.002; +$ja4=$j-.0005; + +$hja0=$h3->eval(x=>$ja0); +$hja1=$h3->eval(x=>$ja1); +$hja2=$h3->eval(x=>$ja2); +$hja3=$h3->eval(x=>$ja3); +$hja4=$h3->eval(x=>$ja4); + +$ja5=$j+.2; +$ja6=$j+.05; +$ja7=$j+.01; +$ja8=$j+.002; +$ja9=$j+.0005; + +$hja5=$h3->eval(x=>$ja5); +$hja6=$h3->eval(x=>$ja6); +$hja7=$h3->eval(x=>$ja7); +$hja8=$h3->eval(x=>$ja8); +$hja9=$h3->eval(x=>$ja9); + +$jb1=$j+100; +$jb2=$j+1000; +$jb3=$j+10000; + +$hjb1=$h3->eval(x=>$jb1); +$hjb2=$h3->eval(x=>$jb2); +$hjb3=$h3->eval(x=>$jb3); + +$jb4=$i-3; +$jb5=$i-9; +$jb6=$i-14; + +$hjb4=$h1->eval(x=>$jb4); +$hjb5=$h1->eval(x=>$jb5); +$hjb6=$h1->eval(x=>$jb6); + +TEXT(beginproblem()); +Context()->texStrings; + +Scaffold::Begin(can_open => "when_previous_correct", is_open => "first_incorrect"); +########################################### +Section::Begin("Passcode"); + +BEGIN_PGML + +In the previous problem, we looked at + +[```h(x)= +\begin{cases} +[$h1]&x\leq[$i]\\ +[$h_slope]([$h2_partial])&[$i][$j-2]\\ +\end{cases}```] + +[% Enter the passcode from the previous problem: [_]{$passcode3} %] + +END_PGML + +Section::End(); + +Section::Begin("One more limit..."); + +BEGIN_PGML + +Let's see what happens when [`x`] is close to [`[$j]`]. We will start with [`x`] values slightly _less_ than [`[$j]`]: + +END_PGML + +$table=DataTable( +[ + ['\(x\)','\(h(x)\)'], + ['\('.$ja0.'\)',ans_rule(10)], + ['\('.$ja1.'\)',ans_rule(10)], + ['\('.$ja2.'\)',ans_rule(10)], + ['\('.$ja3.'\)',ans_rule(10)], + ['\('.$ja4.'\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table,$desmos_div)); + +#Context()->{format}{number} = "%.2f"; +#ANS(Real(sprintf("%.2f",$hja0))->cmp()); +ANS($hja0->cmp()); +ANS($hja1->cmp()); +ANS($hja2->cmp()); +ANS($hja3->cmp()); +ANS($hja4->cmp()); + +#Context()->{format}{number} = "%g"; + +BEGIN_PGML + +Is there any number these [`y`]-values are approaching? [_]{$no} + +END_PGML +Section::End(); + +Section::Begin("Describing the y-values"); + +BEGIN_PGML + +When [`x`] is slightly less than [`[$j]`] and getting closer to it, how would you describe what the output [`h(x)`] does? [_]{$negative_infinity} + +END_PGML + +Section::End(); + +Section::Begin("Other side"); + +$table2=DataTable( +[ + ['\(x\)','\(h(x)\)'], + ['\('.$ja5.'\)',ans_rule(10)], + ['\('.$ja6.'\)',ans_rule(10)], + ['\('.$ja7.'\)',ans_rule(10)], + ['\('.$ja8.'\)',ans_rule(10)], + ['\('.$ja9.'\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table2,$desmos_div2)); + +ANS($hja5->cmp()); +ANS($hja6->cmp()); +ANS($hja7->cmp()); +ANS($hja8->cmp()); +ANS($hja9->cmp()); + +BEGIN_PGML + +When [`x`] is slightly _more_ than [`[$j]`] and getting closer to it, how would you describe what the output [`h(x)`] does? [_]{$positive_infinity} + +END_PGML + +Section::End(); + +Section::Begin("Infinite Limits!"); + +BEGIN_PGML + +When [`h(x)`] goes up or down forever, we often refer to that limit as "equaling" either [`\infty`] or [`-\infty`] (you can type [`\infty`] with "inf"). In this case: + +[``\lim_{x\rightarrow[$j]^-}h(x)=``] [_]{$NInf} + +[``\lim_{x\rightarrow[$j]^+}h(x)=``] [_]{$Inf} + +We call both of these *infinite limits*. Keep in mind that [`\infty`] and [`-\infty`] are _not_ numbers, so in a sense we can still say these limits "do not exist." However, sometimes we want to specify if a function goes up or down forever, and the limit notation along with the [`\infty`] symbol is a great way to do it! + +If you are ever unsure whether a problem wants you to answer "DNE" for an infinite limit, or to answer [`\infty`] or [`-\infty`] where they would fit, either try it both ways or ask your instructor. (For this problem set, use [`\infty`] and [`-\infty`].) + +Are your last two answers the same? [_]{$no} + +So what is [``\lim_{x\rightarrow5}h(x)``]? [_]{$dne} + +END_PGML + +Section::End(); + +Section::Begin('What about when \(x\) goes way up...?'); + +BEGIN_PGML + +We just saw an example of _output_ numbers approaching [`\infty`] or [`-\infty`]. But what about _input_ numbers? + +END_PGML + +$table3=DataTable( +[ + ['\(x\)','\(h(x)\)'], + ['\('.$jb1.'\)',ans_rule(10)], + ['\('.$jb2.'\)',ans_rule(10)], + ['\('.$jb3.'\)',ans_rule(10)], +], +align => '|l | l|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table3,$desmos_div3)); + +#Context()->{format}{number} = "%.2f"; +#ANS(Real(sprintf("%.2f",$hja0))->cmp()); +ANS($hjb1->cmp()); +ANS($hjb2->cmp()); +ANS($hjb3->cmp()); + +#Context()->{format}{number} = "%g"; + +BEGIN_PGML + +As [`x`] keeps going up, what is [`h(x)`] getting close to? [_]{2+$j} + +We call this number [``\lim_{x\rightarrow\infty}h(x)``]. + +END_PGML + +Section::End(); + +Section::Begin('...or down?'); + +BEGIN_PGML + +Let's see what happens when [`x`] keeps going down. +END_PGML + +$table4=DataTable( +[ + ['\(x\)',"rounding",'\(h(x)\)'], + ['\('.$jb4.'\)','',ans_rule(10)], + ['\('.$jb5.'\)',5,ans_rule(10)], + ['\('.$jb6.'\)',6,ans_rule(10)], +], +align => '|l | c|l|', +midrules => 1, +tablecss => " border-spacing:0px 0px; border-radius: 5px; border-collapse:separate;" +); + +TEXT(ColumnTable($table4,$desmos_div4)); + +Context()->normalStrings; + +ANS($hjb4->cmp()); + +Context()->{format}{number} = "%.5f"; +ANS(num_cmp($hjb5,tol=>5e-6, tolType=>"absolute")); + +Context()->{format}{number} = "%.6f"; +ANS(num_cmp($hjb6,tol=>5e-7, tolType=>"absolute")); + +Context()->{format}{number} = "%g"; + +Context()->texStrings; + +BEGIN_PGML + +[``\lim_{x\rightarrow-\infty}=``] [_]{0} + +(It might not seem like these [`x`] values are that far down, but this number is approached _really_ fast.) + +END_PGML + +Section::End(); + Scaffold::End(); + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id2"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id3"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +TEXT( MODES(TeX=>'', HTML=>< + + var arstarst = document.getElementById("$unique_div_id4"); + + var my_calculator = Desmos.Calculator(arstarst, { + keypad: false, + //expressions: false, + expressions: true, + settingsMenu: true, + graphpaper: false, + expressionsTopbar: true + }); + + my_calculator.setMathBounds({ + left: -101, + right: -99, + bottom: -1, + top: 1 + }); + + my_calculator.updateSettings({ fontSize: Desmos.FontSizes.SMALL, expressions: true }); + + var state = my_calculator.getState(); + +END_SCRIPT + +Context()->normalStrings; + +ENDDOCUMENT(); + +# EXTRA LINES OF CODE FOR OTHER PURPOSES: +# Context()->{format}{number} = "%18.15f"; +# ANS(Real(sprintf("%.3f",$gd2->value))->cmp(tolType => 'absolute',tolerance => .01)); +# ANS(Real(sprintf("%.8f",$gd6))->cmp(tolType => 'absolute',tolerance => 1e-7)); +# ANS($fb1->cmp(tolType => 'absolute',tolerance => .5)); +# ANS($gd6->cmp()); + +# SIDE BY SIDE CODE: +# $column1 = $desmos_div ."$PAR $PAR $PAR $PAR ". $desmos_div2; +