restart:# HORNER'S ALGORITHM 2.7## To evaluate the polynomial# p(x) = a(n) * x^n + a(n-1) * x^(n-1) + ... + a(1) * x + a(0)# and its derivative p'(x) at x = x0:## INPUT: degree n: coefficients aa(0),aa(1),...,aa(n):# value of x0.## OUTPUT: y = p(x0), z = p'(x0).print(`This is Horners Method\134n`):OK := FALSE:while OK = FALSE doprint(`Input degree n of polynomial - no decimal point\134n`):N := scanf(`%d`)[1]:print(`Degree = `):print(N):if N < 0 thenprint(`Incorrect input - degree must be nonnegative.\134n`):elseOK := TRUE:fi:od:print(`Input coefficients of P(X) in ascending order\134n`):for I1 from 0 to N doprint(`Input coefficient of X with exponent `, I1):AA[I1] := scanf(`%f`)[1]:print(`Coefficient = `):print(AA[I1]):od:print(`Input argument X0 at which to evaluate P(X)\134n`):X0 := scanf(`%f`)[1]:print(`Evaluate at x = `):print(X0):# Step 1# Compute b(n) for p(x)Y := AA[N]:# Compute b(n-1) for p'(x)if N = 0 thenZ := 0:elseZ := AA[N]:fi:MM := N-1:# Step 2for I1 from 1 to MM doJ := N-I1:# Compute b(j) for p(x)Y := Y*X0+AA[J]:# Compute b(j-1) for p'(x)Z := Z*X0+Y:od:# Step 3# Compute b(0) for p(x)if N <> 0 thenY := Y*X0+AA[0]:fi:print(`Coefficients of polynominal P :\134n`):# Step 4for I1 from 0 to N doprint(`Exponent = `,I1,` Coefficient = `, AA[I1]):od:print(`\134n P evaluated at x = `, X0,` is `, Y):print(` P' evaluated at x = `, X0,` is `, Z):JSFH