As far as I understand RegionNearest-function the last command
p = {x1, y1};
np = RegionNearest[Disk[]][p]
abs=(np - p) . (np - p) (* scalar *)
gives a result
which is scalar!
But if I substitude point p by {x1->1/2,y1->1/3}
abs /.{x1->1/2,y1->1/3}
(*{1/36, 1/36}*)
I get a list of values?
What's wrong here? Thanks!

absis not a scalar, it has a list inside of it (and squaring a list gives a list of squares) ... I think the problem is innp - pnot "combining" the components inListandPiecewisecorrectly. – Domen Apr 14 '23 at 09:08pandnpboth are lists! Scalar product should give a scalar I think. – Ulrich Neumann Apr 14 '23 at 09:10{x1, y1} + Piecewise[{{{x2, y2}, cond}}, {x3, y2}].Piecewisegets distributed into each component! So if you then do% /. cond->True, you don't get one vector – as one might expect. – Domen Apr 14 '23 at 09:13abs = (np~plus~-p) . (np~plus~-p); abs /. {x1 -> 1/2, y1 -> 1/3} /. plus -> Plus– Domen Apr 14 '23 at 09:26