Let $a_i \in [a,b]$, and $x_i,y_i\in R$, $$\sum_{i=1}^n x^2_i=\sum_{i=1}^n y^2_i=1$$
show that $$\left|\sum_{i=1}^n a_i x^2_i - \sum_{i=1}^n a_i y^2_i\right| \le (b-a) \sqrt{1-\left(\sum_{i=1}^n x_i y_i\right)^2}$$
Let $a_i \in [a,b]$, and $x_i,y_i\in R$, $$\sum_{i=1}^n x^2_i=\sum_{i=1}^n y^2_i=1$$
show that $$\left|\sum_{i=1}^n a_i x^2_i - \sum_{i=1}^n a_i y^2_i\right| \le (b-a) \sqrt{1-\left(\sum_{i=1}^n x_i y_i\right)^2}$$
First let denote set $$S=\{i \in \{1,2,...,n\}|x_i \ge y_i \}.$$ Thus for each $i \in S$, we have $a_i({x_i}^2-{y_i}^2) \le b({x_i}^2-{y_i}^2)$ and for each $i \not \in S$, we have $a_i({x_i}^2-{y_i}^2) \le a({x_i}^2-{y_i}^2)$. Note that the left side is less than or equal to:
$$b\sum_{i \in S} {x_i}^2-{y_i}^2+a\sum_{i \not \in S} {x_i}^2-{y_i}^2$$ Using the fact that $\sum_{i=1}^n {x_i}^2=1$ and the same of ${y_i}^2$, this can be reduced to
$$(b-a)(\sum_{i \in S} {x_i}^2-{y_i}^2)$$ Therefore it suffices to show that
$$(\sum_{i \in S} {x_i}^2-{y_i}^2)^2 \le 1-(\sum_{i=1}^n (x_i)(y_i))^2$$ Substituting 1 by $\sum_{i =1}^n {x_i}^2$ and the same of ${y_i}^2$,the above inequality is equivalent to
$$(\sum_{i=1}^n (x_i)(y_i))^2 \le (\sum_{i \in S} {x_i}^2 + \sum_{i \not \in S} {y_i}^2)(\sum_{i \in S} {y_i}^2 + \sum_{i \not \in S} {x_i}^2)$$ which is true by the Cauchy-Schwarz inequality.