WeBWorK Problems

Answer (in the form of a function) is not graded correctly

Re: Answer (in the form of a function) is not graded correctly

by Bentley Garrett -
Number of replies: 0
Hi Davide:

Thanks for your prompt reply!

The seed was: 176.

Below is the complete code for the .pg file. Sorry about the length, but I included everything to be safe.

Also, if it means anything, we are using version 2.4 right now. 

## DESCRIPTION
## First order ODEs: Bernoulli
## ENDDESCRIPTION

## KEYWORDS('differential equations','first order','Bernoulli')

## DBsubject('Differential Equations')
## DBchapter('First Order Differential Equations')
## DBsection('Bernoulli')
## Date('10/10/2012')
## Author('ZH')
## Institution('UTD')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


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

DOCUMENT(); 

loadMacros(
"PGbasicmacros.pl",
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
"parserAssignment.pl",
);

TEXT(beginproblem());


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

Context("Numeric");
Context()->variables->are(
t=>"Real"
);
parser::Assignment->Allow; 

$answer = Formula(" 2/(t^2sqrt(8e^t-8e+1)) ")->with(limits=>[1,5]);

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


Context()->texStrings;

BEGIN_TEXT

Solve the following Initial Value Problem
$BR
$BR
 \(    \begin{cases} ty' + 2y + t^5y^3e^t = 0 \\ y(1)=2 \end{cases}     \)
$BR
$BR

\( y=\) \{ ans_rule(60) \}

\{ AnswerFormatHelp("formulas") \}

END_TEXT

Context()->normalStrings;



Context()->texStrings;


SOLUTION(EV3(<<'END_SOLUTION'));

$PAR SOLUTION $PAR


This is a Bernoulli equation
$BR
$BR
\[ y' + \frac2t y = -t^4y^3e^t \]
$BR
$BR
Thus, we use the substitution \( u = y^{1-3} = y^{-2} \), i.e. \( y = u^{-\frac12} \) and \( y' = -\frac12 u^{-\frac32}u' \) and we get
$BR
$BR
\[ -\frac12u^{-\frac32}u' + \frac2t u^{-\frac12} = -t^4u^{-\frac32}e^t \iff u' - \frac4tu = 2t^4e^t \]
$BR
$BR
The last equation is linear, therefore we use the integrating factor \( \mu = e^{-\int \frac{4dt}t} = \frac1{t^4} \) and we get
$BR
$BR
\[
\frac d{dt}\left(\frac u{t^4}\right)=2e^t\;\; \Leftrightarrow\;\; y^{-2}=u=2t ^4e^t+Ct^4
\]

$BR
$BR
And we obtain the following general solution:
$BR
$BR
\[ y = \frac{\pm 1}{\sqrt{2t^4e^t+Ct^4}}, \text{ and } y \equiv 0 \]
$BR
$BR
The initial value gives us:
$BR
$BR
\[ 2 = \frac{1}{\sqrt{2e+C}} \Rightarrow 2e+C = \frac14 \Rightarrow C = \frac{1-8e}{4} \]
$BR
$BR
which leads to the solution
$BR
$BR
\[ y = \frac2{t^2\sqrt{8e^t-8e+1}} \]
END_SOLUTION

Context()->normalStrings;


######################
#  Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp( ));

COMMENT("MathObject version.");

ENDDOCUMENT();