I came across an error that was based on my assumption that when we square a negative variable that the negative is also squared but apparently this is not always the case? The only way I could get the negative to square to a positive was to enclose the variable in parentheses?

The Interactive PGML Lab from our homework does not have this glitch but this homework does. Please see lines 71 and 73 in which the critical number calculation must have the negative variable $b = -8 wrapped within parentheses in order for the square power to square the negative value.

The Code block is below. Thanks for exploring this and letting me know of any misconstrue on my part.

##DESCRIPTION

## Sign Analysis on a 3rd degree Polynomial #11

##KEYWORDS('sign analysis')

## DBsubject('Precalculus')

## DBchapter('Rational equations and functions')

## DBsection('Asymptotes')

## Date('6/7/2017')

## Author('Tim Payer')

# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>

# ENDDESCRIPTION

DOCUMENT();

loadMacros(

"PGstandard.pl",

"PGunion.pl",

"PGnumericalmacros.pl",

"PGstatisticsmacros.pl",

"MathObjects.pl",

"parserPopUp.pl",

"PGML.pl",

"unionTables.pl",

"niceTables.pl",

"PGcourse.pl",

"PGchoicemacros.pl",

"answerHints.pl",

"weightedGrader.pl"

);

install_weighted_grader();

#Text(beginproblem()); #uncomment

#install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 1;

Context("Numeric");

Parser::Number::NoDecimals($context); # we want the exact value of critical numbers

Context()->flags->set(

tolerance => 0.01,

tolType => "absolute",

);

############ Start Problem HW 1.8 #################

#$a = non_zero_random(-7,7);

#$c = non_zero_random(-7,7);

# do { $b = non_zero_random(-13,13); } until ($b**2 > 3*$a*$c); ## forcing all real domain with 2 cp.

$d = non_zero_random(-15,15);

### Testing negative values for a Square within a square root....

$a = Real(2);

$b = Real(-8);

$c = Real(-6);

## $sa = Real(0); ## Horizontal Asymptote

$fp0 = Formula("$a*x**3 + $b*x**2 + $c*x + $d")->reduce; # f(x)

$fp1 = Formula("3*$a*x**2 + 2*$b*x + $c")->reduce; # first derivative

$fp2 = Formula("6*$a*x + 2*$b")->reduce; # second derivative

## f(x) has three critical numbers: A point of inflection at x = 0 will be stradled by

## by two critical points. The concavity will flip based on the sign of $a and $b.

## Accordingly an if-conditional will assign these values as

## critical numbers of $cn1, $cn2, $cn3. The student will have to determine in their sign

## analysis whether they are working with a critical point or a point of inflection.

##

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

$cn1 = Compute("(-$b -sqrt($b**2 - 3*$a*$c))/(3*$a)"); ## And Yet ($b)**2 will work!

$cn2 = Compute("-$b/(3*$a)");

$cn3 = Compute("(-$b + sqrt($b**2 - 3*$a*$c))/(3*$a)"); ## And Yet ($b)**2 will work!

if ( $a > 0 ) {

$f1s = "inc";

$f2s = "dec";

$f3s = "dec";

$f4s = "inc";

$d1s = "+";

$d2s = "-";

$d3s = "-";

$d4s = "+";

$dd1s = "CD";

$dd2s = "CD";

$dd3s = "CU";

$dd4s = "CU";

} else {

$f1s = "dec";

$f2s = "inc";

$f3s = "inc";

$f4s = "dec";

$d1s = "-";

$d2s = "+";

$d3s = "+";

$d4s = "-";

$dd1s = "CU";

$dd2s = "CU";

$dd3s = "CD";

$dd4s = "CD";

}

#### Column Header: Critical number ID

$cpop1 = PopUp(

["?", 'VA', 'cp', 'poi'], 'cp');

$cpop2 = PopUp(

["?", 'VA', 'cp', 'poi'], 'poi');

$cpop3 = PopUp(

["?", 'VA', 'cp', 'poi'], 'cp');

### Row 2, f(x) is incresing or decreasing

$f1 = PopUp(

["?", 'inc', 'dec'], $f1s);

$f2 = PopUp(

["?", 'inc', 'dec'], $f2s);

$f3 = PopUp(

["?", 'inc', 'dec'], $f3s);

$f4 = PopUp(

["?", 'inc', 'dec'], $f4s);

### Row 3, f'(x) is positive or negative

$d1 = PopUp(

["?", '+', '-'], $d1s);

$d2 = PopUp(

["?", '+', '-'], $d2s);

$d3 = PopUp(

["?", '+', '-'], $d3s);

$d4 = PopUp(

["?", '+', '-'], $d4s);

### Row 4, f''(x) is positive with f(x) CU or f''(x) is negative with f(x) CD

$dd1 = PopUp(

["?", 'CU', 'CD'], $dd1s);

