May be easier by setting up an "example case"; say extending the 3-4-5 right triangle:
I'll complicate your life by changing your variables to different letters!
E 8 D
9 9 15
C 8 F 12 A
Start with right triangle ABC; a = BC = 15, b = AC = 20, c = AB = 25
Draw line ED such that similar right triangle DBE is formed; e = BE = 6, d = DE = 8, f = DB = 10
Similar right triangle ADF also is formed; DF = a-e = 9, AF = b-d = 12, AD = c-f (your x) = 15
Givens are BC = a = 15, DB = f = 10 and AF = b-d = 12
PROBLEM: what is (c-f) in terms of a, f and (b-d) ?
I'll try this out later...