Skip to content

Fast Fibbing

Vector 3:4, page 121

The text of this article is not yet online. No complete scan of this issue has been found. The only copy found, on vector.org.uk, is damaged: its page images are lost, but the text machine-read from them survives, shown below (help find a scan).

Unedited OCR text, machine-read from a scan now lost: it contains errors, and its APL is wrong. Shown for searching.

VECTOR Vol.3 No.4

More Fibbing

by Dr Alan Sykes

John Sullivan’s article VECTOR Vol.3, No.1), raises some important issues concerning APL and its relationship with other languages. APL provides only rather inefficient tools (some more inefficient than others!) for solving those computational problems typified by the Fibonacci sequence. The most natural method is to consider looping (or function recursion) and the search for alternative methods, whilst intellectually stimulating, often give computer scientists (justified?) cause for concern! After all, John Sullivan’s solution (FIB2) isn’t recursive, nor does it involve only integer arithmetic.

However, to avoid such criticisms completely, it would be necessary to write our program in machine-code ~ undoubtedly the best  language for recursive integer arithmetic! Many computer scientists would not readily follow this course, and clearly some compromise between the efficiency of the program execution and the efficiency of the program construction is usually made. What we APLers must do is to show our readiness to construct auxiliary processors for those applications which demand them, thereby showing our computer science colleagues that we can have our cake and eat it”. In a wider context of computing solutions to difference (or differential) equations, John Sullivan has a point. Numerical solution of even simple difference equations can be fraught with the likelihood of numerical instability. Hence, if an exact solution is known, this may lead to an efficient and error-free method of computation. In this context, FIB2 is a good solution. Incidentally, at the risk of invoking my own criticism, may I present an APL2 solution (which I hasten to add is much slower than FIB2). FIB3 calculates the first 2N Fibonacci numbers: VRSPIBS (1) Ae, (te.x\Woc2 26111 2)C,,27  This example is interesting in the context of becoming familiar with useful second- generation’ APL idioms, It is inefficient because the powers of the matrix 1 1 1 2 created by +ex\Wpe2 2p 1112 are not created recursively. The scan  operation \  operates recursively with some binary operations; for example +\1 10000 is much faster than =\t 10000 because +  is associative  whereas -  is not. Although +.x  is an associative operation on matrices, the APL2 interpreter does not recognise this and hence the inefficiency.

fam very grateful to John Scholes of Dyadic Systems for his helpful comments on FIB3 during APL’86 at Manchester.

121

APL CONSULTANTS LONDON & READING

Account Managers (6 yearst) 25K

(4-6 years} to 21K

Consultants (2-4 years) to 17K (1-2 years) to 13K Senior Consultants

Junior Consultants

Are your APL skills and potential being recognised and rewarded? Cocking & Drury consultants have been implementing successful decision support applications for 10 years, with clients who appreciate the productivity e nefits of APL. In our professional team you will experience a range of APL environments - APL*Plus, VSAPL, APL2 and Unix, on both mainframes and micros. You will also be developing systems which, increasingly, need to interface with non-APL Information Centre products. Of course as the leading APL consultancy, in a rapidly expanding market, we offer a rewarding career with first class benefits - profit sharing, free health insurance, and a non‘contributory pension.

ee ee OCR Ae UN CA aon Are oer =3==— COCKING &DRURY LID. 155 Friar Street, Reading, RG] JHE