Forum archive 2000-2006

Danny Glin - Problem with frac in PGdiffeqmacros.pl

Danny Glin - Problem with frac in PGdiffeqmacros.pl

by Arnold Pizer -
Number of replies: 0
inactiveTopicProblem with frac in PGdiffeqmacros.pl topic started 10/4/2004; 6:33:42 PM
last post 10/5/2004; 8:18:23 AM
userDanny Glin - Problem with frac in PGdiffeqmacros.pl  blueArrow
10/4/2004; 6:33:42 PM (reads: 964, responses: 2)
Howdy,
We've been looking to use some questions out of the Rochester templates for differential equations, and have run into the following problem:
It appears in setDiffEQ9Linear2ndOrderHomog/ur_de_9_10.pg
When entering an answer for the Wronskian in webwork 2, I get the following error:
There is an error in WeBWorK's answer to this problem, please alert your instructor. Error: Operator or semicolon missing before *A. Error detected evaluating correct adapted answer at (0.110000078 ) There is an error in WeBWorK's answer to this problem, please alert your instructor. Error: Operator or semicolon missing before *A. Error detected evaluating instructor answer at (0.110000078 )
After taking a closer look, the problem seems to stem from a call to the frac function in PGdiffeqmacros.pl
We've made a temporary fix by replacing this call with the straight fraction ("-$b/$a" in this case), but this leaves the possibility of a double negative as well as the fraction not being in lowest terms. Has anyone else run into this, and if so, is there a fix?
Thanx,
Danny

<| Post or View Comments |>


userArnold K. Pizer - Re: Problem with frac in PGdiffeqmacros.pl  blueArrow
10/4/2004; 8:29:26 PM (reads: 1213, responses: 0)
Hi Danny,

This doesn't address your main point but WeBWorK (really Perl)handles double negatives fine. The only possible problem is that you might end up with a perl espression of the form --3 which will give you an error since -- is perl's decrement operator. I doubt in your case this would occur but just to be safe you could write "- $b/$a" with a space after the minus sign.

Arnue

<| Post or View Comments |>


userDavide P. Cervone - Re: Problem with frac in PGdiffeqmacros.pl  blueArrow
10/5/2004; 8:18:23 AM (reads: 1206, responses: 0)
Danny:

I think you are using an old version of the problem, as the frac call is not used in the current one (the change occured in June 2003 according to the CVS logs). The frac call is still in the problem, but the $W answer has been replaced with -$b/$a, as you suggest.

The "Operator or semicolon missing before *A" message usually means that the answer included a variable that is not valid in the current formula, in this case "A". Where did that "A" come from? Well the frac() returns a HASH reference, and when that was inserted into the answer string, the answer was set to something like "exp(HASH(0xddaac0)*t)", and WeBWorK parsed this as "exp(H*A*S*H*(0*x*d*d*a*a*c*0)*t)", and tried to evaluate it to obtain the correct answer when only t is given a value. It turns out that since A has no other meaning, perl tries to interpret *A as something called a "typeglob" (sort of a reference to a name rather than an object itself, in this case it refers to main::A as a possible name for something rather than a value). So * here is not multiplication but typeglobbing. The "H" was interpreted as a string constant, and so there are now two operands (a string and a typeglob) with no operator in between, so perl complains that you either left out the operator (or maybe a semicolon that should have separated the end of one command from the beginning of the next one).

Anyway, your solution is the right one. The frac should never have been there in the first place.

Davide

PS, students can generate this error message by tying things like "HASH" as their answer to any function answer. It is also produced if they type "3X" rather than "3x", for example, which can be a bit confusing to students. Luckily, the new parser doesn't have this problem.

<| Post or View Comments |>