A numerical approach to finding limits is indeed tricky. I was coding a
tacit version of
Arie's conjunction...

   (9!:11) 16 NB. Setting the print precision

   ( lim=. (@:(&(".@:('(0.5^i.1076)'"_)))) ({~ (1 i.~ (}. = }:) @:
(<.&.(1e11&*)))@:) )
(@: (&(".@:('(0.5^i.1076)'"_)))) (({~ (1 i.~ (}. =
}:)@:(<.&.(100000000000&*))))@:)
     NB. Uses the form (c a) ( see,
http://www.jsoftware.com/pipermail/programming/2013-February/031684.html )
     NB. Replacing (0.5^i.1076) by (".@:('(0.5^i.1076)'"_) to avoid a
humongous linear representation of lim

   (((4%~])* 3 o. 1r2p1 * 1-])) lim + 0 NB. OK
0.1591549430837225
   (((4%~])* 3 o. 1r2p1 * 1-])) lim - 0 NB. Wrong!
_6.596135044885868e_12

Changing slightly the definition does the trick in this instance...

   ( lim=. (@:(&(".@:('(0.5^i.1076)'"_)))) ({~ (1 i.~ (}. = }:) @:
(<.&.(1e10&*)))@:) )
(@: (&(".@:('(0.5^i.1076)'"_)))) (({~ (1 i.~ (}. =
}:)@:(<.&.(10000000000&*))))@:)

   (((4%~])* 3 o. 1r2p1 * 1-])) lim + 0 NB. OK
0.159154943061271
   (((4%~])* 3 o. 1r2p1 * 1-])) lim - 0 NB. OK
0.1591549430620842

Arie's conjunction behaves in the same manner...

   ( limit=: 2 :'({~1 i.~[:(}.=}:)<.&.(1e11&*)) u y v 0.5^i.1076' )
2 : '({~1 i.~[:(}.=}:)<.&.(1e11&*)) u y v 0.5^i.1076'

   (((4%~])* 3 o. 1r2p1 * 1-])) limit + 0 NB. OK
0.1591549430837225
   (((4%~])* 3 o. 1r2p1 * 1-])) limit - 0 NB. Wrong!
_6.596135044885868e_12

   ( limit=: 2 :'({~1 i.~[:(}.=}:)<.&.(1e10&*)) u y v 0.5^i.1076' )
2 : '({~1 i.~[:(}.=}:)<.&.(1e10&*)) u y v 0.5^i.1076'

   (((4%~])* 3 o. 1r2p1 * 1-])) limit + 0 NB. OK
0.159154943061271
   (((4%~])* 3 o. 1r2p1 * 1-])) limit - 0 NB. OK
0.1591549430620842

There are differences between the two forms though.  The former resolves
the verb...

   u lim v
({~ (1 i.~ (}. = }:)@:(<.&.(100000000000&*))))@:(u@:v&(".@:('(0.5^i.1076)'
"_)))

Whereas...

   u limit v
u (2 : '({~1 i.~[:(}.=}:)<.&.(1e10&*)) u y v 0.5^i.1076') v
... and, of course ;)

   u=. (4 %~ ]) * 3 o. (2 %~ o.1) * 1 - ]
   v=. +
   Y=. 0

   u lim v Y
0.1591549430837225

   u limit v Y
|stack error: v
|   ({~1 i.~[:(}.=}:)<.&.(10000000000&*))u y     v 0.5^i.1076


On Sat, Mar 2, 2013 at 3:25 AM, Aai <[email protected]> wrote:

> According to my description I have to formulate limit as follows:
>
> limit=: 2 :'({~1 i.~[:(}.=}:)<.&.(1e11&*)) u y v 0.5^i.1076'
>
> otherwise the values are cut off at 11 decimals.
>
> BTW 11 is a value obtained by experimenting with
>
>
> ((4%~])* 3 o. 1r2p1 * 1-])
>
> as input.
>
>
>
>
> On 01-03-13 20:20, km wrote:
>
>> That's pretty good!  Thank you, Arne.  --Kip
>>
>> Sent from my iPad
>>
>>
>> On Mar 1, 2013, at 6:45 AM, Aai <[email protected]> wrote:
>>
>>  Here's a conjunction with the choice of left/right approach.
>>>
>>> It's like Raul's approach except it uses a bit more values and it
>>> compares successive values up to a limited number of decimals.
>>>
>>> limit=: 2 :'({~1 i.~(}.=}:))<.&.((10^11)&*) u y v 0.5^i.1076'
>>>
>>> tests:
>>>
>>>    ((4%~])* 3 o. 1r2p1 * 1-]) limit + 0
>>> 0.159155
>>>    (_4 0 1&p.%_2 1&p.) limit + 2
>>> 4
>>>    (1&o.%]) limit + 0
>>> 1
>>>    % limit + 0
>>> _
>>>    % limit - 0
>>> __
>>>    %@^. limit + 0
>>> 0
>>>    %@^. limit - 0
>>> 0
>>>    %@^. limit + 1
>>> _
>>>    >. limit - 0
>>> 0
>>>    >. limit + 0
>>> 1
>>>
>>>
>>>
>>>
>>> On 28-02-13 22:28, km 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 <http://www.jsoftware.com/forums.htm>
>>>>>>
>>>>> ------------------------------**------------------------------**
>>>>> ----------
>>>>> For information about J forums see http://www.jsoftware.com/**
>>>>> forums.htm <http://www.jsoftware.com/forums.htm>
>>>>>
>>>> ------------------------------**------------------------------**
>>>> ----------
>>>> For information about J forums see http://www.jsoftware.com/**
>>>> forums.htm <http://www.jsoftware.com/forums.htm>
>>>>
>>> --
>>> Met vriendelijke groet,
>>> @@i = Arie Groeneveld
>>>
>>> ------------------------------**------------------------------**
>>> ----------
>>> For information about J forums see 
>>> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>>
>> ------------------------------**------------------------------**
>> ----------
>> For information about J forums see 
>> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>
>
> --
> Met vriendelijke groet,
> @@i = Arie Groeneveld
>
> ------------------------------**------------------------------**----------
> For information about J forums see 
> http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to