Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!utcsri!rpi!zaphod.mps.ohio-state.edu!uunet.ca!unixbox!telly!moore!torsqnt!jtsv16!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: Tacit numerical integration?
Message-ID: <1992Oct24.192342.2201@yrloc.ipsa.reuter.COM>
Organization: Iverson Software Inc.
References: <16223@umd5.umd.edu>
Date: Sat, 24 Oct 92 19:23:42 GMT
Lines: 76

Pat Harrington writes:
 
> ... This makes me think that one should be able to construct
> a conjunction X such that f (h X) n would take one step of
> Runga-Kutta integration, say, from x to x+h, where the
> function f describes the differential equation.  But to
> start with something simpler, suppose you only want x ->x+h
> and y->y+h*(dy/dx). Assume the equation is (dy/dx)= -x*y,
> which has the solution y(x) = const exp(-x^2/2). Then I may define
>    f=. 1&,@-@*/
> so that f (x y) will yield (1 dy/dx). Then if I define
>    S=. ([. (&*))@ ].
> I find that f (h S) (x y) will yield (h, h*dy/dx). So defining
>    Z=. f (h S) + ]
> I have a function Z such that Z n takes one integration step: ...
 
> ... But this is not what I want. I would like a conjunction X
> so that (h X) is an adverb, and f (h X) n is the integration step.
 
It may be helpful to look at the linear representation of Z:
 
   lr=.5!:5
   lr <'Z'
0.001&*@f + ]
 
If x. is 0.001 and y. is f, then the desired computation is x.&*@y. + ] .
The tacit translator :12 can be used to obtain the answer:
 
   RK=.'x.&*@y. + ]' : 12
   RK
+------------+---------+-+
|+-----+-+--+|+-+-----+|\|
||+-+-+|@|].|||`|+-+-+|| |
|||&|*|| |  ||| ||+|]||| |
||+-+-+| |  ||| |+-+-+|| |
|+-----+-+--+|+-+-----+| |
+------------+---------+-+
   lr <'RK'
(&*) @ ]. (`(+`])) \
   Z1=.h RK f
   lr <'Z1'
0.001&*@f + ]
   Z1^:1000 (0 10)
1 6.06733
   h RK f^:1000 (0 10)
1 6.06733
 
Some may prefer to skip the explicit form and the tacit translator
altogether and proceed directly to (&*)@]. (`(+`])) \ .
 
> ... And of course, in tacit form. This is supposed to be a
> *good thing*, although just why this is so is not yet clear to me.
 
Some advantages are:

0) The tacit form encourages the use of components, primitive and 
user-defined.  Use of components is one of the few effective ways of 
dealing with complexity.
1) The tacit form focuses on how components are combined, i.e. it focuses
on the interface between components, where errors tend to occur.
2) Tacit expressions are algebraic, i.e. they are amenable to proof
and other formal manipulations.
3) Tacit expressions are constructed using operators (adverbs and
conjunctions), ideas debugged in mathematics over hundreds of years.
 
> But it strikes me that a fourth order Runge-Kutta formula
> in tacit J could be a very ugly beast. And this is a concern,
> that on any non-trivial problem, finding the tacit forms may
> be too hard to be worthwhile.
 
I do not believe it is necessarily ugly, at least not if there is
judicious use of well-chosen subfunctions.

------------------------------------
Roger Hui, Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
Phone: (416) 925 6096;  Fax: (416) 488 7559
