A Polynomial Black Box

Algebra Level 3

The polynomial p ( x ) p(x) is of degree 2017 and has non-negative integer coefficients which you don't know.

If you input a value like x = x 0 , x= x_0, the computer will output the value p ( x 0 ) p(x_0) at a cost of $1.

If you want to determine all 2018 coefficients of p ( x ) p(x) at a minimum cost using only positive integer inputs, what is your cost in dollars?


The answer is 2.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Daniel Xiang
Mar 4, 2018

Here is how you determine all 2018 2018 coefficients.

First you input x 0 = 1 x_0 = 1 and the computer would give you p ( 1 ) p(1) , which is the sum of all coefficents.

let s = p ( 1 ) s = p(1)

Then you input x 1 = s + 1 x_1 = s+1 , and the computer would give you p ( s + 1 ) p(s+1) .

Converting p ( s + 1 ) p(s+1) to base s + 1 s+1 and the digits correspond to the coefficients of p ( x ) p(x) .

Because

p ( s + 1 ) = d 2017 ( s + 1 ) 2017 + d 2016 ( s + 1 ) 2016 + + d 2 ( s + 1 ) 2 + d 1 ( s + 1 ) + d 0 p(s+1)=d_{2017} (s+1)^{2017}+d_{2016} (s+1)^{2016}+\cdots+d_2 (s+1)^2 + d_1(s+1) + d_0

is exactly how we represent integers in base s + 1 s+1

we use s = p ( 1 ) s=p(1) to make sure that the second number we input is larger than any of the coefficients.

This works for p ( x ) p(x) of arbitrary degrees, as long as all coefficient are nonnegative integers.

Moderator note:

There is some confusion in the comments as to what is going on, so a practical example using 2 as the degree rather than 2017 might help.

Suppose the polynomial is p ( x ) = 5 x 2 + 3 x + 4. p(x) = 5x^2 + 3x + 4 .

First, we set an input of x = 1 x=1 and get 5 + 3 + 4 = 12. 5 + 3 + 4 = 12 .

Now, we input that sum plus one, that is, x = 13. x = 13 . 5 ( 13 ) 2 + 3 ( 13 ) + 4 = 888. 5(13)^2 + 3(13) + 4 = 888 .

888 888 converted to base 13 is 534 , 534 , which is the coefficients we want.

This is because if we backtrack and consider the meaning of 534 534 base 13, it's

4 4 copies of 1 1

3 3 copies of 13 13

5 5 copies of 1 3 2 13^2

that is, exactly 5 ( 13 ) 2 + 3 ( 13 ) + 4. 5(13)^2 + 3(13) + 4 .

Compare this with the given solution and it should become clearer. Note since our base is always larger than the sum of the coefficients, it will always be possible to represent all coefficients as single digits.


There's also the question of proving it isn't possible to do in 1 check.

Assume $1 is possible. Say that we tested with Z . Z. Then, we just need to find 2 polynomials f 1 f_1 and f 2 f_2 which satisfy

f 1 ( Z ) = f 2 ( Z ) f_1(Z) = f_2 (Z)

in which case we are unable to differentiate between these 2 polynomials.

One example is f 1 ( x ) = x 2017 + x f_1(x) = x^{2017} + x and f 2 ( x ) = x 2017 + Z . f_2 (x) = x^{2017} + Z.

so, what is the correct answer? 2$?

emme effe - 3 years, 3 months ago

How does this work? I'm confused.

Ishaan Gupta - 3 years, 3 months ago

Somehow understood. If we narrow down the question with the following constraints: "All of the coefficients are non-negative integers less than or equal to 9." Then if you plug in x=10, the output of the function is just the number containing the digits as each coefficient.

But how about with coefficients larger than 9? We cannot plug in x=10 as it will cause 'overflow' or 'carry over' of the digits hence we cannot separate the digits. But if we use a base which guarantee larger than any coefficients, the problem doesn't exist. Selecting the base to be the sum of all coefficient is definitely a good choice.

Ximple Shum - 3 years, 3 months ago

Log in to reply

I do agree with you

andrea costa - 3 years, 3 months ago

Log in to reply

great explanation

Abel McElroy - 3 years, 3 months ago

Exactly, thank you for your explanation.

Daniel Xiang - 3 years, 3 months ago

Can someone explain the solution?

Ashwini Kumar - 3 years, 3 months ago

Even though I've known this solution for a little while, it still constantly amazes me!

zico quintina - 3 years, 3 months ago

How do you know that 2 is the minimum solution? If you input x=pi, p(x) will be of the form a+b(pi)+c(pi)^2+d(pi)^3+... It would be impossible for p(x) to be constructed from powers of pi in more than one way because pi is transcendental. Deconstructing p(x) into powers of pi would certainly be harder than deconstructing into powers of an integer, but it still could theoretically be done. This $1 solution could be eliminated by restricting your choices of x to integers.

