Yes, I was using "squared error" because the OP was. What I wrote was modulo a square root missing here and there!