DOCUMENT();Here's what I'm getting:
loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl", # Math Objects
"source.pl", # allows code to be displayed on certain sites.
"PGcourse.pl", # Customization file for the course
);
# Print problem number and point value (weight) for the problem
TEXT(beginproblem());
# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;
##############################################################
#
# Setup
#
#
Context("Numeric");
# Allow y' as a variable name
Context()->variables->{namePattern} = qr/[a-z][a-z0-9_]*'*/i;
Context()->variables->are( y => "Real", x => "Real", c => "Real", "y'" => "Real" );
# Randomized Parameters for the problem
$a = Real(random(1,8,1));
$b = Real(random(1,8,1));
# Initial Value
$y0 = Real(random(-10,-0.1,0.1));
# Value of "c" for the particular solution
$c = Real(($y0)**3+3*$b/($a)**2);
# General Solution
$sol = Formula("(3*$b*(1/$a*x*e**($a*x)-1/($a)**2*e**($a*x))+c)**(1/3)");
# Particular Solution
$part = Formula("(3*$b/$a*x*e**($a*x)-3*$b/($a)^2*e**($a*x)+$c)**(1/3)");
# Interval of Validity
$int = Interval("(-inf,inf)");
# LHS of the DE
$de = Formula("y ** 2 * e ** ( -1 * $a * x ) * y'")->reduce;
# RHS of the DE
$hom = Formula("$b*x")->reduce;
# General solution solved for "c" (for use in custom grader)
$getC = Formula("y**3 - 3*$b/$a*x*e**($a*x) + 3*$b/($a)**2*e**($a*x)")->reduce;
##############################################################
#
# Text
#
#
Context()->texStrings;
BEGIN_TEXT
Separate the following differential equation and integrate to find the general solution:
$BR
\( $de = $hom \)
$BR
$BR
Then give the particular solution that satisfies the initial condition \(y(0) = $y0\) and state the interval on which this solution is valid.
$BR
$BR
General Solution (explicitly): \(y(x)=\) \{$sol->ans_rule\}
$BR
Particular Solution (explicitly): \(y(x)=\) \{$part->ans_rule\}
$BR
Interval of Validity: \{$int->ans_rule\}
$BR
END_TEXT
$showHint = 5;
BEGIN_TEXT
$PAR
If you don't get this in $showHint tries, you can get a hint.
END_TEXT
BEGIN_HINT
Make sure you've adjusted to the variables appearing in this problem: \(y\) is dependent upon \(x\) as the independent variable.
$BR
$BR
Separate the \(y\)s to the left and the \(x\)s to the right, then separate the differentials and integrate both sides. You _did_ remember to use integration by parts, did you not?
$BR
$BR
Finish by solving for \(y\)
END_HINT
Context()->normalStrings;
##############################################################
#
# Answers
#
#
ANS( $sol->cmp( checker => sub {
my ( $correct, $student, $self ) = @_;
### Get the student's y', c, and find the derivative of their "c".
my $Dstudent = $student->D('x');
my $studentC = $getC->substitute(y=>"$student");
my $DstudentC = $studentC->D('c');
### Plug the student's solutions into the DE
my $rhs = $hom->substitute(y=>"$student");
my $lhs = $de->substitute("y'"=>"$Dstudent", y=>"$student")->reduce;
### Make sure that the student has the _general_ solution here
if ($DstudentC == Formula("0")) {
Value->Error("Your answer is not the most general solution. Where's 'c'?");
##### \/ \/ \/ For Debugging \/ \/ \/
} else {
Value->Error("$lhs is not equal to $rhs");
};
return ($lhs == $rhs && $DstudentC != Formula("0"));
}));
ANS($part->cmp);
ANS($int->cmp);
ENDDOCUMENT();
This particular seed has the problem listed as:
incorrect ::
(([(0.5*x*[e^(6*x)]-0.0833333*[e^(6*x)]+c)^0.333333]^2)*[e^(-6*x)]*0.333333*[(0.5*x*[e^(6*x)]-0.0833333*[e^(6*x)]+c)^(-0.666667)]*(0.5*[e^(6*x)]+6*0.5*x*[e^(6*x)]*ln(e)-0.5*[e^(6*x)]*ln(e))) is not equal to (x)
But, by reducing (by hand) the output, one can see that they _are_ equal. What is WeBWorK not seeing here? And how might I adapt the problem to resolve this issue?