By the way, concerning your method, converting a number into a different base is hard, so it would be easier to just set your second value of x equal to the next higher power of 10 after s.

John Ross - 3 years, 3 months ago

Log in to reply

I tried doing a couple of examples on scratch paper to see practically how Mr. Xiang's solution would work (but using degree 3 or 4, for obvious reasons), and your power of 10 suggestion really does simplify the math nicely. Good idea Mr. Ross.

David Ortiz - 3 years, 3 months ago

I have the same idea.😁

Tesla Ma - 3 years, 2 months ago

Hi John. Thanks for your input! We've modified the problem to address the issue that you raised.

Patrick Zulkowski Staff - 3 years, 2 months ago

Log in to reply

The problem talked about inputting numbers into a computer, which would only give outputs up to a certain decimal accuracy. In that case, you would not be able to rely on the transcendency (nice word) of an input anyway, correct?

David Ortiz - 3 years, 2 months ago

Log in to reply

@David Ortiz Yes, I see your point. Perhaps we should think of the "computer" as an oracle that can provide us with the output of the polynomial given an input instead of a literal machine without finite precision. Thanks for your comment!

Patrick Zulkowski Staff - 3 years, 2 months ago

@David Ortiz You are technically correct. The issue of computer accuracy had occured to me, but I figured that the problem was more theoretical than technically literal. Good point though. :)

John Ross - 3 years, 2 months ago

Amazing problem

Antonio Mendez Gonzalez - 3 years, 2 months ago

For ease of actually performing the example, you don't have to use x_1=s+1, just use the next power of 10. In your example of p(x)=5x^2+3x+4, you got p(1)=12. Then you can input x=100, getting p(100)=50304. From this, it is simple to read off the coefficients of 5,3,4 without having to change bases (technically we are changing bases, but converting from base 10 to base 10^n is way easier than base 10 to base 13).

Note that we cannot just use x=10 in this example, because the polynomial p(x)=x+11 would also give p(1)=12, but p(10)=21 gives the wrong coefficients.

Matthew Burkemper - 3 years, 2 months ago

What if the original coefficients were not single digit?

Kushagra Gupta - 3 years, 2 months ago

Being practical, and assuming the computer can provide results with an unlimited number of digits (as the high degree of the polynomial suggests), in most cases we could get the answer with $1 by trying a high power of ten from the start. This is what I thought at first and what I would do if I were supposed to undertake the task more than once. But, of course, this would not work in those cases where you have no clue as to how large the coefficients could be...

Gabriel Chacón - 3 years ago

Log in to reply

... But I was wrong! See Moderator note.

Gabriel Chacón - 2 years, 5 months ago

p(x) = 20 * x^2+ 3*x + 1 which is a very simple contra-example.

p(1) = 24 p(1)+1 = 25 (base)

p(25) = 12626 (base 10) , which converted to base 25 is K51. Nice one !

I think there is an error in your assumption or i did a mistake ?

Alexandru Alexandrescu - 2 years, 5 months ago
Sam Rero
Mar 17, 2018

suppose p(x) = 1+12 x+123 x^2 we will input x=1 so p(x)=136 since the sum of the coefficients is 3 digit-number then the biggest coefficient has no more than 3 digits so the next input is 1000 (number of zeros equals number of digits) which gives 123,012,001 where every 3 digits from right forms a coefficient. therefore the coefficients are 1, 12 and 123 and finally the answer is 2$.

What if the equation is 1+12x+99x²? The sum of coefficients is a 3-digit number , but the biggest coefficient has only 2-digits!

Chavali Anirudh - 3 years, 2 months ago

Log in to reply

thanks for the feedback.I meant to say that the biggest number is no more than 3 digits. now it is edited. but you still need to use the second input as 1000. the idea is that your second input is 10^n where n is the number of digits of the sum, so you guarantee that every 3 digit-number is a coefficient.

sam rero - 3 years, 2 months ago
Sophie Williams
Mar 17, 2018

I really had no idea what the question meant, but I hazarded a guess at doing the following:

2017 2018 \frac{2017}{2018} + 1 = 1.999504459

i.e. if you like... last year divided by this year, plus the difference in years between the two years.

Then it said the answer had to be an integer, so I rounded it up to 2, and it was correct. Forgive me for what is, I suppose, just a lucky guess. This is my first day on Brilliant and my last formal mathematics was Year 11 high school 39 years ago (so I never actually graduated). I've come here to try to get my maths up to speed, so I can work these problems out properly.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...