I think the machine epsilon concept http://en.wikipedia.org/wiki/Machine_epsilon#Formal_definition )
is related to this thread discussion... (%&2^:(1 (~:!.0) 1 + %&2)^:_)1 NB. 2^_52 as expected 2.22044605e_16 On Fri, Mar 1, 2013 at 8:50 AM, Raul Miller <[email protected]> wrote: > For readers following along: > > IEEE 754 is a decent search term. > > Or, at least, it is for me - Google apparently customizes search > results so I cannot know for sure that they give good, relevant > results for everyone searching on that phrase (nor can I be sure > whether anyone I care about will get different results from > me).http://steve.hollasch.net/cgindex/coding/ieeefloat.html > > Here are my top four hits when I search for IEEE 754 today: > > http://en.wikipedia.org/wiki/IEEE_floating_point > http://grouper.ieee.org/groups/754/ > http://steve.hollasch.net/cgindex/coding/ieeefloat.html > http://babbage.cs.qc.cuny.edu/IEEE-754/ > > But the short form is: IEEE 754 splits the representation of a number > into a sign (+1 or _1 -- one bit), an exponent and a mantissa. There > are actually several IEEE 754 representations, and current J > implementations use the 64 bit representation. The 64 bit > representation uses 52 bits to represent the mantissa (a number > between 1 and 2, or equal to 1), and and the remaining 11 bits > represent the exponent (a power of 2). In operation we act as though > these elements are multiplied together. > > Obviously, there are some exceptions to the above summary. Without > any exceptions this mechanism could not represent 0. So the lowest > and the highest exponents get treated specially, which is where we get > J's inconsistent numbers (_ __ _.). > > Rather than describe the details of what's going on in deeper detail, > here, I'll let you read other materials. > > FYI, > > -- > Raul > > On Thu, Feb 28, 2013 at 6:11 PM, km <[email protected]> wrote: > > I remember that comparisons with 0 are exact > > > > 0 = N - N + epsilon > > 0 0 0 0 0 0 0 1 1 > > > > which agrees with your first report. No, I am unfamiliar with the IEEE > structure, and am surprised by these results. > > > > --Kip > > > > Sent from my iPad > > > > > > On Feb 28, 2013, at 4:21 PM, Raul Miller <[email protected]> wrote: > > > >> Are you familiar with the structure of IEEE 754 floating point numbers? > >> > >> Consider, for example: > >> > >> epsilon=: 2^_44 > >> N=: 10^i:4 > >> > >> NB. this result reflects IEEE-754's structure > >> *N+epsilon-N > >> 1 1 1 1 1 1 1 0 0 > >> > >> NB. this result reflects J's heuristic to deal with that structure > >> N=N+epsilon > >> 0 0 0 0 1 1 1 1 1 > >> > >> FYI, > >> > >> -- > >> Raul > >> > >> On Thu, Feb 28, 2013 at 4:28 PM, km <[email protected]> wrote: > >>> Here is what I did > >>> > >>> NB. right hand limit of a function > >>> > >>> lim =: 1 : 0 > >>> value =. u y + (2^_44) > >>> if. value <: - 2^40 do. __ > >>> elseif. value >: 2^40 do. _ > >>> elseif. do. value > >>> end. > >>> ) > >>> > >>> It does "reasonably well" but can be fooled, for example > >>> > >>> ] lim 2^40 > >>> _ > >>> > >>> Here it does better > >>> > >>> *: lim 1000 > >>> 1000000 > >>> > >>> dq =: 1 : (':'; 'y %~ (u x+y) - u x') NB. difference quotient > >>> > >>> 2&(^&3 dq)lim 0 NB. derivative of x^3 at 2 is 12 > >>> 12 > >>> > >>> --Kip > >>> > >>> Sent from my iPad > >>> > >>> > >>> On Feb 28, 2013, at 7:19 AM, Raul Miller <[email protected]> > wrote: > >>> > >>>> Here's a model implementation: > >>>> > >>>> lim=: (1 :0)("0) > >>>> tests=. u ((1e_6*1>.|y)*0.5^i.1000)+y > >>>> tests {~{.I.((1 }. 0&~:) * 2 ~:/\ ])(,2:)(*!.0)2 -/\ tests > >>>> ) > >>>> > >>>> My assumptions are: > >>>> > >>>> (1) the limit in question is relatively stable (that my choices for > >>>> epsilon are adequate) > >>>> > >>>> (2) that the result of limit should be a consistent number. > >>>> > >>>> Note that (2) means that _ and __ will typically not be returned, > >>>> since they are inconsistent numbers (but, since they are inconsistent, > >>>> it's impossible to make an entirely consistent guarantee about their > >>>> treatment). > >>>> > >>>> (1&o.%]) lim 0 > >>>> 1 > >>>> % lim 0 > >>>> 2.67877e306 > >>>> -@% lim 0 > >>>> _2.67877e306 > >>>> > >>>> For my purposes, these "e306" values are close enough to infinity to > >>>> be treated as such. > >>>> > >>>> Note also that I'm probably being a bit too aggressive with the number > >>>> of epsilon values I'm using. > >>>> > >>>> If you really want _ and __ results, you could use something like > this: > >>>> > >>>> lim=: (1 :0)("0) > >>>> tests=. u ((1e_6*1>.|y)*0.5^i.1000)+y > >>>> 1e_3*1e3* tests {~{.I.((1 }. 0&~:) * 2 ~:/\ ])(,2:)(*!.0)2 -/\ tests > >>>> ) > >>>> > >>>> However, note that this is a heuristic and its ability to force the > >>>> result to be an inconsistent infinity depends on the stability u (and > >>>> also depends on the actual limit value). I place less faith in this > >>>> mechanism than in the ability of the user to recognize that the result > >>>> should be thought of as infinite (and if the user does not understand > >>>> what's going on well enough to make that determination it's hard to > >>>> imagine how this distinction could be useful). > >>>> > >>>> FYI, > >>>> > >>>> -- > >>>> Raul > >>>> > >>>> On Wed, Feb 27, 2013 at 10:55 PM, km <[email protected]> wrote: > >>>>> Can you write an adverb lim so that > >>>>> > >>>>> sin =: 1&o. > >>>>> > >>>>> (sin % ])lim 0 > >>>>> 1 > >>>>> > >>>>> % lim 0 NB. limit is from right > >>>>> _ > >>>>> > >>>>> -@% lim 0 > >>>>> __ > >>>>> > >>>>> > >>>>> Kip Murray > >>>>> > >>>>> Sent from my iPad > >>>>> > >>>>> > ---------------------------------------------------------------------- > >>>>> For information about J forums see > http://www.jsoftware.com/forums.htm > >>>> ---------------------------------------------------------------------- > >>>> For information about J forums see > http://www.jsoftware.com/forums.htm > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
