9

Is there any way I can find a polynomial given any $2$ points (with $x$ coordinate OF MY CHOICE): Let's say there's some polynomial I don't know $(p(x)=2x^3+x^2+3)$, but my machine will give me an output. I give one $x$ value of my choice, and it returns $p(x)$, where $p(x)$ is the polynomial function. I give another value of my choice., $x+h$, and get the output $p(x+h)$. Given these outputs, I have to find $p(x)$ as a polynomial.

What I've done is plugged in $0$, which gives me the final term of the polynomial that is not multiplied by any power of $x$. Then I plug in $1$, getting another output. When I find the "slope" of the two points, I get the sum of all the coefficients of all the terms that are powers of $x$. If I do this for the given $p(x)$, I get $3$, which is the sum of $2$ and $1$. However, I can't figure out what powers of $x$ there are and what specific coefficients there are. Does anyone know how to solve this?

@GerryMyerson and @Shash said I can find the polynomial given the bound of the coefficients. I am confused as to what that means. There is only one number that is the sum of the coefficients. How is there a bound? Also, how do I find this sum of coefficients with just one value? I need to use one more value, M+1, as Shash said, so I can't use 2 values to find the max/sum, as I won't be able to ask for a value that is M+1. Can anyone help? Thanks.

EDIT: Non-negative integer coefficients are assumed.

David
  • 113
  • 15

4 Answers4

14

If all the coefficients are non-negative integers and if we know the max of all the coefficients, then it is easy to find the coefficients with just ${one\ point}$ of choice. Let's say the max is $M$. Then evaluate the polynomial at $M+1$. The output will be equal to the decimal number system representation of a number whose base $M+1$ number has digits as the coefficients of the polynomial. So, given the output, just get the base $M+1$ representation.

So, even if have just an upper bound (can be very lose upper bound), just set that as $M$ and proceed as above.

As Gerry Myerson points out in the comments, if you do not have an upper bound, you can use $M = p(1)$. Then only two evaluations will be required to determine the coefficients.

Shash
  • 826
  • 4
    Note that we don't need to know the degree here :) – Shash Nov 28 '14 at 08:16
  • 4
    And if you don't have a bound for the coefficients, you can get one by evaluating at $x=1$. So (if the coefficients are nonnegative integers) you can get the whole polynomial by 2 evaluations. – Gerry Myerson Nov 28 '14 at 08:44
  • @GerryMyerson Myerson: how do I only use x=1 to find the bound? I thought I need to use both $x=0$ and $x=1$. – bob the pie Nov 28 '14 at 16:27
  • Wait, so I can start with $x=0$, then ask $x=1$? This gives me a bound, and I then use that bound? Or do you mean something else – bob the pie Nov 28 '14 at 16:47
  • 1
    @VardaanBhat: what is meant here is that if your polynomial is $p(x)=2x^3+x^2+3$, you can read the coefficients in $p(10)=2103$; if the coefficients can have at most, say three digits, then evaluate $p(1000)$. Like $p(x)=234x^2+15x$, and $p(1000)=234 015 000$. And so on. –  Nov 28 '14 at 17:26
  • What does the decimal number system have to do with anything? You can just delete "equal to the decimal number system representation of". – TonyK Nov 28 '14 at 17:28
  • @YvesDaoust I'm still confused. Why f(10)? – bob the pie Nov 28 '14 at 17:46
  • This is similar to this puzzle posted a couple weeks ago. http://www.calpoly.edu/~sherman1/puzzleoftheweek/pow_130soln.pdf – Vortico Nov 28 '14 at 18:20
  • @VardaanBhat: open you eyes and look at the value of $p(10)$ compared to $p(x)$. –  Nov 28 '14 at 18:23
  • As @GerryMyerson was saying, set $M = f(1) + 1$. Since the coefficients are nonnegative, this gives an upper bound of the coefficients. Then evaluate $f(M)$, write in base $M$, and observe that the digits correspond directly to the coefficients of the polynomial. – Vortico Nov 28 '14 at 18:25
  • If the polynomials are assumed to have nonnegative integers, should @VardaanBhat update his question with this information? Or are we operating under a false assumption for this answer? – Vortico Nov 28 '14 at 18:27
  • @Vortico , I edited the question to confirm that the polynomials are assumed to have nonnegative integer coefficients. – bob the pie Nov 28 '14 at 19:14
  • @YvesDaoust :So I find p(10 raised to the power of max. amount of digits in the bound of the coefficients)? – bob the pie Nov 28 '14 at 19:17
  • @YvesDaoust : As an example, with $p(x)=x^3+3$, I ask for p(1), and get 4, then I ask for p(10)(since $10^1$ represents a maximum of 1 digit in any number less than or equal to four). I get $1003$, and see that $p(x)=1(x^3)+0(x^2)+0(x^1)+3(x^0)$. Is this correct or not? – bob the pie Nov 28 '14 at 19:20
  • If this is true, would a proof say: 10 to the maximum amount of digits(lets call that n) allows for us to split $p(10^n)$ into parts of n digits, and the coefficients would be found in these parts, going from a coefficient of $x^(n-1)$ down to a coefficient of $x^0$? – bob the pie Nov 28 '14 at 19:23
  • @VardaanBhat: absolutely. This is also valid for other bases than $10$. It is necessary to use a power of $10$ large enough to ensure that the coefficients do no overlap. –  Nov 28 '14 at 19:37
  • @YvesDaoust But for a solution, I can just use base 10 right? I'm really bad with other bases, so will base 10 always apply? I think so, but I'm not sure. – bob the pie Nov 28 '14 at 19:40
  • @VardaanBhat: yep. Actually, you are working in base $10$, $100$, $1000$... All you need is a base larger than the largest coefficient. –  Nov 28 '14 at 21:03
  • @Vortico So that's where I saw the problem! I remember seeing it, just didn't remember the solution. Thanks – bob the pie Dec 10 '14 at 06:06
