public static Double nernst(Double freeEnergy, Double moles, Double cellPotential)
	{
		//G = -nFE
		
		boolean[] nulls = new boolean[4];
		nulls[0] = (freeEnergy == null);
		nulls[1] = (moles == null);
		nulls[2] = (cellPotential == null);
		
		int nullCount = 0;
		for(int k = 0; k < nulls.length; k++)
		{
			if(nulls[k])
				nullCount++;
		}
		
		if(nullCount != 1)
			return null;
		
		double result = 0;
		
		if(nulls[0])
		{
			// freeEnergy is unknown
			result = -moles*F*cellPotential;
		}
		else if(nulls[1])
		{
			// moles is unknown
			result = -freeEnergy/(F*cellPotential);
		}
		else if(nulls[2])
		{
			// cellPotential is unknown
			result = -freeEnergy/(F*moles);
		}
				
		return result;
	}