Download GENTRAN User`s Manual REDUCE Version

Transcript
6 EXAMPLES
62
• value type: integer
• default value: 40
MINPASCLINELEN!*
• minimum number of characters printed on each line of generated PASCAL code after indentation.
• value type: integer
• default value: 40
6
Examples
Short examples have been given throughout this manual to illustrate usage
of the GENTRAN commands. This section gives complete code generation
examples.
6.1
Interactive Code Generation
Suppose we wish to generate a FORTRAN subprogram which can be used for
computing the roots of a polynomial by Graeffe’s Root-Squaring Method8 .
This method states that the roots xi of a polynomial
Pn (x) =
n
X
ai xn−i
i=0
can be found by constructing the polynomial

‘

Pn∗ x2 = a0 xn + a2 xn−2 + . . .
‘2

− a1 xn−1 + a3 xn−3 + . . .
‘2
with roots x2i When read into REDUCE, the following file of REDUCE
statements will place the coefficients of Pn∗ into the list B for some userentered value of n greater than zero.
Contents of file graeffe.red:9
8
This is for instance convenient for ill-conditioned polynomials. More details are given
in Introduction to Numerical Analysis by C. E. Froberg, Addison-Wesley Publishing Company, 1966.
9
In accordance with section 2.5, the subscripts of A are I+1 instead of I.