Equation for tangent line to the graph $y=(f(x))^2$ at point $x=2$. Let $f$ be differentiable function and $y=-2x+1$ be tangent line to graph of $y=f(x)$ at the point $x=2$.
How can I find the equation for tangent line to the graph $y=(f(x))^2$ at point $x=2$.
I created a function $f (x)$ myself, but it didn't work. Any ideas?

Find $f(2)$ and $f'(2)$ as follows $$\begin{align} y \quad &= \quad f(2) + f'(2)(x-2)  \\&=\quad f'(2)x + f(2) - 2f'(2) \\&=\quad -2x + 1 \end{align}$$
Since the coefficients should be equal, we get
$$\begin{cases} f'(2) = -2 \\ f(2) = -3 \end{cases}$$
Now, take $g = f^2$. To find the tangent equation, we will need the derivative of $g$ at $2$. $$g'(2) = [f(x)^2]'\bigg|_2 = 2f(2)f'(2) = 2(-3)(-2) = 12$$
Hence, the required tangent is
$$\begin{align} y \quad &= \quad g(2) + g'(2)(x - 2)  \\&=\quad (-3)^2 + 12(x-2) \tag{$g(2) = f(2)^2$} \\&=\quad 12x - 15 \end{align}$$
