public double NextPropagationTime(double time) {
	time += 1e-13;	// get past current time by epsilon
	double tlast = 0;
	double vlast = 0;
	for (int i = 0; i < npairs; i += 2) {
	    double t = tvpairs[i];
	    double v = tvpairs[i+1];
	    if (i > 0 && time <= t) {
		if (vlast < vih && v >= vih) {
		    double et = tlast + (t - tlast)*(vih - vlast)/(v - vlast);
		    if (et > time) return et;
		}
		else if (vlast > vil && v <= vil) {
		    double et = tlast + (t - tlast)*(vil - vlast)/(v - vlast);
		    if (et > time) return et;
		}
	    }
	    tlast = t;
	    vlast = v;
	}
	return -1;
    }