should I write this
srcset="small.jpg 1x 500w, medium.jpg 2x 1000w, large.jpg 3x 1500w"
or this
srcset="small.jpg 500w, medium.jpg 1000w, large.jpg 1500w"
are the two expression the same?
Your first code block is incorrect, see this MDN documentation:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#attr-srcset
A srcset attribute can contain either width descriptors(w) or pixel density descriptors (ex. 2x), but not a combination of both.
The second code block is correct.
Side note: the browser will automatically take into account the device's pixel density when choosing which of the three images to download.