## Forum archive 2000-2006

### Alberto Candel - problem typo

by Arnold Pizer -
Number of replies: 0
 problem typo topic started 10/28/2004; 7:03:01 PMlast post 11/18/2004; 2:27:11 AM
 Alberto Candel - problem typo  10/28/2004; 7:03:01 PM (reads: 3560, responses: 32) I think there is a typo in the answer to problem setAlgebra20QuadraticFun/lh3-1_85.pg Answers 2 and 3 should be $ans2 = ($a**2*$c/4)+$b; $ans3 = [$a*$c+$c*sqrt($a**2+4*($b/$c))]/2; Also, I have a query on the answer to problems like setAlgebra20QuadraticFun/vertexform.pg This problem asks to find the vertex of the graph of a quadratic function. It admits the answer str_cmp($vertex) where $vertex="($H,$K)" Now if the vertex is (10,7) and the student inputs (10, 7) (with a space between the comma and the number) WW would say that it is incorrect. How can I fix that? Thanks Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 10/29/2004; 11:18:30 AM (reads: 3800, responses: 0) Thanks for the bug report on setAlgebra20QuadraticFun/lh3-1_85.pg and the correct solution. Note that$ans3 = [$a*$c+$c*sqrt($a**2+4*($b/$c))]/2; is incorrect for a subtle reason. Square brackets are not allowed in an arithemetical expression in perl (or at least they do not do what you think they do) so you have to write $ans3 = ($a*$c+$c*sqrt($a**2+4*($b/$c)))/2; Better yet is to let WeBWorK parse the expression by writing$ans3 = "[$a*$c+$c*sqrt($a^2+4*($b/$c))]/2"; Notice the quotes (and you can then also use ^ in place of ** if you want). This has the added advantage that when the student sees the answer, instaed of e.g. 29.4272486205415 they will see [2*14+14*sqrt(2^2+4*(3/14))]/2 which makes a lot more sense. Similarily, you can write $ans2 = "($a^2*$c/4)+$b"; As for setAlgebra20QuadraticFun/vertexform.pg, there are (at least) three things you can do. The simplest is to replace &ANS(str_cmp($vertex)); with &ANS(ordered_str_cmp($vertex)); or with the equivalent &ANS(str_cmp($vertex,'remove_whitespace')); This will accept (10,7) and (10, 7) but not (10, 2+5). A better solution is to first add extraAnswerEvaluators.pl to the list of macros at the top so that it reads loadMacros(PG.pl,PGbasicmacros.pl,PGchoicemacros.pl,PGanswermacros.pl,PGauxiliaryFunctions.pl,extraAnswerEvaluators.pl); and then to replace &ANS(str_cmp($vertex)); with &ANS(interval_cmp("($H,$K)")); I will use the third method to fix the problem in the CVS. Arnie <| Post or View Comments |>

 Alberto Candel - Re: problem typo  10/29/2004; 2:29:06 PM (reads: 3775, responses: 0) Thanks Arnie, I recall now that another instance of the problem with the spaces appears in problem setAlgebra20QuadraticFun/standardform.pg At first I didn't notice because when looking at the past answers of the one student that brought it up I saw 2 commas instead of 1. He had erased his current answer. Alberto <| Post or View Comments |>

 Arnold K. Pizer - Re: problem typo  10/29/2004; 2:39:19 PM (reads: 3778, responses: 0) Thanks again Alberto. I fixed this one again using interval_cmp. Arnie <| Post or View Comments |>

 Alberto Candel - Re: problem typo  11/1/2004; 1:58:18 PM (reads: 3753, responses: 0) Another typo: In setAlgebra23PolynomialZeros/roots1.pg, the last entry in the "match list" should be "$$x=+2i,-2i,-2,-2$$" Otherwise (with -2i and -2i) the polynomial has complex coefficients. Also, in your first reply above, regarding the use of ^2 instead of **2 in the .pg files, I seem to have problems with ^2. It doesn't give the right answer. I am using WW 1.9, is that the reason? Maybe I did something else wrong. Thanks, Alberto <| Post or View Comments |>

 Arnold K. Pizer - Re: problem typo  11/1/2004; 5:03:41 PM (reads: 3756, responses: 0) Thanks Alberto, I updated setAlgebra23PolynomialZeros/roots1.pg in the CVS. As long as the answer is a string, i.e. it is enclosed in quotes, e.g. $ans3 = "[$a*$c+$c*sqrt($a^2+4*($b/$c))]/2"; you can use ^ instead of **. This works in WW 1.9 and in WW 2. Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/2/2004; 11:32:05 AM (reads: 3750, responses: 0) One more typo (I think): in setAlgebra20QuadraticFun/lh3-1_41.pg If the vertex and the y-intercept happen to be the same, then there are infinitely many solution but it only accepts one as correct. How do I fix this? Thanks, Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/2/2004; 11:52:02 AM (reads: 3755, responses: 0) Thanks again Aberto. The fix is easy. Replace$h=random(-2,2,2); by $h=non_zero_random(-2,2,2); Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/2/2004; 5:15:59 PM (reads: 3731, responses: 2) One more. I don't know whether this is a typo, but there is something going on with setAlgebra23PolynomialZeros/beth1polyfun.pg No text problem appears, but the warning "This problem did not ask any questions" instead. Can you help me fixing it? Thanks, Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/3/2004; 1:17:06 PM (reads: 4032, responses: 0) This problem seems never to have been completed. Here is a version where find all roots means all real and complex roots. ##DESCRIPTION## Algebra problem: polynomial functions##ENDDESCRIPTION##KEYWORDS('algebra', 'polynomial function', 'rational zero')DOCUMENT(); # This should be the first executable line in the problem.TEXT(&beginproblem);$showPartialCorrectAnswers = 1;$a = non_zero_random(-5,-1,1);$b = non_zero_random(1,5,1);# (x-a)(x-b)(x^2+2)$b1=-($a+$b);$c1=$a*$b+2;$d1=-2*($a+$b);$e1=2*$a*$b;$p = nicestring([1,$b1, $c1,$d1, $e1]);$p="P(x)=$p ";BEGIN_TEXTFind$BBOLD all $EBOLD of the zeros of the following polynomial and give them in acomma-separated list.[$p ]$BR Its zeros are:{ ans_rule(40) }END_TEXTANS(number_list_cmp("$a, $b, sqrt(2)i, -sqrt(2)i ", complex=>'ok','tolType'=>'absolute','tolerance'=>0.001));ENDDOCUMENT(); # This should be the last executable line in the problem. <| Post or View Comments |>  John Jones - Re: problem typo 11/3/2004; 1:39:59 PM (reads: 3718, responses: 0) Here is our current version of beth1polyfun. Our only claim on authoring this problem is that Beth is here. ##DESCRIPTION## Algebra problem: complex roots of a polynomial##ENDDESCRIPTION##KEYWORDS('algebra', 'polynomial function', 'zero')DOCUMENT(); # This should be the first executable line in the problem.TEXT(&beginproblem);$showPartialCorrectAnswers = 1;$a = non_zero_random(-5,-1,1);$b = non_zero_random(1,5,1);# (x-a)(x-b)(x^2+2)$b1=-($a+$b);$c1=$a*$b+2;$d1=-2*($a+$b);$e1=2*$a*$b;$p = nicestring([1,$b1, $c1,$d1, $e1]);$p="P(x)=$p ";BEGIN_TEXTFind$BBOLD all $EBOLD of the zeros of the following polynomialand give them in a comma-separated list. If there are no zeros,enter$BITALIC None$EITALIC.[$p]$BR Its zeros are:{ ans_rule(40) }$BR $BR$BBOLD Note: $EBOLD complex numbers should be in the form(a+bi).END_TEXTANS(number_list_cmp("$a, $b, sqrt(2)*i, -sqrt(2)*i", complex=>'ok', strings=>['none']));ENDDOCUMENT(); # This should be the last executable line in the problem. I think the most recent change was the note about the form of the answers. Webwork would choke on "sqrt(-2)" and "-sqrt(-2)". In fact, we may revise this problem to use the new parser which can handle answers in that form. John <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/3/2004; 4:20:05 PM (reads: 3714, responses: 0) Hi John, I like your revision but I have two questions: When I tried, 1.4142i, and -1.4142i (and the other two roots) were not accepted as correct (but 1.41421i, etc. was OK). 1.414 is accepted by num_cmp as being equal to sqrt(2). What sets the default tolerenance for number_list_cmp? Why doesn't it use the same tolerenance as num_cmp? My other point is very minor. I prefer "sqrt(2)i, -sqrt(2)i" to "sqrt(2)*i, -sqrt(2)*i". Arnie PS Do you know how the library vlean up project is going? <| Post or View Comments |>  John Jones - Re: problem typo 11/3/2004; 6:38:46 PM (reads: 3680, responses: 0) Hi Arnie, number_list_cmp just sends values off to other evaluators for checking. If we just had real numbers (and not specified complex=>ok), then it would use num_cmp for the checking. Since this problem uses complex values, they go to cplx_cmp. It apparently uses a different tolerance than num_cmp does. I just check it with a problem where the answer was just sqrt(2). I only really know about the small amount of library clean up which took place here over the summer. The other sites are where the bulk of that kind of stuff will be done. John <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/3/2004; 7:57:29 PM (reads: 3737, responses: 0) Thanks for your fix. On problem setAlgebra23PolynomialZeros/FindPositiveRoot.pg, it appears that if one of the coefficients is 0, then the sign + (or -) is not printed, like x5 + 3x4 -114 x3 -292 x20x1 -5700 (Actually this is the problem instance that appears in the .pdf included within the UofR templates. The code for this problem is rather sophisticated). And thanks again. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/3/2004; 9:58:55 PM (reads: 3794, responses: 0) Not exactly a typo, but in setAlgebra25RationalFun Problems FindInfo2.pg and FindInfo2_r.pg will give credit by simply submitting all boxes blank. That is, they accept empty answers as correct. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/4/2004; 3:31:04 PM (reads: 3777, responses: 0) With respect to problem setAlgebra23PolynomialZeros/FindPositiveRoot.pg mentioned above, I figured out that seed 2226 produces x40x3 + 7x2 - 82x1 -390 That is, if one of the coefficients is 0, no +/- sign is printed. Please let me know how could I fix this. Thanks, Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/4/2004; 3:48:22 PM (reads: 3714, responses: 0) Seed 2226 produces f(x) = x^5+4 x^4-282 x^3-1128 x^2-1144 x^1 - 4576 so I don't know an example where the problem occurs. As you say, the code is somewhat sophisticated and I haven't spent the time to understand what the problem is doing. However, assuming everything else is correct, the following change should fix the bug. Replace $poly = "";foreach $i (0..$#prod){ $j =$#prod-$i; if ($i<$#prod) { if ($i==0) {$poly=$poly."x^{$j}";} elsif ($prod[$i] > 0) {$poly=$poly."+$prod[$i] x^{$j}";} else {$poly=$poly."$prod[$i] x^{$j}";} } else {$poly=$poly."+$prod[$i]";}} with $poly = "";foreach $i (0..$#prod){ $j =$#prod-$i; if ($i<$#prod) { if ($i==0) {$poly=$poly."x^{$j}";} elsif ($prod[$i] > 0) {$poly=$poly."+$prod[$i] x^{$j}";} elsif ($prod[$i] < 0) {$poly=$poly."$prod[$i] x^{$j}";} } else {$poly=$poly."+$prod[$i]";}} Thus only terms with non-zero coefficients are displayed. Let me know if this works. Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/4/2004; 4:25:26 PM (reads: 3677, responses: 0) Sorry about that. It is seed 2226 for problem setAlgebra23PolynomialZeros/FindAllRoots0.pg (The one I mentioned earlier also has the same issue, but I don't know a seed # that produces it.) I tried your suggestion on this one (that portion of the code is the same) but I still get a 0 without sign. Thanks, Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/4/2004; 5:21:43 PM (reads: 3678, responses: 0) That's strange (could it be a caching problem?). I'll look at it more closely. <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/4/2004; 5:27:37 PM (reads: 3685, responses: 0) This is a message about the fact that cplx_cmp has a different relative tolerance than num_cmp. There is a bug in PGcomplexmacros.pl. It seems like whoever wrote this copied a lot of stuff from num_cmp but missed a few things. The easiest fix is to edit lines 125, 305, 769, and 959 replacing$cplx_params{'tolerance'} = .01*$cplx_params{'tolerance'}; by$cplx_params{'tolerance'} = .01*$cplx_params{'relTol'}; Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/4/2004; 5:43:07 PM (reads: 3763, responses: 0) No, it is not a caching problem. It was my mistake; I left one line in that I should have removed. Sorry about that, and thank you. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/7/2004; 10:01:10 PM (reads: 3642, responses: 0) Problem setAlgebra25RationalFun/FindInfo2.pg has the wrong answer for the vertical asymptotes. I fixed it by changing lines 151 and 152 to &ANS(num_cmp($v2));&ANS(num_cmp($v1)); This seems to work, but I am not sure of what I really did. This problem's code is too complex. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/8/2004; 8:04:47 AM (reads: 3634, responses: 0) Problem setAlgebra25RationalFun/FindInfo3_r.pg has a bug that can be corrected with &ANS(interval_cmp()) as in a previous message in this topic. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/8/2004; 8:42:38 AM (reads: 3623, responses: 0) Problem setAlgebra25RationalFun/FindInfo3.pg has a very fine bug I think. With seed number 92 it produces a rational function whose num and denum are degree 3 poly's with two common factors. Thus it has just one vertical asymptote, but WW is expecting two. I am not sure which of the two factors corresponds to the missing asymptote and which to the hole. Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/8/2004; 5:11:33 PM (reads: 3610, responses: 0) Thanks for the corrections Alberto. Since the changes are a little too long to go over here, please download the new versions from the CVS. A good way to view and download individual problems (and to see what changes have been made) is to goto http://cvs.webwork.rochester.edu/viewcvs.cgi/ Select UR Problem Library as the Project Root and then select rochester_problib. For instructions on downloading the current version of the whole library, see Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/9/2004; 2:08:04 PM (reads: 3625, responses: 0) Is there a way for me to access those corrected pg files other than CVS? I have not yet set up our server for CVS, and will not be able to do it just now. <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/9/2004; 4:07:30 PM (reads: 3618, responses: 0) Hi Alberto, You don't need CVS to grab individual problems. Use the link http://cvs.webwork.rochester.edu/viewcvs.cgi/ and follow the instructions above. Once you select a problem, click on view and then copy the problem. Also you can easily just view the changes from the previous version. Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/11/2004; 1:57:26 AM (reads: 3611, responses: 0) Thanks Arnie That's great, I didn't know about CVS. (I should have read your post instead of just the email from WW.) Anyhow, setAlgebra25RationalFun/FindInfo3.pg now produces a timeout pink page with seed number 1548 It works fine with other seed nos., so I doubt that it is related to our server's speed. Alberto <| Post or View Comments |>  Arnold K. Pizer - Re: problem typo 11/11/2004; 1:56:10 PM (reads: 3599, responses: 0) Thanks Alberto, I didn't get a timeout with seed 1548 but looking at the code, there are two places where random(9,9,1) should be replaced by random(-9,9,1). This occured in the original problem and I just copied it without looking closely. Obviously, using random(9,9,1) will result in an infinite loop. Arnie <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/12/2004; 1:29:09 PM (reads: 3603, responses: 0) Seed 380 also produces a timeout pink page here. I guess many others do because our server has a bunch of lingering perl processes, but others work just fine. Thanks for the fix. Alberto <| Post or View Comments |>  Alberto Candel - Re: problem typo 11/18/2004; 2:18:05 AM (reads: 3558, responses: 0) Problem setAlgebra28ExpFunctions/pexp.pg seems to have the wrong answers for some of the random choices (e.g. seed 3883). I think the typos are in lines 46 and 50. They should be $ans_c = "-$e**x"; and $ans_c = "\$e^**(-x)"; respectively. Alberto <| Post or View Comments |>

 Alberto Candel - Re: problem typo  11/18/2004; 2:27:11 AM (reads: 3541, responses: 0) After posting the above I saw in the CVS that the bug has already been fixed. But since I don't know how to remove a post ... A. <| Post or View Comments |>