Can anyone help do the maths?

How would you code all relationships into a form to display accurate pages per number of words queried? Want to offer this form on our site for free but it is quite uneasy establishing the relationships in a single equation/model. Certain we can come up with something… any easy way out?