Factorize both quadratic polynomials, as shown below
[tex]\begin{gathered} a^2-3a-4=0 \\ \Rightarrow a=\frac{3\pm\sqrt{9+16}}{2}=\frac{3\pm\sqrt{25}}{2}=\frac{3\pm5}{2}\Rightarrow a=-1,4 \\ \Rightarrow a^2-3a-4=(a+1)(a-4) \\ \end{gathered}[/tex]
Similarly,
[tex]\begin{gathered} a^2+5a+4=0 \\ \Rightarrow a=\frac{-5\pm\sqrt{25-16}}{2}=\frac{-5\pm3}{2}\Rightarrow a=-1,-4 \\ \Rightarrow a^2+5a+4=(a+1)(a+4) \end{gathered}[/tex]
Thus,
[tex]\Rightarrow\frac{a^2-3a-4}{a^2+5a+4}=\frac{(a+1)(a-4)}{(a+1)(a+4)}[/tex]
Therefore, since the denominator cannot be equal to zero.
The variable restrictions for the original expression are a≠-1,-4
Then, provided that a is different than -1,
[tex]\Rightarrow\frac{a^2-3a-4}{a^2+5a+4}=\frac{x-4}{x+4}[/tex]
The rational expression in the lowest terms is (x-4)/(x+4)