you should use Pythagoras' theorem. meaning side AB squared + BC squared = 9 squared.
(try to understand this because i have no idea how to write squared on the keyboard sorry.. by (2) i mean squared)
8x comes from the squaring of (x+4)
it expands to x(2)+4x+4x+16
~~~~~~~~~~~~~~~
so then:
x(2)+x(2)+8x+16=9(2)
2x(2)+ 8x-65=0
2x(2)+8x-65=0