Quadratic polynomial computation without multiplication

31 Views Asked by At

Given a quadratic polynomial $f(x)=ax^2+bx+c$, and $a,b,c$ are all constant. If we know some function value for certain $x$, s.t. $f(1),f(2),f(3)...$, is it possible to given a recursive relation between $f(x)$ and $f(x-1),f(x-2),...$ (possibly $f(1),f(2)...?$) without multiplication (since multiplication costs much more resource than addition in terms of programming)

1

There are 1 best solutions below

0
On BEST ANSWER

For a given polynomial $f(x)=ax^2+bx+c$, taking two sets of "forward differences" yields the following:

$$f(x+2)-f(x+1)=a(x^2+4x+4-x^2-2x-1)\\ +b(x+2-x-1)+c(1-1)\\ =a(2x+3)+b\\ =v_2$$

$$f(x+1)-f(x)=a(x^2+2x+1-x^2)\\ +b(x+1-x)+c(1-1)\\ =a(2x+1)+b\\ =v_1$$

and now

$$v_2-v_1=a(2x+3-2x-1)+b(1-1)\\ =2a$$

Now to go in reverse, you just need to keep one "difference vector":

$$v_3=v_2+2a\\ f(x+3)=f(x+2)+v_3$$

$$v_{n+1}=v_n+2a\\ f(x+n+1)=f(x+n)+v_{n+1}$$

If you need to go many steps forward all at once, it will probably be faster to just do the multiplication.