How to map 0.40-1.87V to 0-5V?
The gist of it is basically this:

Let's call the input range (X, Y), the output range (J, K).

Then the 'mapping function' is as follows:

$$
V_{\mathrm{out}} =  {V_{\mathrm{in}} - X\over Y-X} \times (K-J)+J
$$

You can easily derive it - what the division by the endpoints of one range does is it maps the input to some 0 to 1 range. Then you can 'stretch' it to cover the other range. Then just adjust for the offsets.

The hardware implementation usually follows that pretty well.

First, you get the difference of the input against the reference (\$X\$). Then you amplify it (by the \$K-J \over Y-X\$) and apply the offset \$J\$ if required.

In your case, the \$X\$ and \$Y\$ are 0.40 V and 1.87 V respectively, \$J\$ is 0 V (no output offset relative to ground), and \$K\$ is 5V.

So you just need to implement a thing that does:

$$
V_{\mathrm{out}} = {V_{\mathrm{in}} - 0.40 \mathrm{V} \over 1.87\mathrm{V} - 0.4\mathrm{V}} \times 5\mathrm{V}
$$

or

$$
V_{\mathrm{out}} = (V_{\mathrm{in}} - 0.40 \mathrm{V}) \times {5\mathrm{V} \over 1.87\mathrm{V} - 0.4\mathrm{V}} = (V_{\mathrm{in}} - 0.40 \mathrm{V}) \times 3.4
$$

So. You just need to make a differential amplifier that measures against a 0.4V 'reference', and amplifies stuff by 3.4!