$dd2 = PopUp(

["?", 'CU', 'CD'], $dd2s);

$dd3 = PopUp(

["?", 'CU', 'CD'], $dd3s);

$dd4 = PopUp(

["?", 'CU', 'CD'], $dd4s);

#################### Begin Problem...#######################

BEGIN_PGML

*WeBWorK workshop 2017 HW 1.11)

A sign analysis for a third degree polynomial*

*HW 1.11)* Given the rational function [``f(x) = [$fp0]``], perform a sign analysis for the function and the first and second derivatives.

Find all critical points, points of inflection, and asymptotes associated with the function.

*1.11a)* Find the first derivative [`f'(x)`] = [_______]*

*1.11b)* Find the second derivative [`f''(x)`] = [_______]*

[@

DataTable(

[

["$BBOLD 1.11c) $EBOLD Complete the table below for a correct sign analysis display. Use the key at the right to enter the correct values for the function. Use ascending order to display the numerical value for each critical number. Indicate whether a given critical number is a critical point, a vertical asymptote or an

inflection point."," ","VA = Vertical asymptote. $BR cp = Critical point. $BR poi = Point of inflection $BR inc = \\(f(x)\\) is increasing. $BR dec = \\(f(x)\\) is decreasing. $BR + = \\(f(x)\\) is positive. $BR - = \\(f (x)\\) is negative. $BR CU = \\(f^{\\prime \\prime}(x) > 0\\) and \\(f(x)\\) is concave up. $BR CD = \\(f^{\\prime \\prime}(x) < 0\\) and \\(f(x)\\) is concave down." ],

],

caption => " ",

midrules=>1,

align => "|p{3in} p{0.2in}|p{3in}|"

);

@]***

[@

DataTable(

[

["","Before $BR the first $BR critical $BR number:","The first $BR critical $BR number $BR is a: $BR".$cpop1->menu."","Before $BR the 2nd $BR critical $BR number:","The 2nd $BR critical $BR number $BR is a: $BR ".$cpop2->menu."","Before $BR the 3rd $BR critical $BR number:", "The 3rd $BR critical $BR number $BR is a: $BR".$cpop3->menu."", "After $BR the 3rd $BR critical $BR number:" ],

["\\(x =\\)","","".$cn1->ans_rule(2)."","","".$cn2->ans_rule(2)."", "", "".$cn3->ans_rule(2)."","" ],

["\\(f(x)\\)","".$f1->menu."","","".$f2->menu.""," ", "".$f3->menu."", " ","".$f4->menu."" ],

["\\(f^\\prime (x)\\)","".$d1->menu."","","".$d2->menu."","", "".$d3->menu."", "","".$d4->menu.""],

["\\(f^{\\prime \\prime} (x)\\)","".$dd1->menu."","","".$dd2->menu."","", "".$dd3->menu."", "","".$dd4->menu."" ],

],

caption => "Complete the Sign Analysis in the Table Below: ",

midrules=>1,

align => "|p{0.25in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|p{0.5in}|"

);

@]***

END_PGML

#Adapted weighted answers values:

## Asymptotes and derivatives ##

WEIGHTED_ANS( ($fp1)->cmp, 10 );

WEIGHTED_ANS( ($fp2)->cmp, 15 );

## HW 1.10C Sign Analysis Table: ##

###Column Header: Critical number ID

WEIGHTED_ANS( ($cpop1)->cmp, 3 );

WEIGHTED_ANS( ($cpop2)->cmp, 3 );

WEIGHTED_ANS( ($cpop3)->cmp, 3 );

###Row 1:

WEIGHTED_ANS( ($cn1)->cmp, 8 );

WEIGHTED_ANS( ($cn2)->cmp, 8 );

WEIGHTED_ANS( ($cn3)->cmp, 8 );

###Row 2:

WEIGHTED_ANS( ($f1)->cmp, 1 );

WEIGHTED_ANS( ($f2)->cmp, 1 );

WEIGHTED_ANS( ($f3)->cmp, 1 );

WEIGHTED_ANS( ($f4)->cmp, 1 );

###Row 3:

WEIGHTED_ANS( ($d1)->cmp, 1 );

WEIGHTED_ANS( ($d2)->cmp, 1 );

WEIGHTED_ANS( ($d3)->cmp, 1 );

WEIGHTED_ANS( ($d4)->cmp, 1 );

###Row 4:

WEIGHTED_ANS( ($dd1)->cmp, 1 );

WEIGHTED_ANS( ($dd2)->cmp, 1 );

WEIGHTED_ANS( ($dd3)->cmp, 1 );

WEIGHTED_ANS( ($dd4)->cmp, 1 );

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

BEGIN_PGML_SOLUTION

a = [$a]

b = [$b]

c = [$c]

END_PGML_SOLUTION

ENDDOCUMENT();