Suppose there's a projective $R$-module $P$ (non-free). We know that there is another $R$-module $M$ such that $P\oplus M$ is free over $R$. Is there a way to write down such an $M$ in terms of $P$?
If this is not always tractable, is it possible in certain specialized circumstances? The setting that comes to mind is where $P$ is a non-principal ideal of the ring of integers of a number field (as Wikipedia says this is an instance of $P$ being projective but not free).
(This was originally posted on math.stackexchange but I realized that here might be the better place to ask, apologies if not.)