## Forum archive 2000-2006

### Dennis Keeler - Another square root of negative issue

by Arnold Pizer -
Number of replies: 0
 Another square root of negative issue topic started 10/12/2004; 6:58:24 AMlast post 10/13/2004; 1:46:45 PM
 Dennis Keeler - Another square root of negative issue  10/12/2004; 6:58:24 AM (reads: 2286, responses: 11) Hi. My students and I are running into an issue where (f(x))^.5 or sqrt(f(x)) are giving errors like "WeBWorK was unable evaluate your function. Please check that your expression doesn't take roots of negative numbers, or divide by zero." For instance, the naive answer to rochesterLibrary/setDerivatives7Log/mec8.pg seed 1972 is ((4x+6)/(7x-3))^-.5 which gives the above error. If one inputs 1/sqrt((4x+6)/(7x-3)) the message Error: Can't take sqrt of -2.88789. is displayed. Of course that problem can be dealt with using log differentiation. But this issue can't be avoided in setDerivatives5ChainRule/ur_dr_5_21.pg . In that problem, the correct answer is sometimes accepted, sometimes not, depending on the luck of the draw during the random evaluation comparison. The only solution I see on my end is to avoid any problem with square roots, though that cuts out a lot of nice ones. Any other suggestions? Thanks. -Dennis <| Post or View Comments |>

 Dennis Keeler - Re: Another square root of negative issue  10/12/2004; 9:20:01 AM (reads: 2795, responses: 0) Thanks for the advice. I'm not yet to the point of writing my own problems, so maybe this is just a bug in the problems above. However, I imagine in some problems that it will be difficult to think of every possible way of writing a correct answer that involves a square root and figuring out appropriate bounds for x. In setDerivatives5ChainRule/ur_dr_5_21.pg, the proble is to take the derivative of sqrt($trig1($e^(x^$m*$trig2(x)))) where $trig1 can be sin or cos, and$trig2 can be sin or cos independently, and $m=2 to 5. I haven't gotten out a piece of scratch paper, but it looks challenging to find out what bounds to put on x. -Dennis <| Post or View Comments |>  Carl F. Letsche - Re: Another square root of negative issue 10/12/2004; 12:31:40 PM (reads: 2530, responses: 1) If you really want to do a problem like this, just bury the square root a little deeper in the chain so that you *can* get a grip on a domain. Finding the derivative of$trig1(sqrt($e^(x^$m*$trig2(x)))) is every bit as nasty a computation, and any positive stretch of domain is fine. Carl <| Post or View Comments |>  Dennis Keeler - Re: Another square root of negative issue 10/12/2004; 3:23:43 PM (reads: 2749, responses: 0) Yes, this certainly works, Carl. Thanks. Upon further reflection, I realized that for this particular question, as long as x is near 0, the expression inside the square root is positive. Using Maple to look at the various possibilities, it turns out that (0, .5) works as an interval for the original problem, as the input of the trig function will be between 0 and pi/2. In fact, if cos(x) is in the exponent, (0, 1) works. This would explain why about 50% of my students had no trouble with this problem. -Dennis <| Post or View Comments |>  John Jones - Re: Another square root of negative issue 10/12/2004; 6:33:47 PM (reads: 2512, responses: 0) Specifying the domain can help, but there are some problems where you currently can't win. While it is essential that the limits range fit into the domain of the right answer, it really should fit all wrong answers. Otherwise, students enter something and get system type error messages. Student's don't always interpret this as "my answer must be really wrong". Instead, some think "the system is buggy because it is throwing error messages and all I did is submit an answer, so my answer might be right". I have run into some where there is no single domain which will work - there is no common ground between the right answer and all natural wrong answers one might give. One solution might be to move to the new parser. In my limited experience with thus far, it doesn't seem to have this problem. John <| Post or View Comments |>  Arnold K. Pizer - Re: Another square root of negative issue 10/12/2004; 6:47:23 PM (reads: 2531, responses: 1) Thanks for the bug reports, analysis, and suggested fixes. I changed setDerivatives5ChainRule/ur_dr_5_21.pg using the first suggestion of switching sqrt with$trig1. For setDerivatives7Log/mec8.pg I used &ANS(fun_cmp($ans, limits => [10,15])) since things are always defined there. Both these edited problems are now uploaded to CVS. If Davide's parser always returns either a value or NaN, then when that becomes standard we could modify fun_cmp so that if, in comparing two functions, if one returned Nan and the other a value the functions would be declared different and if both returned NaN, then another random point would be considered. This at least would take care of some troubles but not a case where the problem author has WeBWorK check points where the function is not (or should not) be defined. This was the case with setDerivatives7Log/mec8.pg (f(x) = ln { sqrt { frac {$a x + $b } {$c x + \$d } } } ) where the answer obtained by simplifying then differentiating is defined almost everywhere but the original function and the answer obtained by just differentiating is not. Arnie <| Post or View Comments |>