Find polynomial with some conditions I need to find $f(x)\in \mathbb{Q}[x]$, such that:  


*

*$f(x)\equiv 1 \pmod{(x-1)^2}$

*$f(x)\equiv x \pmod{x^2}$

*$\deg(f(x))<4$
So, what I understand so far is that:  


*

*$(x-1)^2\mid f(x)-1$

*$x^2\mid f(x)-x$
(I hope I'm right at those)


But I'm stuck here, I don't know how to continue...
Can you help me please?
Thank you!
 A: Let the polynomial be $f(x)=ax^3+bx^2+cx+d$. The second condition is easier to apply, because it implies $c=1$ and $d=0$.
Now let's apply the first condition. You know that $f(1)-1=0$, so
$$
a+b+1-1=0
$$
On the other hand, $1$ must also be a root of the derivative of $g(x)=f(x)-1$. Hence
$$
3a+2b+1=0
$$
Thus $a=-1$ and $b=1$.
The polynomial is $f(x)=-x^3+x^2+x$.
Without derivatives: consider $g(x)=f(x)-1=ax^3+bx^2+x-1$. It should be divisible by $x-1$, so $g(1)=a+b+1-1=0$. Hence $b=-a$. Now we see that
$$
g(x)=ax^3-ax^2+x-1=ax^2(x-1)+(x-1)=(x-1)(ax^2+1)
$$
This should be divisible by $(x-1)^2$, yielding $a=-1$.
A: $f(x)-1=g(x-1)^2$ with $g$ that is a polynomial of degree $1$, so $g=ax+b$ but you have also that 
$f(x)-x=(cx+d)x^2$ 
so 
$(ax+b)(x-1)^2+1=(cx+d)x^2+x$
Then $a=c$, $-2a+b=d$, $a-2b=1$, $b+1=0$
so
$b=-1$, $a=-1$, $d=1$, $c=-1$.
Then 
$f(x)=-(x+1)(x-1)^2+1$
A: $-(1+x)(x-1)^{2}+1$ is such a polynomial. 
A: Consider the polynomial $f(x)=(Ax+B)(x-1)^2+1$. It is evident that $f$ satisfies the conditions 1 and 3. It remains to find $A$ and $B$ such that 
$$f(x)=(Ax+B)(x^2-2x+1)+1\equiv (A-2B)x+B+1\equiv x \pmod{x^2}$$
that is $B=-1$ and $A=-1$. Hence
$$f(x)=-(x+1)(x-1)^2+1=-x^3+x^2+x.$$
A: Using $\ ag\,\bmod\, bg\, =\, g\,\left[\,a\bmod b\,\right]\:$ to factor out $\: g = (x\!-\!1)^{\large 2}$
$\,\ \begin{align}f\!-\!1\!\!\!\pmod{\!x^{\large 2} g} &\,=\,  g\,\left[\dfrac{\!\color{#c00}f\!-\!1\,}{(x\!-\!1)^{\large 2}}\bmod {x^{\large 2}}\right]^{\phantom{|^|}}\!\!,\, \  {\rm so}\ \  \color{#c00}{f\equiv x}\!\!\!\pmod{\!x^2}\ \ \rm yields\\
&\!\!\!=\  {-}g\,\left[\,\color{#0a0}{x\!+\!1}\,\right]\ \ {\rm by}\ \ \dfrac{\color{#c00}x\!-\!1\ }{(x\!-\!1)^{\large 2}} \equiv \dfrac{1}{x\!-\!1} \equiv \dfrac{1\!-\!\color{#90f}{x^{\large 2}}}{x\!-\!1} \equiv \color{#0a0}{-(x\!+\!1)}\!\!\pmod{\!\color{#90f}{x^{\large 2}}} 
\end{align}$
