The Math Behind the pH-logci Diagrams