private Double evaluate(LinkedList<Token> s, Queue<Integer> variablePosition, double x) throws EmptyStackException{
		LinkedList<Token> temp = new LinkedList<Token>(s);
		for (Integer j : variablePosition) {
				temp.set(j, new Token(Double.toString(x)));
		}
		Stack<Token> stack = new Stack<Token>();
		for (Token token : temp) {
			stack.push(
			  token.isNumber()? token
			: token.isOperator()? new Token(Double.toString(token.getSymbol().operator(Double.parseDouble(stack.pop().getValue()),Double.parseDouble(stack.pop().getValue()))))
			: token.isFunction()? new Token(Double.toString(token.getSymbol().function(Double.parseDouble(stack.pop().getValue())))) 
			: null);
		}
		return Double.parseDouble(stack.pop().getValue());
	}