Leigh wrote:

>  By the way, I've never seen 1x1 as exponential notation.
>  Where in the help files is that described?

Constant notation is described in full here:

     http://www.jsoftware.com/help/dictionary/dcons.htm

It's linked to from the Vocabulary, under the word "Constants".

>  It seems to imply that the delta-x of the D. operator can 
>  be specified.

The "finer grained" was not referring to how the lngamma operates, but how it 
is generated.

The script was primarily a demonstration of code generation in J.  By itself, 
it will not help you work around the limitations of  D.  .  

Concretely:  the function  lngamma =: ^.@:!@:<:  is composed of 3 parts: ln, 
gamma, and decrement.  Each of those components can be formulated in different 
ways.  The comments you quoted will take sets of alternate formulations for 
those components, and generate all possible combinations of them.

The idea is that if  D.  doesn't work well on, for example,  !  , then you can 
define gamma differently  , in a way that  D.  likes better (see the last part 
of this message).   

You did a bit of this manually:

>  Trigamma was a little better if I defined it 
>  as D.1 of digamma than as D.2 of lngamma.

The purpose of the rest of the script is to automate this process, and to be 
comprehensive about it.  

The script will combine all your different formulations in every way possible, 
and then automatically choose the best combination.  No manual trial-and-error 
or user inspection will be required.  If two combinations give equally good 
results, the fastest and cheapest will be chosen.

The script defines "good" and "best" with your test data and your fitness 
function.  In my case, my test data was just some random result from the set of 
all possible results.   Your test data should be whatever you want the result 
to actually be (probably generated by Excel).  

Similarly, my fitness function was simply "-:";  being in the numbers game, you 
can probably come up with something better.   Maybe an error function, or, 
e.g., testing whether the result is within  X  stddevs of the target.

Now, regarding: 

>  Could I then increase the accuracy of the calculations by
>  asking J to differentiate over more (and more finely grained) 
>  points?

I don't believe you can control  D.  that way.  But, if I understood John 
Randall's explanation of numerical differentiation at last night's JUG, then 
you might be able to do so with  D:  (colon, not dot).

    http://www.jsoftware.com/help/dictionary/ddcapco.htm


That primitive lets you calculate the secant-slope and lets you control the 
points by which it's calculated.  Does that help?  

Another tack to try:  if I read the documentation right, then  D.  calculates 
derivatives symbolically for polynomials and taylors.  Could you reformulate  
^.  or  !  or both using, say,  one of the p.  or  t.  family?  Could you do so 
if you restricted your input to a significant subdomain?  

But now I'm just talking out of my rear.  I should (and now will) leave these 
numerical questions to the mathematicians.  Or at least the people who remember 
how derivatives work.

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to