## WeBWorK Problems

### hardcopy chokes on solution to this problem

by Tim Alderson -
Number of replies: 7

Likely obvious but I just cant figure out why LaTeX is choking on this problem when I include the solution.

The table seems okay to me, but there must be an issue with the array.

++++++++++++++++++

## DESCRIPTION
## This is Problem 3.3.15 from the APEX Calculus text (3.3.16 in the ULETH APEX text). It covers the First Derivative Test.
## ENDDESCRIPTION

## DBsubject(Calculus - single variable)
## DBchapter(Applications of differentiation)
## DBsection(Increasing/decreasing functions and local extrema)
## Level(2)
## Institution('Valdosta State University')
## Author('S. V. Ault')
## RevisedBy('F. J. Francis')
## TitleText1('APEX Calculus')
## AuthorText1('Hartman')
## EditionText1('3.0')
## Section1('3.3')
## Problem1('15')
## MO(1)
## Keywords('first derivative test', 'increasing and decreasing functions','ULETH-MATH1560', 'ULETH-MATH1565')

###########################
#  Initialization
DOCUMENT();

# Load whatever macros you need for the problem
"PGstandard.pl",
"MathObjects.pl",
# Used to provide contextual help for how to type answers.
# Provides greater control over the layout of the problem.
"PGML.pl",
# Used for course-specific initializations.
"PGcourse.pl",
);

# Sets up basic problem information.
TEXT(beginproblem());

#############################
#   Setup
#-ULETH-#
Context("Numeric");

$b = 3*random(1,6,1);$c = random(1,20,1)*random(-1,1,2);

$f = Formula("x^3 +$b x^2 + $c")->reduce();$b2 = 2*$b;$df = Formula("3x^2 + $b2 x")->reduce(); Context("Interval"); @domain = Compute("(-INF, INF)");$crit1 = -$b2/3;$crit2 = 0;

@inc = Compute("(-INF, $crit1) U ($crit2, INF)");
@dec = Compute("($crit1,$crit2)");

$ans_crit = List($crit1, $crit2);$ans_max = List($crit1);$ans_min = List($crit2); #-ENDULETH-# ############################# # Problem Text #-ULETH-# BEGIN_PGML In the following questions, consider the function >>[f(x) = [$f].]<<

Enter *DNE* if an answer does not exist.
----
a) Give the domain of [f] (in interval notation): [________________________]{Compute(@domain)}  [@ AnswerFormatHelp("intervals") @]*

b) Find the critical numbers of [f].  [____________]{Compute($ans_crit)} [@ AnswerFormatHelp("numbers") @]* (Separate multiple answers with commas.) c) Determine the intervals on which [f] is increasing and decreasing. [f] is increasing on: [________________________]{Compute(@inc)} [f] is decreasing on: [________________________]{Compute(@dec)} d) Use the First Derivative Test to determine whether each critical point is a relative maximum, minimum, or neither. Relative maxima occur at [x = ] [____________]{Compute($ans_max)} (Separate multiple
Relative minima occur at [x = ] [____________]{Compute($ans_min)} (Separate multiple answers with commas.) END_PGML #-ENDULETH-# ############################# # Solution #-ULETH-# BEGIN_PGML_SOLUTION Since [f(x) = [$f]] is a polynomial, its domain is all real numbers,
or [(-\infty, \infty)].

Its derivative is [f'(x) = [$df]]. Factor to find the two critical numbers, [x = [$crit1], [$crit2]]. Use the first derivative test, choosing sample points in each interval. [ \begin{array}{|l|l|l|} \hline \textrm{Interval} & \textrm{Sign of}\; f'\; \textrm{at sample} & \textrm{Conclusion} \\ \hline \hline (-\infty, [$crit1]) & \textrm{positive} & \textrm{increasing} \\
\hline
([$crit1], [$crit2]) & \textrm{negative} & \textrm{decreasing} \\
\hline
([$crit2], \infty) & \textrm{positive} & \textrm{increasing} \\ \hline \end{array} ] Based on the signs in each interval there is a relative maximum at [x = [$crit1]] and a
relative minimum at [x = [$crit2]]. END_PGML_SOLUTION #-ENDULETH-# ############################# # Answer evaluation #Answers are evaluated in the problem text. #-ULETH-# # Setting this to 1 means that students will receive feedback on whether their # answers are correct.$showPartialCorrectAnswers = 1;

#-ENDULETH-#

COMMENT('
Randomization provides 240 possible versions of this question.<BR>
Includes a solution set.<BR>
');

ENDDOCUMENT();

by Alex Jordan -

### Re: hardcopy chokes on solution to this problem

by Tim Alderson -

Unfortunately I don't have the greatest luck in compiling hardcopy.tex locally on my machine (Windows + TeXLiVe).

With.packages.tex, PGML.tex, and CAPA.tex in the same directory I get multiple "Missing \begin{document}" errors.

If I comment out the calls to these files then compiling completes, but with many "undefined control sequence" type errors rated mainly to PGML.

All this being said,  the log from a MWE (attached) appears to have only PGML related issues, and the pdf appears to be fine.

### Re: hardcopy chokes on solution to this problem

by Danny Glin -
I fooled around with the latex a little bit. If I move the table outside of the \pgmlSetup block, then it displays fine. Inside the \pgmlSetup block, if I remove any instance of \hline, then it displays fine, but inside \pgmlSetup with \hline, the table gets mangled, though on my tex installation I don't get any errors.

Clearly something in the PGML setup is interacting weirdly with the table layout, but I don't see anything in PGML.tex that looks like it should affect the table.

There are workarounds, like using niceTables.pl instead of a LaTeX table, but it would be good to know what's causing this (since it should work).

### Re: hardcopy chokes on solution to this problem

by Glenn Rice -

If you move all of the \hline's up to the end of the line above them, it compiles with no error.  Also, move the \end{array} to the end of the line after the last "\\ \hline" to prevent a new empty row at the end.  So make the code

[
\begin{array}{|l|l|l|} \hline
\textrm{Interval} &
\textrm{Sign of}\; f'\; \textrm{at sample} &
\textrm{Conclusion} \\ \hline \hline
(-\infty, [$crit1]) & \textrm{positive} & \textrm{increasing} \\ \hline ([$crit1], [$crit2]) & \textrm{negative} & \textrm{decreasing} \\ \hline ([$crit2], \infty) & \textrm{positive} & \textrm{increasing} \\ \hline \end{array}
]

This is caused by the way that PGML changes the catcode for carriage returns.

### Re: hardcopy chokes on solution to this problem

by Tim Alderson -

Thank you Glenn. Once again you come through with a solution. I have to say it...You rock!

### Re: hardcopy chokes on solution to this problem

by Glenn Rice -

Thanks.  I try to do my part.

WeBWorK rocks!