As other posts have mentioned, Sony is certainly taking a loss. In the long term it is probably worth it for them in this instance since the $400 price ($100 less than Xbox One) really cut the legs off the Xbox One in the wake of the always-connected DRM fiasco (which Microsoft has since backed off on).
There's plenty of places for them to make up the difference if the original intent of increasing percentage of marketshare works (and it seems to be): they get a cut of every game sold, they are likely to sell a lot of PS+ memberships, accessory sales (extra controllers, the PS4 camera) and they will almost certainly get costs down faster than the retail price on the eventual redesigns (PS4 slim or whatever) in a couple years.
On a related note, I've had a PS4 since Friday and the machine is very, very nice.