[Mg3897] Re: Wanted: a trick
- To: mathgroup at smc.vnet.net
- Subject: [Mg3897] Re: Wanted: a trick
- From: Robert Knapp <rknapp>
- Date: Sat, 4 May 1996 23:23:52 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
Jinchul Park wrote: > > Hello, Experts: > > I'd like to ask you a very simple question. I know it seems dumb, but > please help me to have the answer to the question. > > *********************** > My problem is > > 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 I hope this clears up the confusion. -- Rob Knapp Wolfram Research, Inc. http://www.wri.com/~rknapp ==== [MESSAGE SEPARATOR] ====