|Why isn't 'e' resolving?||topic started 11/11/2001; 9:43:43 PM
last post 11/12/2001; 12:18:31 PM
|Arnold K. Pizer - Re: Why isn't 'e' resolving?
11/12/2001; 12:18:31 PM (reads: 1032, responses: 0)
This is a little tricky. It depends on whether the expression is evaluated within the body of the problem or within an answer evaluator.
If the expression is evaluated within the body of the problem then you must use valid Perl. Recent versions of WeBWorK allow you to use to use $E and $PI (capitals are important as you have discovered) for the numerical values. Thus for example you could say
$ans = 10*$E**3;
Here $ans is evalated by Perl to be the number 200.855 and then then it is shipped off to the answer evaluator std_num_cmp.
Another option would be
$ans = "10e^3";
Here $ans is a string which is shipped off to the answer evaluator std_num_cmp. The answer evaluator will evaluate the string so using e and ^ are legal. Note that in the first example WeBWorK will display the correct answer as a number 200.855 and in the second example the correct answer will be displayed as 10e^3. See http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$651 for more info on this.
Everything a student enters is evaluated by an answer evaluator, but when writing problems you need to keep track of what is being evalued by Perl. Usually this is everything unless you ship your answers off as strings. A mistake that is easy to make is to write $c = $a^3 instead of $a**3. This doesn't generate an error since ^ is a valid Perl bitwise operator but is not exponentiation so the results will not be what you expect.