Forum archive 2000-2006

Gavin LaRose - cplx_cmp, ambiguous call of sqrt

Gavin LaRose - cplx_cmp, ambiguous call of sqrt

by Arnold Pizer -
Number of replies: 0
inactiveTopiccplx_cmp, ambiguous call of sqrt topic started 3/31/2006; 10:41:06 AM
last post 4/5/2006; 9:21:53 PM
userGavin LaRose - cplx_cmp, ambiguous call of sqrt  blueArrow
3/31/2006; 10:41:06 AM (reads: 667, responses: 7)
Hi all,

I have a problem which checks an answer using cplx_cmp, viz.,

  $ans = cplx(0,-1*sqrt(2*$b*$c2));
...
ANS( cplx_cmp( $ans ) );

I find that when a student enters an answer involving a square root, the message "Ambiguous call resolved as CORE::sqrt(), qualify as such or use &" is logged to the server's httpd error log. The problem is marked correctly, which is good, but the accumulation of error messages seems unnecessary.

My first guess would be that this has something to do with the overloading of sqrt in the complex numbers package. Can someone point me in the direction of a fix?

Thanks,
Gavin

<| Post or View Comments |>


userDavide P. Cervone - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
3/31/2006; 1:41:54 PM (reads: 780, responses: 0)
One question is are you using the old complex macros or the Parser-based ones from the Parser's Legacy directory? If you are not using the parser-based version, you might try that. To do so, you need to copy PGcomplexmacros.pl from pg/lib/Parser/Legacy to pg/macros (or your course macros directory, or somewhere in the macros path). If I recall correctly, there should be some documentation there.

If you already ARE using the parser version, let me know and I'll look into it. Otherwise, you are right that it has to do with sqrt() being overloaded, but it may not be the Complex package that is at fault, but rather PGcommonfunctions.pl (or whatever it is called). it might be possible to post-filter the result of AlgParser before evaluating it to convert sqrt() to CORE::sqrt().

Davide

<| Post or View Comments |>


userGavin LaRose - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/3/2006; 8:08:22 AM (reads: 784, responses: 0)
Hi Davide,

I'm using the parser versions.

Thanks,
Gavin

<| Post or View Comments |>


userDavide P. Cervone - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/3/2006; 8:35:50 AM (reads: 777, responses: 0)
Does that mean you WERE using the old versions and have switched, or that this error is from the parser version?

I was able to reproduce the warning using the old answer checkers, but they do not occur for me with the Parser-based ones.

Note that you actually have to replace the pg/macros/PGcomplexmacros.pl file with the one from the pg/lib/Parser/Legacy directory AND have useOldAnswerMacros set to 0 in the global.conf file to get the parser-based versions. The complex answer checker is not replaced automatically like the numeric and function checkers are, so using the parser-based numeric and function checkers does not mean you are using the parser-based complex checker, unless you took the extra step to move the PGcomplexmacros.pl file.

If you get answers that look like [1.4183746683487,pi/8] (i.e., polar form, or with more than 5 or 6 digits displayed), then you are still using the old checker. My suspicion is that this is the case for you.

Davide

<| Post or View Comments |>


userGavin LaRose - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/3/2006; 1:40:27 PM (reads: 774, responses: 0)
Hi Davide,

It means that I was using the Parser versions of the answer checkers in general, but had missed that to get the Parser version of the complex macros I had to copy the file. Sorry for missing that part of the problem.

I've now replaced PGcomplexmacros.pl, and so should be out of the woods.

Thanks,
Gavin

<| Post or View Comments |>


userGavin LaRose - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/4/2006; 7:59:52 AM (reads: 753, responses: 0)
...or maybe not.

I made the change to the Parser versions and the problem immediately crashed with an error, I think about checking equivalence. So I've backed off to the old complex answer checker. We're running an older version of the Parser (that is, HEAD from the CVS from about the beginning of the term), however, so it may be that I just need to get everything up to snuff there. In that the old answer checker only produces silent (for the student) errors, I'll deal with that when we get to the summer.

Thanks for the help,
Gavin

<| Post or View Comments |>


userDavide P. Cervone - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/4/2006; 9:54:07 AM (reads: 732, responses: 0)
If you send me the complete problem (you can do so by email if you prefer), I'll check it out. The Parser-based complex checker hasn't gotten a lot of shake-down, so there may well be problems with it that haven't been found.

Davide

<| Post or View Comments |>


userDavide P. Cervone - Re: cplx_cmp, ambiguous call of sqrt  blueArrow
4/5/2006; 9:21:53 PM (reads: 728, responses: 0)
OK, there was a bug in Parser/Legacy/PGcomplexmacros.pl that caused it to fail when the answer checker was passed a complex object rather than a string that needed to be parsed to produce a complex answer (I had checked for an object in package "Complex" rather than "Complex1", which is what WeBWorK actually uses). Sorry about that.

I have fixed the file and it is available in the CVS repository. Remember to copy it from pg/lib/Parser/Legacy to pg/macros in order for it to take effect.

Davide

<| Post or View Comments |>