private String calculate(String x) throws MathParsingException
    {
		Matcher m;
		
		x = x.replaceAll("[ ]+", " ");
		
		// Cas de base : un chiffre
		if(this.regex(x, "^ [-]?[0-9.]+ $").matches())
		    return " " + x + " ";
		
		// Traitement des log
		m = this.regex(x, "^(.*)log ([-]?[0-9.]+)(.*)$");
		if(m.matches())
		    return calculate(m.group(1) +  " "  + String.valueOf(Math.log10(Double.parseDouble(m.group(2)))) +  " "  + m.group(3));
		
		// Traitement des parenthèses en premier
		m = this.regex(x, "^(.*)\\(([^)]*)\\)(.*)$");
		if(m.matches())
		    return calculate(m.group(1) +  " "  + calculate(m.group(2)) +  " "  + m.group(3));
		// Traitement des ^
		m = this.regex(x, "^(.*) ([-]?[0-9.]+) \\^ ([-]?[0-9.]+)(.*)$");
		if(m.matches())
		    return calculate(m.group(1) +  " "  + String.valueOf(Math.pow(Double.parseDouble(m.group(2)),Double.parseDouble(m.group(3)))) +  " "  + m.group(4));
		// Traitement des *
			m = this.regex(x, "^(.*) ([-]?[0-9.]+) \\* ([-]?[0-9.]+)(.*)$");
			if(m.matches())
			    return calculate(m.group(1) +  " "  + String.valueOf(Double.parseDouble(m.group(2))*Double.parseDouble(m.group(3))) +  " "  + m.group(4));
		// Traitement des /
		m = this.regex(x, "^(.*) ([-]?[0-9.]+) \\/ ([-]?[0-9.]+)(.*)$");
		if(m.matches())
		    return calculate(m.group(1) +  " "  + String.valueOf(Double.parseDouble(m.group(2))/Double.parseDouble(m.group(3))) +  " "  + m.group(4));
			
		// Somme
		m = this.regex(x, "^[-0-9.*/+ ]+$");
		if(m.matches())
		{
		    return somme(x);
		}
		
		throw new MathParsingException(x);
    }