Answer
$$
f(x) =\frac{x^{2}-6 x+9}{x+2}
$$
(*)
A relative maximum occurs at $x=-7,$ and the value of the function $f$ at this value is given by:
$$
\begin{aligned}
f(-7) &=\frac{(-7)^{2}-6 (-7)+9}{(-7)+2} \\
&=-20. \\
\end{aligned}
$$
(**)
A relative minimum occurs at $x=3,$ and the value of the function $f$ at this value is given by:
$$
\begin{aligned}
f(3) &=\frac{(3)^{2}-6 (3)+9}{(3)+2} \\
&=0. \\
\end{aligned}
$$
Work Step by Step
$$
f(x) =\frac{x^{2}-6 x+9}{x+2}
$$
To find the intervals where the function is increasing and decreasing.
First, we find $f^{\prime}(x) $,
$$
\begin{aligned}
f^{\prime}(x) &=\frac{(2 x-6)(x+2)-(1)\left(x^{2}-6 x+9\right)}{(x+2)^{2}} \\
&=\frac{x^{2}+4 x-21}{(x+2)^{2}} \\
&=\frac{(x+7)(x-3)}{(x+2)^{2}}
\end{aligned}
$$
To find the critical numbers, we first find any values of $x$ that make $f^{\prime} =0 $. Now, solve the equation $f^{\prime} =0 $ to get
$$
\begin{aligned}
f^{\prime}(x) =\frac{(x+7)(x-3)}{(x+2)^{2}}&=0\\
\Rightarrow\quad\quad\quad\quad\quad\\
(x+7)(x-3) &=0\\
\Rightarrow\quad\quad\quad\quad\quad\\
(x+7)=0 & \quad \quad or \quad \quad (x-3)=0 \\
x=-7 & \quad \quad or \quad \quad x=3 \\
\end{aligned}
$$
Next, we find any values of $x$ where $f^{\prime}(x) $ fails to exist. This occurs whenever the denominator of $f^{\prime}(x) $ is $0$, here we observe that the denominator $(x+2)^{2}$ equal to 0, when $x=-2$. But , $f(x) $ is not defined also at $x=-2 $.So,
The only critical numbers are: $x =-7 $ and $x=3$ .
We can still apply the first derivative test, however, to find where $f$ is increasing and decreasing. Now, check the sign of $f^{\prime}(x)$. in the intervals
$$
(-\infty, -7 ), \quad (-7 ,3 ) , \quad \text {and} \quad (3, \infty).
$$
(1)
Test a number in the interval $(-\infty, -7 )$ say $-8 $:
$$
\begin{aligned}
f^{\prime}(-8) &=\frac{((-8)+7)((-8)-3)}{((-8)+2)^{2}}\\
&=\frac{11}{36} \\
&\approx 0.305 \\
&\gt 0
\end{aligned}
$$
we see that $f^{\prime}(x)$ is positive in that interval, so $f(x)$ is increasing on $(-\infty, -7 )$.
(2)
Test a number in the interval $ (-7 ,3) $ say $ 0$:
$$
\begin{aligned}
f^{\prime}(0) &=\frac{((0)+7)((0)-3)}{((0)+2)^{2}}\\
&=-\frac{21}{4} \\
&\approx -5.25 \\
&\lt 0
\end{aligned}
$$
we see that $f^{\prime}(x)$ is negative in that interval, so $f(x)$ is decreasing on $(-7 ,3 )$.
(3)
Test a number in the interval $(3, \infty )$ say $4 $:
$$
\begin{aligned}
f^{\prime}(4) &=\frac{((4)+7)((4)-3)}{((4)+2)^{2}}\\
&=\frac{11}{36}\\
&\approx 0.305 \\
&\gt 0
\end{aligned}
$$
we see that $f^{\prime}(x)$ is positive in that interval, so $f(x)$ is increasing on $(3, \infty )$.
From (1), (2) and (3) we find that:
(*)
The function $f$ is increasing on interval $ ( -\infty , -7) , $ and it is decreasing on interval $ (-7 ,3 ) . $ So, a relative maximum occurs at $x=-7,$ and the value of the function $f$ at this value is given by:
$$
\begin{aligned}
f(-7) &=\frac{(-7)^{2}-6 (-7)+9}{(-7)+2} \\
&=-20. \\
\end{aligned}
$$
(**)
The function $f$ is decreasing on interval $ (-7 ,3 ), $ and is increasing on interval $ ( 3 , \infty). $ So, a relative minimum occurs at $x=3,$ and the value of the function $f$ at this value is given by:
$$
\begin{aligned}
f(3) &=\frac{(3)^{2}-6 (3)+9}{(3)+2} \\
&=0. \\
\end{aligned}
$$