Problem 519923 · easy · Level 05 Advanced Algorithms & Graphs

A Gain Around the Loop

closed loop · characteristic polynomial · transfer function · proportional control · delay

A conveyor belt's motor drive is a discrete system with transfer function G(z) = B(z) / A(z): as in Level 4, b and a are coefficient lists in the one-sample delay z^-1, constant term first, so the drive obeys

a[0]*y[k] + a[1]*y[k-1] + a[2]*y[k-2] + ... = b[0]*u[k] + b[1]*u[k-1] + ...

with y the belt speed and u the drive voltage. A proportional controller closes the loop: u[k] = K * (r[k] - y[k - d]), where r is the wanted speed and d >= 0 is the number of samples the speed sensor and the computer take to report (a delay of z^-d). The loop's transfer function from r to y is

            K z^-d B(z)
T(z) = ---------------------
        A(z) + K z^-d B(z)

Its denominator is the loop's characteristic polynomial: its roots are the closed loop's poles, and they, not the plant's own poles, decide whether the belt settles, rings or runs away.

Write closed_loop_poly(a, b, K, d) that returns the coefficient list of A(z) + K z^-d B(z): multiplying by z^-d shifts b right by d places (put d zeros in front), then add it, times K, to a coefficient by coefficient, padding the shorter list with zeros. The result has max(len(a), len(b) + d) entries; keep every one, zeros included.

Read as a polynomial in z with the highest power first, the same list gives the poles: [1, -0.5] is z - 0.5, a pole at 0.5.

Examples

Input:  a = [1, -0.9], b = [0, 0.2], K = 2, d = 0
Output: [1, -0.5]
Explanation: (1 - 0.9 z^-1) + 2 * (0.2 z^-1) = 1 - 0.5 z^-1: one pole at 0.5, faster than the
plant's own pole at 0.9.

Input:  a = [1, -0.9], b = [0, 0.2], K = 2, d = 1
Output: [1, -0.9, 0.4]
Explanation: the delay shifts b to [0, 0, 0.2]. Now z^2 - 0.9 z + 0.4 has a pair of complex poles
of radius sqrt(0.4) = 0.63: the same gain now makes the belt speed ring.

Constraints

  • answers are compared with a tolerance of 1e-6

Goals

  • Close a loop around a plant B(z)/A(z) with a proportional gain K
  • Write the closed loop's characteristic polynomial A(z) + K z^-d B(z) as a coefficient list
  • See how a delay in the loop raises the polynomial's order, and so adds poles
Starting Python…