Thanks a lot mate, if we presume that the pivot point of the boom is at point (0,y1) and the pivot point of the cylinder is at point (x1,0), then the relationship between theta and phi is:
phi = inv.tan (-(dcostheta + y1)/(x1 - dsintheta))
Which can be easily substituted into the left hand...