5 ms·
For those who want the trick: https://www.johndcook.com/blog/2012/03/27/polynomial-trick/ https://www.johndcook.com/blog/2012/03/27/polynomial-trick/
by ghusbands 9y ago
For those who want the trick: https://www.johndcook.com/blog/2012/03/27/polynomial-trick/ https://www.johndcook.com/blog/2012/03/27/polynomial-trick/
- dmitrygr 9y agotry that with f(x) = x^8 - x^4 EDIT: i cannot read. please ignore :)
- huhtenberg 9y agoHa... the proof is so elegant!
- zokier 9y agoOkay, that took some thinking to figure why it works. Basically, p(x) tells the coefficients as long as x is bigger than any coefficient. This is easy to test with the given example polynomial p(x) = 2 x³ + 4 x + 3, p(10) = 2043, where you can see the coefficients plainly in base 10. But for example p(x) = 2x³ + 14x + 3 is ambiguous with p(10) = 2143. (edit: I feel like there is a connection to Nyquist-Shannon theorem here, the coefficients get kinda "aliased") The trick here is that because p(1) is the sum of the coefficients, it must also be bigger than any of coefficients, so p(p(1)) is always "safe" to use. To avoid base conversions, I think you can always use next power of ten for the second value, i.e. p(10^n) where n = floor(log10(p(1)))+1. For example if p(1) = 182, then you could ask p(1000) = 12000140030 or 12 000 140 030, which gives us the coefficients (12x³ + 140x + 30). Arguably easier than trying figure out what 72368326 is in base 182.
- mcphage 9y agoYeah, I like the 10^n method, since it looks like you get the coefficients written out very nicely.