The Many Ways of Sine

Raul Deluth Miller rockwell@nova.umuc.edu
Fri, 23 Jun 1995 20:36:18 -0400


I've been fairly inactive on this list for some time.  I'll probably
continue to be so but I thought I should step in and say a few words.

First, I have a shade of agreement with the LLL-ish people who are
grumping about the fluidity of the entire system.  I might have missed
it, but it seems that at present there's no interfaces for a LLL to
use.  That means that there's nothing to implement at present.

Second, for your entertainment and amusement, here's a recent post on
the language J (a branch off the same tree as K -- they differ in that
K has explicit lambda expressions while J has an operator grammar).
I'll include a glossary at the end of this letter.

Newsgroups: comp.lang.apl
From: Roger Hui <hui@Soliton.COM>
Date: Sun, 18 Jun 1995 06:12:02 GMT
Lines: 40

How many ways can the sine function be computed in J?
Let me count the ways.  (Non-exhaustive list.)

1&o.    
   We begin with the sine qua non ;-) of any such list, 
   the circle function with a fixed left argument of 1.

2&o. * 3&o.
   Cosine times tangent.

5&o.&.j.
   Sinh under (dual with respect to) multiplication by 0j1.

^ .: - &.j.
   Odd function of exponentiation with negation, under multi-
   plication by 0j1.

0j2"_ %~ ^@j. - ^@-@j.
   A restatement of same.

* '' H. 3r2@(_1r4&*)@*:
   The phrase '' H. 3r2 is limit of the the hypergeometric 
   series with upper parameter the empty vector and 
   lower parameter the number three-halves.

-@(2&o.)"0 D. 1
   The derivative of minus cosine.

2&o."0 D. _1
   The integral of cosine.  (Not yet implemented.)

-.&.*:@(2&o.)
   The square root of one minus cosine squared.  
   (Restricted domain.)

(0&o.)@(2&o.)
   A restatement of same.

[ ` (! %~ 4&| { 0 1 0 _1"_) t. T. _
  Limit of Taylor approximation with specified coefficients.

----------------------------------------------------------------------

o. 	a trancendental math library, significant entries:
	0	square root of 1 - argument
	1	sine
	2	cosine
	3	tangent
	5	sinh
	[there are other "better" ways of obtaining all of these, so
	these are not proper members of the language.]

	-- left argument is library entry number
	-- right argument is argument to specified library function

	grammar: dyadic 
	parsing priority: low .. right to left

&	bind (a curry operator)

	grammar: dyadic -- one argument is a dyadic function word with
	lower priority, the other argument is the datum to apply as
	the corresponding positional argument
	parsing priority: high .. left to righ

	Special case: if both arguments are function words, the left
	one is a dyadic function word, and the right one is a monadic
	function word.  both arguments to the dyadic function word are
	pre-processed by the monadic function word.

*	multiplication

	grammar: dyadic
	parsing priority: low .. right to left

^	exponentiation

	left argument, if present is base (default is the natural
	logarithm base)

	right argument is exponent.

	grammar: dyadic 
	parsing priority: low .. right to left

	grammar: monadic
	parsing priority: low .. right to left


.:	odd operator

	derives an odd function from two monadic functions.   f .: g
	of y is (f(y) - f(g(y)))/2

j.	multiply by square root of -1

	grammar: monadic
	parsing priority: low .. right to left

0j2	a number (2 times the square root of -1)

	grammar: data
	parsing priority: 0

"	rank operator

	There are two classes of use of this in the above code.  "_ is
	is used to specify a constant function (where the number(s) to
	the left of the double quote are the literal value of that
	funcction). "0 is used to specify an implicit loop.  the
	function to the left of the double quote is applied inside an
	inner loop over any arguments.  [You can ignore this effect
	for the case where only one argument is considered --
	otherwise, think of it as being analogous to mapcar.]

	grammar: dyadic
	parsing priority: high .. left to right

At this point, I've probably lost most of the audience, so I'm only
going to do a quick summary of the rest:

%	division
@	monadic function on left postprocesses function on right
~	cross left argument to derived function is used as right
	argument to word on left of ~
_	infinity (a number)
''	an empty list (in this case, a list without any characters)
H.	hypergeometric series operator (think bessel series, ...)
3r2	the rational number 3/2
_1r4	the rational number (-1)/4
*:	square operator f(x) = x*x
D.	the derivative operator   f D. 1 is the first derivative of f
-.	predefined function for 1 - y
[	left identity function
!	! binomial combinations (related to factorial) function

t. or T. is a taylor series operator (takes a function and computes
its taylor series equivalent), but I don't remember the details, and
my freeware version of j doesn't have this implemented yet, and it's
too much trouble to look it up, and probably no one is all that
interested in the details anyways...

Later,

-- 
Raul