# Algorithm for shifting a curve

I have to following problem that I would like to solve.

I have a vector of coefficients $V = [a_N, \ldots ,a_1, a_0]$ which represents the coefficients of a polynomial $P$, i.e.: $$P(x) = a_N x^N + ... + a_1 x + a_0$$

I would like to write an algorithm for shifting the curve on the horizontal axis, i.e., given a shift factor $h$ I would like to find a generalized way for automatically writing the coefficients of the polynomial: $$P(x-h) = a_N (x-h)^N + \ldots + a_1(x-h) + a_0$$ on MATLAB, without computing them at hand.

-
Can't you just define it as a function and use an Expand command? That's what I would think about in Mathematica. There must be a way then to recollect the coefficients into a vector if you want. –  Ross Millikan Mar 12 '13 at 13:32

Hoping that by "without calculating them" you mean "without calculating the $(x-h)^k$ polinomials", this should work:

$a^*_{i} = \sum_{j=i}^n\binom{j}{i}a_jh^{j-i}$

-
Is there maybe an error in the binomial coefficient? j cannot be bigger than i, right? –  Eleanore Mar 12 '13 at 16:19
Yes, you're right, edited –  kaharas Mar 12 '13 at 16:20
Moreover, I think that there is a problem with the signs. For instance, if y=2x+1 is considered, y=2x+7 is obtained, which is not correct I guess. –  Eleanore Mar 12 '13 at 16:24

Given the polynomial: $$P(x) = a_N x^N + ... + a_1x + a_0$$ the coefficients of the polynomial: $$P(x-h) = a_N^* x^N + ... + a_1^* + a_0^*$$ can be found as follows: $$\left \{ \begin{array}{ll} a_i^* = \sum_{j=i}^N \binom{j}{i} a_j h^{j-i}(-1)^{j-i} & i = 1...N \\ a_0^* = \sum_{j=0}^N a_j h^j (-1)^j & \end{array} \right .$$