## WeBWorK Problems

### Recognizing equivalent implicit differentiation answers ### Recognizing equivalent implicit differentiation answers

by Doug Torrance -
Number of replies: 3
Suppose we want to compute the second derivative of y when y is defined implicitly by:

x2 + y2 = 1

Using implicit differentiation, the answer is:

y'' = (-x2 - y2) / y3

A clever student might recognize that the numerator is just the opposite of the left-hand side of our original implicit equation, and enter:

y'' = -1 / y3

Is there a way for WeBWorK to recognize both solutions as correct?

From what I understand, if we use MathObjects and define a Formula for our answer, the answers will be checked by picking some random test points for x and y. But in this case, we'd want to make sure that those test points satisfy the original implicit equation. For example, if we pick x = 1/2 as one of the test points, then we would want to pair it with y = sqrt 3 / 2 or y = - sqrt 3 / 2. ### Re: Recognizing equivalent implicit differentiation answers

by Danny Glin -
For this case I use parserOneOf.pl, which allows you to give a list of correct answers, of which the student can submit any one.

You will need to add parserOneOf.pl to the loadMacros section, then the usage would be something like:

$correct1 = Compute("(-x^2-y^2)/y^3");$correct2 = Compute("-1/y^3");
ANS(OneOf($correct1,$correct2)->cmp());

One could try to write a more sophisticated answer checker that tried to substitute the original formula where possible, but in the example you provide and the ones I'm using I find it very unlikely that the student would find a correct answer other than the two forms mentioned. ### Re: Recognizing equivalent implicit differentiation answers

by Alex Jordan -
Here is an example of what I have done in the past for this issue.

Say the problem asks to find dy/dx for x^4+y^2+y=7.

Consider this code:

$dydx = Formula("-4x^3/(2y+1)"); @y = (random(-2,2,0.2), random(-2,2,0.2), random(-2,2,0.2), random(-2,2,0.2), random(-2,2,0.2)); @x = map{(7-($_)-($_)**2)**(1/4)*(-1)**(random(-1,1,2))} (@y); @xy = map{[$x[$_],$y[$_]]} (0..4);$dydx -> {test_points} = ~~@xy;

Explanation:
1. Add y to the context (this assumes x is there to start).
2. Make the canonical correct answer formula. This will display as "the" correct answer.
3. Make some random y-values coming from an interval where 7 - y - y^2 is positive. This part means you need to consider the specifics of the original curve.
4. Find x-values that pair with those y-values on the curve. This was doable with this curve because x can essentially be solved for. Note it is randomly choosing positive or negative fourth roots. In other settings, it may make more sense to randomize x-values and solve for y-values. In yet other settings, this approach just isn't quite doable.
5. Make an array where each element is an array reference to an x,y-pair that is on the curve.
6. Set the test points for the answer to be this array.

So during a check, instead of choosing a bunch of random x and y-values to plug in to -4x^3/(2y+1), it is forced to only choose (x,y) pairs that are on the curve. Therefore if a student uses an expression that has made use of the defining relationship between x and y, it won't matter. With this example, it is OK to answer with:
-4x^3/(2y+1)

or with:
-4x^4/[x(2y+1)]

or with:
-4(7 - y - y^2)/[x(2y+1)]

etc. 