public double calc_weight(double x) { double t; if (x < 0.5) return 0.75 - x * x; if (x < 1.5) { t = x - 1.5; return 0.5 * t * t; } return 0.0; } };