/src/main/java/net/finmath/functions/AnalyticFormulas.java
while( solver.getAccuracy( ) > maxAccuracy && !solver.isDone( ) && solver.getNumberOfIterations( ) < maxIterations) { f
f while ( solver.getAccuracy ( ) > maxAccuracy && !solver.isDone ( ) && solver.getNumberOfIterations ( ) < maxIterations ) {
final double q = 2.0 * Math.abs(Math.log(forward/optionStrike)) / optionMaturity; final double volatilityLowerBound = p + Math.sqrt(Math.max(p * p - q, 0.0)); final double volatilityUpperBound = p + Math.sqrt( p * p + q ); if(Math.abs(volatilityLowerBound - volatilityUpperBound) < maxAccuracy) { return (volatilityLowerBound+volatilityUpperBound) / 2.0; } <extra_id_0> final double volatility = solver.getNextPoint(); final double dPlus = (Math.log(forward / optionStrike) + 0.5 * volatility * volatility * optionMaturity) / (volatility * Math.sqrt(optionMaturity)); final double dMinus = dPlus - volatility * Math.sqrt(optionMaturity); final double valueAnalytic = (forward * NormalDistribution.cumulativeDistribution(dPlus) - optionStrike * NormalDistribution.cumulativeDistribution(dMinus)) * payoffUnit; final double derivativeAnalytic = forward * Math.sqrt(optionMaturity) * Math.exp(-0.5*dPlus*dPlus) / Math.sqrt(2.0*Math.PI) * payoffUnit; final double error = valueAnalytic - optionValue;