[Jprogramming] Tacit series
km
km at math.uh.edu
Sun Dec 22 08:27:28 UTC 2013
Thanks, Raul, for a cool solution. I'm still interested in tacitly terminating a series when its partial sums stop changing. --Kip
Sent from my iPad
> On Dec 22, 2013, at 12:34 AM, Raul Miller <rauldmiller at gmail.com> wrote:
>
> ^ 2
> 7.38906
> (%!i.40) p. 2
> 7.38906
> (^ = (%!i.40)&p.) 0j1p1
> 1
>
> I'd just use ^
>
> --
> Raul
>
>> On Sat, Dec 21, 2013 at 5:43 PM, km <km at math.uh.edu> wrote:
>> Verb exp below uses the series for monadic ^ to calculate ^ y . Can you remind me how to do exp tacitly? You may omit the "clean" part. Verb clean replaces tiny real numbers by 0 .
>>
>> clean =: (* *!.1e_14@|)"0&.+.
>>
>> exp =: 3 : 0
>> os =. 0
>> s =. 1
>> k =. 0
>> t =. 1
>> while. s ~: os do.
>> os =. s
>> k =. >: k
>> t =. t * y % k
>> s =. s + t
>> end.
>> clean s
>> )
>>
>> exp 1
>> 2.71828
>>
>> ^1
>> 2.71828
>>
>> exp 0j1p1
>> _1
>>
>> ^ 0j1p1
>> _1j1.22465e_16
>>
>> (^0j1p1) = exp 0j1p1
>> 1
>>
>> VERSION NB. iPad
>> 1.3 5
>>
>> --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
More information about the Programming
mailing list