[Jprogramming] Tacit series
Roger Hui
rogerhui.canada at gmail.com
Sun Dec 22 15:50:49 UTC 2013
A while loop can be effected tacitly by f^:g^:_, which says do f while g is
true. Therefore,
g=: , %@!@#
g ''
1
g g ''
1 1
g g g ''
1 1 0.5
g^:10 ''
1 1 0.5 0.166667 0.0416667 0.00833333 0.00138889 0.000198413 2.48016e_5
2.75573e_6
g^:10 ]0$1x
1 1 1r2 1r6 1r24 1r120 1r720 1r5040 1r40320 1r362880
c=: 3 g@]^:(p.~ ~: (p.~g))^:_ ''
c
1 1 0.5 0.166667 0.0416667 0.00833333 0.00138889 0.000198413 2.48016e_5
2.75573e_6 ...
$ c
24
3 p.~ c
20.0855
3 p.~ 3 g@]^:(p.~ ~: (p.~ g))^:_ ''
20.0855
exp=: ] p.~ ] g@]^:(p.~ ~: (p.~ g))^:_ i. at 0:
exp 3
20.0855
^3
20.0855
exp 3j4
_13.1288j_15.2008
^3j4
_13.1288j_15.2008
I expect exp can be improved. The details are left as an exercise for the
reader. :-)
On Sun, Dec 22, 2013 at 12:27 AM, km <km at math.uh.edu> wrote:
> 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list