public void expand() {
		
		computedIntervals++;
		
		Interval interval = q.poll();
		
		double a = interval.a;
		double b = interval.b;
		double mid = (a + b) / 2;
		
		Interval interval1 = new Interval( a, mid, p, usedFormula );
		Interval interval2 = new Interval( mid, b, p, usedFormula );
		
		if ( (!interval1.singularityCase() || !interval2.singularityCase()) 
				&& Double.isInfinite(globalError))
			globalError = 0.;
				
		if (!interval1.singularityCase() ){
			integral += interval1.integral;
			globalError += interval1.error;
		}
		if (!interval2.singularityCase()){
			integral += interval2.integral;
			globalError += interval2.error; 
		}
	
		if (!interval.singularityCase()){
			integral -= interval.integral;
			globalError -= interval.error;
		}
		
		this.q.add(interval1);
		this.q.add(interval2);
	}