##DESCRIPTION
##  Using a GeoGebra applet to provide an interactive accumulation function
##ENDDESCRIPTION


## DBsubject(Calculus - single variable)
## DBchapter(Integrals)
## DBsection(Conceptual understanding of integration)
## Date(11/04/2010)
## Institution(Fort Lewis College)
## Author(Paul Pearson, modified by Mike Gage)
## KEYWORDS('GeoGebra applet example','Accumulation function','Fundamental Theorem of Calculus')

##########################################
#  Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"PGessaymacros.pl",
"unionTables.pl",
"parserNumberWithUnits.pl",
"parserFormulaWithUnits.pl",
"scaffold.pl",
"AnswerFormatHelp.pl",
"PGcourse.pl",
);
 
$showPartialCorrectAnswers = 1;

TEXT(beginproblem());


##########################################
#  Setup

Context("Numeric");

Context()->variables->add(t=>"Real");
Context()->variables->add(dt=>"Real");
Context()->variables->add(v=>"Real");
Context()->variables->add(r=>"Real");
Context()->variables->add(h=>"Real");

HEADER_TEXT('<script type="text/javascript" src="https://cdn.geogebra.org/apps/deployggb.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ww_ggb_applet/lib/ww_ggb_applet.js"></script>');

TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) );
<div id="applet1" class="ww-ggb" style="margin: auto; clear: both"></div>
<br/>
<script language="javascript">
encodedApp = "UEsDBBQACAAIAHq+ZT0AAAAAAAAAAAAAAAAMAAAAZ2VvZ2VicmEueG1s3VfbbuM2EH3ufgWhAkHSrmVRom6NnUWatkCAbTdAtkXQYh9oibLZSKIrUYmcP+iH9Mf6JR2Skiw7l2ZTFL34wZKGw5nhmTOj0exNW+TohlU1F+XcwrZjIVYmIuXlcm41MptE1puTV7MlE0u2qCjKRFVQObc827WUvOEnrz6Z1Stxi2iuVX7g7HZuZTSvmYXqdcVoWq8Ykzty2rQ857TavFv8zBJZbxeMkfNy3YAXWTUgS4r0La/7x6lymNMFyyHGS7nJGUI3NJ9brlnKRCkRqvkdg/No2Wyqw5yxJsl5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iQB3ek9uNRGa9fKP0msjLfQYLVk2730/FVDVrPtFKinCgI3/RBicihpJXW3Rap3YNv3CIHxJ/Ci2FPjle4dE8+OQs/DxAuI64Sui8et5M+BdneAvuTLEmI+hbF0DDl9Ftru/wpt4sXjn3lNTFyQRzDX+k738z8C7g5q3QkeAHS/2uUD1b7/+ng2mvh5dPB26PCCKUJrKTFMOPwO4Kc5kmaqMDatZzDJ+w8xyR2YhB9kkm87ijFx7LuxQ+DjRxPJs4MgivwwdsMwCkgcRR9XtmQnTxso1uxQHj0fYfLvQ3gPN6BsQJwwwnHkRyF2Q5d0yBEceiT2YhyEcQg3jyE3HY/n+ju3+0w/+QNQSwcI3r/ydgkFAADYDwAAUEsBAhQAFAAIAAgAer5lPd6/8nYJBQAA2A8AAAwAAAAAAAAAAAAAAAAAAAAAAGdlb2dlYnJhLnhtbFBLBQYAAAAAAQABADoAAABDBQAAAAA=";
wwGgb = new WwGgbApplet('applet1', {width: 400, height: 400, ggbBase64: encodedApp})
</script>
END_SCRIPT


##########################################
#  Main text

COMMENT('MathObject version.  Uses GeoGebra applet.  Not randomized.');
Context()->texStrings;
BEGIN_TEXT

\(f(t)\) is a function which might represent one of a number of things: speed at a given time, 
height at a given location (along the \(x\) or \(t\) axis), area of a cross section of
of a solid of rotation and so forth.
$PAR
\[F(T) = \int_0^T f(t)\, dt \]

