I encountered the following inequality in a paper I was reading: $$\left(\sum_{i=1}^d a_ib_i\right)^2 \leq \left(\sum_{i=1}^d b_i \right) \left( \sum _{i=1}^d a_i^2 b_i\right)$$
I am unable to prove it (or find a counterexample for that matter). Hints would suffice on how to proceed.
We can obviously disregard terms $b_i=0$, that don't contribute to either side.
The case $d=1$ is obvious. Assume then $d>1$ and that there are positive and negative $b_i$.
Assume, without loss of generality, $b_1<0$ and $b_2>0$. We can choose $a_i=0$ for $i=3,\dots,d$.
If $\sum_i b_i>0$, set $a_1=1$ and choose $a_2$ such that $a_2^2b_2<-b_1$. Then $$ \sum_{i=1}^da_i^2b_i<0 $$ and the inequality doesn't hold.
If $\sum_i b_i<0$, set $a_2=1$ and choose $a_1$ such that $-a_1^2b_1<b_2$. Then $$ \sum_{i=1}^da_i^2b_i>0 $$ and the inequality doesn't hold.
If $b_i\le0$, for all $i$, we can substitute $b_i$ with $-b_i$ and the terms in the left-hand and right-hand sides wouldn't change. Thus it is not restrictive to assume $b_i\ge0$, for all $i$.
Applying Cauchy-Schwarz to $(a_1\sqrt{b_1},\dots,a_d\sqrt{b_d})$ and $(\sqrt{b_1},\dots,\sqrt{b_n})$ proves the inequality.