9!:3]5

   pwr =. ^~   NB. this is y to the power x (dyadic tacit verb)
   recip =. %@ pwr  NB. take the reciprocal
   zeta =. +/"_ @: recip NB. sum all
   zeta f.
+/"_@:(%@(^~))

Looking at that, it can be simplified, slightly as:
   +/@:%@:^~

To illustrate this, we can compare the results of this version with your
original:

   2 (+/@:%@:^~ -: zeta) i.100
1

And you have a few other replies, so I'll stop here. (But of course, like
any mathematical expression, there's a variety of other ways of expressing
the concept.)

Thanks,

-- 
Raul



On Sun, Mar 9, 2014 at 1:49 PM, Jon Hough <[email protected]> wrote:

>
> Ah, I see what's happened.z should be recipSorry.
> It should be: zeta =. +/"_ @: recip NB. sum all> From:
> [email protected]
> > Date: Sun, 9 Mar 2014 13:41:18 -0400
> > To: [email protected]
> > Subject: Re: [Jprogramming] Zeta Function as Tacit Verb
> >
> > But what is z?
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Sun, Mar 9, 2014 at 1:38 PM, Jon Hough <[email protected]> wrote:
> >
> > > Sorry, The verb zeta is dyadic.for example 2 zeta i.100 gives an
> > > estimation of the functionzeta(x), for x =2,where zeta(x) is the
> Riemann
> > > zeta function defined for positive integers > 1.
> > >
> > > > From: [email protected]
> > > > Date: Sun, 9 Mar 2014 13:32:54 -0400
> > > > To: [email protected]
> > > > Subject: Re: [Jprogramming] Zeta Function as Tacit Verb
> > > >
> > > > Hypothetically speaking, you can get J to tell you how to build
>  tacit
> > > verb.
> > > >
> > > > Practically speaking... here's the definitions you gave:
> > > >
> > > > pwr =. ^~   NB. this is y to the power x (dyadic tacit verb)
> > > > recip =. %@ pwr  NB. take the reciprocal
> > > > zeta =. +/"_ @: z NB. sum all
> > > >
> > > > And here's how I would examine them:
> > > >
> > > > First, enable linear represenation of verbs:
> > > >
> > > >    9!:3]5
> > > >
> > > > Second, resolve the names in your definition:
> > > >
> > > >    zeta f.
> > > > |value error: z
> > > >
> > > > (oops)
> > > >
> > > > It looks like you left out a part of your definition. I've not worked
> > > with
> > > > zeta before, and I don't actually know which zeta function you were
> > > trying
> > > > to compute. At a guess, though, you were using one that happens to
> work
> > > > nicely with this kind of implementation.
> > > >
> > > > If you could supply the rest of the definition, though, I think one
> of us
> > > > could go into how it works.
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > Raul
> > > >
> > > >
> > > >
> > > > On Sun, Mar 9, 2014 at 1:22 PM, Jon Hough <[email protected]>
> wrote:
> > > >
> > > > > I have created a tacit verb to calculate the Zeta function for any
> > > integer
> > > > > greater than 1.
> > > > > http://mathworld.wolfram.com/ZetaFunction.html
> > > > > My verb was built up step by step as follows:
> > > > > pwr =. ^~   NB. this is y to the power x (dyadic tacit verb)
> > > > > recip =. %@ pwr  NB. take the reciprocal
> > > > >  zeta =. +/"_ @: z NB. sum all
> > > > >
> > > > > I tested it
> > > > > 2 zeta >: i.100
> > > > > 1.63498
> > > > > This seems about right (should be about pi*pi/6)
> > > > > My first question is: I would like to make my verb in only one
> line,
> > > not
> > > > > using my step-by-step approach. But every time I tried this I got
> all
> > > kinds
> > > > > of errors or the calculation results were hopelessly wrong. How
> can I
> > > write
> > > > > this verb in a single line?
> > > > > Secondly, I'm still not entirely sure how this works.
> > > > > If I do 2 pwr 3 then that is 3*3, which is fine, but then doing
> "recip"
> > > > > afterwards, I'm not sure how J parses the recip verb as monadic (it
> > > takes
> > > > > the reciprocal instead of "2 over". How does J do this?
> > > > > Lastly, I am not sure why I needed to make +/ to be rank _. That
> was
> > > just
> > > > > a guess. Why is this? I understand it is the way @: and @ interact
> > > with the
> > > > > verbs but I'm struggling to see the cause.
> > > > > Thanks.
> > > > > Jon
> > > > >
> ----------------------------------------------------------------------
> > > > > 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

Reply via email to