END_TEXT
Context()->normalStrings;

BEGIN_TEXT
If \(h=f(t)\) is the height in inches \(y\) when \(x=t\) then the area of the rectangle 
above the interval \( [t, t+dt]\) is given by \{ans_rule(20)\}\{AnswerFormatHelp("units")\}
$PAR If \(f(t)\) is the velocity \(v\) of an object (in ft/m ) at time \(t\) then the distance traveled during 
the time interval (in minutes) \( [t, t+dt]\) is given by \{ans_rule(20)\}
$PAR If \(f(t)\) is the radius (in inches) \(r\) of a solid of revolution at the point \(x=t\) on the \(x\)-axis 
then the volume of the section over the interval (in inches) \( [t, t+dt]\) is given by \{ans_rule(20)\}
$PAR
In all cases we could summarize by using \(f(t)dt\) for the incremental change in the integral.
END_TEXT
$area_inc = FormulaWithUnits("hdt in^2 ");
$distance_inc = FormulaWithUnits("vdt ft ");
$volume_inc = FormulaWithUnits("pi*r^2 dt in^3 ");
ANS( $area_inc->cmp,
$distance_inc->cmp,
$volume_inc->cmp
);

BEGIN_TEXT
$PAR
In all cases we could summarize by using \(f(t)dt\) for the incremental change in the integral.
$PAR
The other common feature of these examples is that the area of the interval \(t_1,t_3\) is the sum 
of the area over the intervals \(t_1, t_2\) and \(t_2, t_3\); the displacement during the time
interval \(t_1,t_3\) is the sum 
of the displacements over the intervals \(t_1, t_2\) and \(t_2, t_3\); and 
the volume of the solid of revolution
over the interval \(t_1,t_3\) is the sum 
of the volumes over the intervals \(t_1, t_2\) and \(t_2, t_3\).   

$PAR
Area, distance and volumes 
all accumulate -- they are additive quanties.  These are the types of quantities often 
represented by integrals. This means that \(F(T)\) is the total area over the interval 
\([0, T]\); \(F(T)\) is the total displacement during the time interval \([0, T]\); and
\(F(T)\) is the total volume of the solid of revolution over the interval \([0, T]\) along the \(x \) axis.
$PAR
Give two more examples of  additive quantities  and write formulas
(with units) for their incremental change: \{ans_box(5, 80)\}

END_TEXT
ANS(essay_cmp());
BEGIN_TEXT
The rate of change of area with respect to \(t\) as \(t\) goes from \(1\) to \(1+dt\) is \{ans_rule(20)\} $PAR
The rate of change of area as \(t\) goes from \(1.5\) to \(1.5+dt\) is \{ans_rule(20)\} $PAR
The rate of change of displacement as \(t\) goes from \(1\) to \(1+dt\) is \{ans_rule(20)\} $PAR
The rate of change of displacement as \(t\) goes from \(1.5\) to \(1.5+dt\) is \{ans_rule(20)\} $PAR
The rate of change of volume as \(t\) goes from \(1\) to \(1+dt\) is \{ans_rule(20)\} $PAR
The rate of change of volume as \(t\) goes from \(1.5\) to \(1.5+dt\) is \{ans_rule(20)\} $PAR
Why is there no slash / in the units for the first and third answers?
$PAR \{ans_box(4, 80)\}
END_TEXT
$area_derivative1          =NumberWithUnits("2 in");
$area_derivative15         =NumberWithUnits("3 in");
$displacement_derivative1  =NumberWithUnits("2 ft/m");
$displacement_derivative15 =NumberWithUnits("3 ft/m");
$volume_derivative1        =NumberWithUnits("2 in^2");
$volume_derivative15       =NumberWithUnits("3 in^2");
ANS(
$area_derivative1->cmp, $area_derivative15->cmp,
$displacement_derivative1->cmp, $displacement_derivative15->cmp,
$volume_derivative1->cmp, $volume_derivative15->cmp,
essay_cmp()
);

##############################################################
#
#  Answers
#
#

#####################################

#####################################

ENDDOCUMENT();
