private double doNamedVal(int beg, int end) {
    while(beg<end && Character.isWhitespace(expression.charAt(end))) { end--; }                     // since a letter triggers a named value, this can never reduce to beg==end

    String                  nam=expression.substring(beg,(end+1));
    Double                  val;

    if     ((val=constants.get(nam))!=null) {                   return val.doubleValue(); }
    else if((val=variables.get(nam))!=null) { isConstant=false; return val.doubleValue(); }
    else if(relaxed                       ) { isConstant=false; return 0.0;               }

    throw exception(beg,"Unrecognized constant or variable \""+nam+"\"");
    }