# The Perfect Polynomial [closed]

The coefficients of a perfect square polynomial can be calculated by the formula $$\(ax)^2 + 2abx + b^2\$$, where both a and b are integers. The objective of this challenge is to create a program that not only can find if an input trinomial is a perfect square, but also find its square root binomial. The input trinomial will be written in this format:

1 2 1


which symbolizes the perfect square number $$\x^2 + 2x+ 1\$$, since all 3 input numbers represent coefficients of the trinomial. The outputs must be readable and understandable. To count as a perfect square in this challenge, a trinomial must have $$\a\$$ and $$\b\$$ as real integer numbers. No fractions, decimals, irrational numbers or imaginary/complex numbers allowed in the final binomial. Make a program that accomplishes this, and since this is , the shortest code in bytes wins.

• What can we do for output where it's not a perfect square? Some more test cases would be good.
– xnor
Sep 20, 2020 at 0:16
• Related to Luis Mendo's question on number types, what if the input is 2 4 2? Its square root is $\sqrt 2 x + \sqrt 2$. Does it count as a perfect square?
– xnor
Sep 20, 2020 at 0:17
• @NipDip Thanks for the clarifications. Please edit them into the question.
– xnor
Sep 20, 2020 at 4:17
• Please put in more test cases, ideally covering all corner cases that programs might encounter. These might include various coefficients being negative or zero. In particular, can the input have zero quadratic term or even just be a constant? Can it even be all zero?
– xnor
Sep 20, 2020 at 10:43
• I downvoted because of too restrictive output format and because the challenge text does not match the clarifications in the comments. Let me know if you solve that so I can remove my downvote Sep 20, 2020 at 10:43

(a,b,c)=>[A=Math.sqrt(a),b/A/2,b*b==c*a*4]

Can be called as f(a,b,c). Output is in the form [<factor of x>, <constant>, True/False] (if it's False, then the first 2 values are meaningless).