Skip to content

Warren Shull WebWork Calculus scaffolds #1166

New issue

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

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

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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();
Loading