I need advice on how to use radcan



  On 8/28/2010 8:16 PM, Richard Hennessy wrote:
>
>
> --------------------------------------------------
> From: "Richard Fateman" <fateman at cs.berkeley.edu>
> Sent: Saturday, August 28, 2010 8:45 PM
> To: <drgst at web.de>
> Cc: <maxima at math.utexas.edu>
> Subject: Re: [Maxima] I need advice on how to use radcan
>
>>  On 8/28/2010 1:28 PM, drgst (at) web (dot) de wrote:
>>> Hi all,
>>>
>>> here is a simple example which frightens me:
>>>
>>> (%i1) sqrt(a^2-2*a*b+b^2);
>>> (%i2) radcan(%);
>>> (%o2) b-a
>>
>>>  Obviously, the mathematically correct answer would read abs(b-a) or 
>>> abs(a-b).
>> Actually, this is not obvious.
>>
>> sqrt(a^2-2*a*b+b^2)  is a shorthand for one, or the other, or both,  
>> of the roots with respect to z of
>>
>> z^2=a^2-2*a*b+b^2.
>>
>> The values for z are  a-b     and b-a.
>> Note that neither of them is abs(a-b).
>
> I think people today don't like ambiguity.  abs(a-b) = 
> sqrt(a^2-2*a*b+b^2) can be thought of as an identity if you take just 
> the positive root, which is its appeal, I think.
abs(a-b) is a function of two variables which has many properties. Only 
some of them are shared
with the solution to that sqrt.
> You could do the same thing in other, maybe better ways, like using 
> %union().
Yes.
>   Personally I think %union() is better in cases like solve() and 
> abs(a-b) better in others when I want to cover all the possibilities 
> and I am not trying to present abs(a-b) as an answer to a question 
> like solve().  Just my 2 cents worth.
>
>
>> Each value for z is differentiable.   abs(a-b) is not.
>>
>
> diff(abs(x),x) =signum(x) except at 0 but then on the other hand at 0, 
> a equals b.  So what is wrong with that?
It's not differentiable at 0, and signum is discontinuous.  Even if you know
b-a >0  that does not make the correct general answer abs(b-a).
  One answer is still b-a, which happens to coincide with abs(b-a) when 
b-a>0.  Even if b-a<0,
the answer may STILL be b-a.  Note that 9 has 2 square roots, 3 and -3.  
Just because you made that 9 out of (-3)*(-3)  or 3*3,  it doesn't 
change the fact that 9 has 2 square roots.

If you know that sqrt()   represents a physical distance quantity, then 
you know the results is >=0.
In applications, that can be useful.  note that when sqrt comes out of 
the quadratic formula, there
are TWO roots.  separating them as symbolic entities is risky, since 
careless treatment of the
sqrt may change your situation so you have only one root, not two.

Historically, choosing the wrong sqrt has caused untold bugs in other 
programs like solve or
integrate, often "system independent" bugs that were exhibited in 
Mathematica, Maple, and others
at the same time.


RJF




>
>