tax $500 between these amounts $1500 and $2000 relative to their percentage of the total $4000.

What? There should not be a remaining 62.50. Something went wrong. Please remember that results should make sense. When your solution fails to make sense, rework your arithmetic, don't question the mathematics.

(2000 / 4000) * 500 = (1/2) * 500 = 250

(500 / 4000 ) * 500 = (1/8) * 500 = 62.50

Since we like to avoid rounding errors, 500 - 250 - 62.50 = 187.50

Now check

(1500 / 4000 ) * 500 = (3/8) * 500 = 187.50

Now you are done.

Of course, in this case, figuring out what the problem is and what it wants turns out to be the hard part.