Source:
public double getPriceAdjoint(EuropeanVanillaOption option, NormalFunctionData data, double[] priceDerivative) { ArgChecker.notNull(option, "option"); ArgChecker.notNull(data, "data"); ArgChecker.notNull(priceDerivative, "derivatives"); ArgChecker.isTrue(priceDerivative.length == 3, "array size"); double strike = option.getStrike(); double t = option.getTimeToExpiry(); double forward = data.getForward(); double numeraire = data.getNumeraire(); double sigma = data.getNormalVolatility(); int sign = option.isCall() ? 1 : -1; double price; double nCDF = 0.0; double nPDF = 0.0; double arg = 0.0; double x = 0.0; double sigmaRootT = sigma * Math.sqrt(t); if (sigmaRootT < 1e-16) { x = sign * (forward - strike); price = (x > 0 ? numeraire * x : 0.0); } else { arg = sign * (forward - strike) / sigmaRootT; nCDF = NORMAL.getCDF(arg); nPDF = NORMAL.getPDF(arg); price = numeraire * (sign * (forward - strike) * nCDF + sigmaRootT * nPDF); } double priceBar = 1.0; if (sigmaRootT < 1e-16) { double xBar = (x > 0 ? numeraire : 0.0); priceDerivative[0] = sign * xBar; priceDerivative[2] = -priceDerivative[0]; priceDerivative[1] = 0.0; } else { double nCDFBar = numeraire * (sign * (forward - strike)) * priceBar; double nPDFBar = numeraire * sigmaRootT * priceBar; double argBar = nPDF * nCDFBar - nPDF * arg * nPDFBar; priceDerivative[0] = numeraire * sign * nCDF * priceBar + sign / sigmaRootT * argBar; priceDerivative[2] = -priceDerivative[0]; double sigmaRootTBar = -arg / sigmaRootT * argBar + numeraire * nPDF * priceBar; priceDerivative[1] = Math.sqrt(t) * sigmaRootTBar; } return price; }

Target:
public double getPriceAdjoint(EuropeanVanillaOption option, NormalFunctionData data, double[] priceDerivative) { ArgChecker.notNull(option, "option"); ArgChecker.notNull(data, "data"); ArgChecker.notNull(priceDerivative, "derivatives"); ArgChecker.isTrue(priceDerivative.length == 3, "array size"); double strike = option.getStrike(); double t = option.getTimeToExpiry(); double forward = data.getForward(); double numeraire = data.getNumeraire(); double sigma = data.getNormalVolatility(); int sign = option.isCall() ? 1 : -1; double price; double nCDF = 0.0; double nPDF = 0.0; double arg = 0.0; double x = 0.0; double sigmaRootT = sigma * Math.sqrt(t); if (sigmaRootT < NEAR_ZERO) { x = sign * (forward - strike); price = (x > 0 ? numeraire * x : 0.0); } else { arg = sign * (forward - strike) / sigmaRootT; nCDF = NORMAL.getCDF(arg); nPDF = NORMAL.getPDF(arg); price = numeraire * (sign * (forward - strike) * nCDF + sigmaRootT * nPDF); } double priceBar = 1.0; if (sigmaRootT < NEAR_ZERO) { double xBar = (x > 0 ? numeraire : 0.0); priceDerivative[0] = sign * xBar; priceDerivative[2] = -priceDerivative[0]; priceDerivative[1] = 0.0; } else { double nCDFBar = numeraire * (sign * (forward - strike)) * priceBar; double nPDFBar = numeraire * sigmaRootT * priceBar; double argBar = nPDF * nCDFBar - nPDF * arg * nPDFBar; priceDerivative[0] = numeraire * sign * nCDF * priceBar + sign / sigmaRootT * argBar; priceDerivative[2] = -priceDerivative[0]; double sigmaRootTBar = -arg / sigmaRootT * argBar + numeraire * nPDF * priceBar; priceDerivative[1] = Math.sqrt(t) * sigmaRootTBar; } return price; }