MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Wanted: a trick

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3933] Re: Wanted: a trick
  • From: rhall2 at umbc.edu (hall robert)
  • Date: Fri, 10 May 1996 03:30:16 -0400
  • Organization: University of Maryland, Baltimore County
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4m7q5d$k5h at dragonfly.wolfram.com>,
Robert Knapp  <rknapp at wolfram.com> wrote:
>Jinchul Park wrote:

>> a = b =  Exp[1 + 1.234 k] (k is a variable).
>> 
>> I want to find t by dividing a by b such as
>> 
>>                          0. k
>> t = a/b.  What I get is E.    How come the result is NOT '1' ?  In other
>> 
>> words, why '0. k' is not calculated as '0'?
>> 
>Mathematica keeps track of the difference between exact zeros (0) and
>inexact zeros (0.).  Since inexact zeros may be the result of roundoff
>or other approximate number errors, they are not made to be equal to and
>exact zero by default.
>
>> Is there any way to make 0. k as 0?
>> 
>Yes,  The simplest way to convert inexact zeros to exact zeros is with
>the command Chop[]:
>
>In[1]:= a = b =  Exp[1 + 1.234 k]
> 
>         1 + 1.234 k
>Out[1]= E
> 
>In[2]:= a/b
> 
>         0. k
>Out[2]= E
> 
>In[3]:= Chop[%]
> 
>Out[3]= 1
> 
>
>> Also, in a simple symbolic calculation, 1.5 k - 1.5 k = '0. k' not '0.'  On
>> 
>> the other hand, k - k = '0.'  Would you tell me what I need to do to get
>> 
>> just '0' instead of '0. k'?
>> 
>
>In[4]:= 1.5 k - 1.5 k
> 
>Out[4]= 0. k
> 
>In[5]:= Chop[%]
> 
>Out[5]= 0

Factor[] and Together[] also work. But Chop[] may cut more Gordian knots.

-- 
Bob Hall            | "Know thyself? Absurd direction!
rhall2 at gl.umbc.edu  |  Bubbles bear no introspection."  -Khushhal Khan Khatak

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Operator overloading with Symbol tags: Correction!
  • Next by Date: Re: Mathematica R^2 value
  • Previous by thread: Wanted: a trick
  • Next by thread: MathLink and Pascal ?