7

With two points you can only uniquely determine $p(x)$ if it has degree one. In general if $p(x)$ has degree $n$, you will need the computer give $(n+1)$ outputs, each for a different input.

For example if $p(x)$ has degree 2 and you input $0$ and $1$ and get outputs $a$ and $b$ respectively, there are an infinite number of parabolas which pass through these points. Here are some:

$p(x) = (b-a)x^2+a$

$p(x) = bx^2-ax+a$

$p(x) = 2bx^2-(b+a)x+a$

$p(x) = -3ax^2+(b+2a)x+a$

David P
  • 12,320
  • This is not true in this special case because of the non-negative integers clause. First evaluate the polynomial at $p(1)$ to find an upper bound for all the coefficients, $M$. Then evaluate at $p(M+1)$ and refer to Shash's answer. – Caleb Stanford Nov 29 '14 at 06:10
  • I think this answer needs more explanation. It is of course well-known that in the case of real numbers two points will not suffice. This is also true in the integers, I think, as well as in the nonnegative real numbers, but not in the nonnegative integers. By just referring to $p(x)$ without talking about where its coefficients lie at all, you are avoiding the crux of the problem. – Caleb Stanford Nov 29 '14 at 06:12
  • (Although, I notice now that the non-negative integers edit was added after you posted this answer.) – Caleb Stanford Nov 29 '14 at 06:18
  • Yes, the question was modified after I answered – David P Nov 29 '14 at 06:30
3

No. You would a minimum of $n$ points, where $n$ is the dimension of the polynomial. For instance, let's try to find a cubic polynomial $p$ where $p(0)=0$ and $p(1)=1$. Notice that $p_1(x)=x^3-x^2+1$ and $p_2(x)=x^3-x+1$ both satisfy the given criteria.

Jason
  • 15,438
3

A polynomial of degree $n$ has $n+1$ coefficients. If you know the degree but don't know anything about those coefficients, you'll need $n+1$ values of the polynomial to determine them. If you don't know the degree, no amount of values of the polynomial will suffice.

Robert Israel
  • 448,999
  • True from a pure math sense. However, if you get enough (way more than 2 points), you could use curve-fitting techniques to guess the original polynomial. Also, if the polynomial is quadratic, and you have 5 points (thus assume a quartic), the leading coefficients will be zeros. ($0x^4+0x^3+cx^2+dx+e=y$). – FundThmCalculus Nov 29 '14 at 03:51