## DESCRIPTION

##

## ENDDESCRIPTION

## DBsubject()

## DBchapter()

## DBsection()

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

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

# Needed to support graph generation.

"PGgraphmacros.pl",

"unionTables.pl",

# Used to provide contextual help for how to type answers.

"AnswerFormatHelp.pl",

# Provides greater control over the layout of the problem.

"PGML.pl",

# Used for course-specific initializations.

"PGcourse.pl",

);

TEXT(beginproblem());

# Refreshes the graph image every time the page is loaded, as opposed to

# retrieving a cached version.

$refreshCachedImages = 1;

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

# Setup

Context("Numeric");

# Value initialization.

$a = random(0,3,1);

$f = Compute("sqrt(x)+$a");

# Graph values

$minX = -5;

$minY = -5;

$maxX = 5;

$maxY = 5;

$originX = 0;

$originY = 0;

$gridHoriz = $maxX-$minX;

$gridVert = $maxY-$minY;

$shadedMinX = 1;

$shadedMinY = 0;

$shadedMaxX = 4;

$shadedMaxY = $f->eval(x=>$shadedMaxX);

# Converts $f to LaTeX for display later.

$ftex = $f->TeX;

# Calculates the value for the answer.

$answer = Compute("(2/3) * (4^(3/2) - 1) + 3*$a");

# Initialize graph at the required size.

$gr = init_graph($minX,$minY,$maxX,$maxY,grid=>[$gridHoriz,$gridVert],axes=>[$originX,$originY],size=>[300,300]);

$gr->lb('reset');

# Initializes the x-axis positive and negative number labels.

foreach my $i (1..$maxX-1) {

$gr -> lb(new Label ( $i,-0.25, $i,'black','center','middle'));

}

foreach my $i (1..-$minX-1) {

$gr -> lb(new Label (-$i,-0.25,-$i,'black','center','middle'));

}

# Initializes the y-axis positive and negative number labels.

foreach my $i (1..$maxY-1) {

$gr -> lb(new Label (-0.25,$i,$i,'black','center','middle'));

}

foreach my $i (1..-$minY-1) {

$gr -> lb(new Label (-0.25,-$i,-$i,'black','center','middle'));

}

# Define new graph colors

# Not all of these are used, but they are defined for easier use later.

$gr->new_color("skyblue", 86,180,233); # RGB

$gr->new_color("darkskyblue", 38,79,233);

$gr->new_color("orange", 230,159,0);

$gr->new_color("darkorange", 182, 58, 0);

#

# Choose colors

#

$light = "skyblue";

$dark = "darkskyblue";

# Graph the function and the filled region

add_functions($gr, "$f for x in <0,5> using color:$dark and weight:4");

$gr->moveTo(1,$a+1);

# Draws lines below function line to form boundary of shaded area.

$gr->lineTo($shadedMinX,$shadedMinY,$dark,4);

$gr->lineTo($shadedMaxX,$shadedMinY,$dark,4);

$gr->lineTo($shadedMaxX,$shadedMaxY,$dark,4);

# Fills in area that needs to be shaded.

$gr->fillRegion([$shadedMinX + 0.1, $shadedMinY + 0.1,$light]

);

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

# Main Text

# Defines the problem text.

# Places the following information in column1 (the leftmost) of the layout table.

$column1 = PGML::Format(<<END_PGML);

Use the graph to find the area of the shaded

region under [``f(x) = $ftex``].

Area = [______________][@ AnswerFormatHelp("numbers") @]*

END_PGML

# Places graph image in right-hand column.

$column2 = image( insertGraph($gr),height=>300,width=>300,tex_size=>800 ).

$BR.$BCENTER.

$BR.

`"Graph of \( y = f(x) \)".`

$ECENTER;

TEXT(ColumnTable($column1, $column2, indent => 0, separation => 30, valign => "TOP"));

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

# Answer Evaluation

# Setting this to 1 means that students will receive feedback on whether their

# answers are correct.

$showPartialCorrectAnswers = 1;

ANS($answer->cmp());

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

# Solution

BEGIN_PGML_SOLUTION

Solution explanation goes here.

END_PGML_SOLUTION

COMMENT('Uses PGML. Looks like pi.');

ENDDOCUMENT();