We will use some ideas illustrated here to find an expression
which will allow us to find the position of the image formed by a
lens by calculation (rather than by drawing a scale
diagram). 

Although the result is usually called the lens equation, it
can, in fact, also be used to predict the positions of images formed
by curved mirrors. 
To derive this equation we will start from a ray diagram showing
a converging (convex) lens forming a real image. 



On the ray diagram, we see two similar
triangles, as shown below. 


Therefore, we can write 

The ratio H/h is called the linear magnification
produced by the lens. 

Looking at the ray diagram we also have the following 


which, after a bit of messing around gives 


This is called the lens equation. 
When using this equation, distances to
real images and objects are given positive values and distances
to virtual images and objects are negative. 
This means that the focal length of a diverging lens is
represented by a negative figure. 