The following fraction "pol" has quadratic terms in k and constant terms in both the numerator and the denominator.
pol = (k^2 (-5 + 2 t) (1 + 2 t) + 3 (-4 + t^2))/(3 + 4 k^2)
To ensure that the value of pol is constant, the ratios of the corresponding coefficients of the quadratic terms in k in the numerator and denominator must be equal.
Under this guiding principle, how can we use code to automatically extract the relevant coefficients and derive the following equation, without manual copy-pasting?
((-5 + 2 t) (1 + 2 t))/4 == (3 (-4 + t^2))/3
Here is my personal attempt at a solution:
pol = (k^2 (-5 + 2 t) (1 + 2 t) + 3 (-4 + t^2))/(3 + 4 k^2)
n = CoefficientList[pol[[-1]], k]
d = CoefficientList[1/pol[[-2]], k]
Equal @@ (n[[{1, 3}]]/d[[{1, 3}]])
% // Reduce
Problem: Because the numerator and denominator have no linear terms, I manually extracted their quadratic (k²) and constant terms, ignoring the zero-coefficient linear terms.
Desired improvements:
Automatic zero-coefficient skipping: If a term (e.g., k¹) is missing (coefficient = 0), the code should skip it and only compare non-zero coefficient ratios.
Handling higher-degree terms: If terms like k³, k², k¹, and constants exist, the code should compare all corresponding coefficients.
Asymmetry detection: If terms are mismatched (e.g., numerator has k¹ but denominator does not), the code should flag that a constant value is impossible.