* Declare variables. INTEGER NCOEFF, STATUS, I, NSUBS REAL COEFF( NCOEFF ) CHARACTER * ( * ) EXPRS * Initialise the expression. EXPRS = '<next_term><coeff>'  * Substitute each coefficient value. DO 1 I = 1, NCOEFF CALL TRN_STOKR( 'coeff', COEFF( I ), EXPRS,  : NSUBS, STATUS ) * Expand the token representing the next term. IF( I .NE. NCOEFF ) THEN CALL TRN_STOK( 'next_term',  : '(<next_term><coeff>)*X+', : EXPRS, NSUBS, STATUS ) * Eliminate the final '<next_term>' token. ELSE CALL TRN_STOK( 'next_term', ' ',  : EXPRS, NSUBS, STATUS ) ENDIF 1 CONTINUE
<coeff>' token is substituted with a coefficient value (say 0.1) to give `
<next_term>' token is expanded to give `
(<next_term><coeff>)*X+0.1'. The process is then repeated to replace the `
<next_term><coeff>' part of this expression using the value of the next coefficient.
<next_term>' token is eliminated by replacing it with a blank string.
The effect of this algorithm with (say) the 5 polynomial coefficients 0.1, 0.12, 1.06, 4.4 & 1E7, would be to produce the following expression:
which casts the polynomial into a form for efficient evaluation using Horner's method.
TRANSFORM Coordinate Transformation Facility