private boolean recalculateSingle(final VariableState state, final boolean forceError) {

        state.result = null;

        if (state.formula == null) {
            state.state = State.ERROR;
            if (state.error == null) {
                state.error = FormulaException.getUserDisplayableMessage(FormulaException.ErrorType.OTHER, "-");
            }
        } else {
            state.resultAsCharSequence = null;
            boolean hasCycleDep = false;
            for (String n : state.needs) {
                final VariableState cs = Objects.requireNonNull(get(n));
                if (cs.state == State.CYCLE) {
                    hasCycleDep = true;
                    break;
                }
            }
            if (hasCycleDep && state.state == State.CYCLE) {
                return true;
            }
            try {
                state.result = state.formula.evaluate(
                        v -> state.needs.contains(v) ? Objects.requireNonNull(get(v)).getResult() : null, state.rangeIndex); //may throw FormulaException
                state.resultAsCharSequence = state.result.toString();
                if (forceError) {
                    state.state = State.ERROR;
                    state.error = FormulaException.getUserDisplayableMessage(FormulaException.ErrorType.OTHER, "-");
                } else {
                    state.state = State.OK;
                    state.error = null;
                }
            } catch (FormulaException ce) {
                state.result = null;
                state.resultAsCharSequence = ce.getExpressionFormatted();
                state.state = State.ERROR;
                state.error = ce.getUserDisplayableErrorMessage();
            }
        }
        return false;
    }
Calculates a set of all variables which are needed (directly or indirectly) to calculate the given vars
main/src/main/java/cgeo/geocaching/utils/formulas/VariableMap.java