Raul, I have modified your adverb lim as follows:
limr =: 1 : 0
lastgood =. ] {~ 0 i:~ 0 = y - y + ]
u y + lastgood (1e_6*1>.|y)*0.5^i.1000
)
% limr 0
5.35754303593134e306
NB. _
>. limr 0
1
NB. 1
<. limr 0
0
NB. 0
%@^. limr 1
4.5035996273705e15
NB. _
%@^. limr 0
_0.00141589002185362
NB. 0
((4%~])* 3 o. 1r2p1 * 1-]) lim 0
0.15915494306771
NB. 0.159154943091895
(_4 0 1&p.%_2 1&p.) limr 2
4
NB. 4
(1&o.%]) limr 0
1
NB. 1
--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