Given $f$ and $d$ sufficiently integrable functions defined on a bounded domain $\Omega$, consider: $$\min_{y \in L^2(\Omega),\\ y \leq f \text{ a.e.}} \lVert y-d \rVert_{L^2(\Omega)}^2$$
My question is, is it possible to give a formula for the minimiser $y^*$ explicitly? I know it's the projection of $d$ onto the set $K=\{ v \in L^2 : v \leq f \text{ a.e.}\}$ but I want an explicit formula.
I thought maybe $y^* = \frac{d}{|d|}f$ but even if this is right this needs positivity of $f$ to make sense. So I don't know.