finished karchermeninv function and DP_mean