Hyper-differential sensitivity analysis with respect to model discrepancy: mathematics and computation