sqrt vs ^0.5



On 11/10/2011 9:30 AM, cheater cheater wrote:
> Hi Rene,
> they do:
>
> (%i1) sqrt(0.1)-sqrt(1/10);
> (%o1)                    .3162277660168379 - 1/sqrt(10)
> (%i2) ev(sqrt(0.1)-sqrt(1/10),numer);
> (%o2)                                 0.0
>
> You just have to invoke numeric evaluation.
>
> Hope this helps

Actually, 0.1 is not equal to 1/10.

0.1  is a floating point number which is converted to double-float 
binary, in which internal form it is
exactly equal to 3602879701896397/2^55.

This is NOT exactly equal to 1/10. They differ by 1/180143985094819840 
or   1/(5*2^55).

The only way 0.1 - 1/10 is computed as zero is if the user forces exact 
numbers be converted to nearby floating-point numbers.  In this case the 
two values coincide.






> On Thu, Nov 10, 2011 at 17:51, rene kaelin<renekaelin at gmx.ch>  wrote:
>> Dear maxima users
>> Why don't both expressions simplify to zero?
>> (%i1) sqrt(0.1)-sqrt(1/10);
>> (%o1) .3162277660168379-1/sqrt(10)
>> (%i2) 0.1^0.5-(1/10)^0.5;
>> (%o2) 0.0
>> Manual:
>> Function: SQRT (X)the square root of X. It is represented internally by
>> X^(1/2). Also see ROOTSCONTRACT. RADEXPAND[TRUE] - if TRUE will cause nth
>> roots of factors of a product which are powers of n to be pulled outside of
>> the radical, e.g. SQRT(16*X^2) will become 4*X only if RADEXPAND is TRUE.
>> Maxima version: 5.21.1Maxima build date: 16:28 5/16/2010Host type:
>> i686-apple-darwin10.3.0Lisp implementation type: SBCLLisp implementation
>> version: 1.0.38
>>
>>
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima