public static double blackFormulaImpliedStdDev(final Option.Type optionType,@Real double strike,@Real double forward,@Real final double blackPrice,@DiscountFactor final double discount,@Real double guess,@Real final double accuracy,@Real final double displacement){
  final int maxIterations=100;
  QL.require(strike >= 0.0,"strike must be non-negative");
  QL.require(forward > 0.0,"forward must be positive");
  QL.require(displacement >= 0.0,"displacement must be non-negative");
  QL.require(blackPrice >= 0.0,"blackPrice must be non-negative");
  QL.require(discount > 0.0,"discount must be positive");
  strike=strike + displacement;
  forward=forward + displacement;
  if (Double.isNaN(guess))   guess=blackFormulaImpliedStdDevApproximation(optionType,strike,forward,blackPrice,discount,displacement);
 else   if (guess < 0.0)   throw new IllegalArgumentException("stddev guess (" + guess + ") must be non-negative");
  final BlackImpliedStdDevHelper f=new BlackImpliedStdDevHelper(optionType,strike,forward,blackPrice / discount);
  final NewtonSafe solver=new NewtonSafe();
  solver.setMaxEvaluations(maxIterations);
  final double minSdtDev=0.0, maxstddev=3.0;
  final double stddev=solver.solve(f,accuracy,guess,minSdtDev,maxstddev);
  if (stddev >= 0.0)   return stddev;
  throw new ArithmeticException("a negative value was calculated");
}

public static double blackFormulaImpliedStdDev ( final Option . Type optionType , @ Real double strike , @ Real double forward , @ Real final double blackPrice , @ DiscountFactor final double discount , @ Real double guess , @ Real final double accuracy , @ Real final double displacement ) { final int maxIterations = 100 ; QL . require ( strike >= 0.0 , "strike must be non-negative" ) ; QL . require ( forward > 0.0 , "forward must be positive" ) ; QL . require ( displacement >= 0.0 , "displacement must be non-negative" ) ; QL . require ( blackPrice >= 0.0 , "blackPrice must be non-negative" ) ; QL . require ( discount > 0.0 , "discount must be positive" ) ; strike = strike + displacement ; forward = forward + displacement ; if ( Double . isNaN ( guess ) ) guess = blackFormulaImpliedStdDevApproximation ( optionType , strike , forward , blackPrice , discount , displacement ) ; else if ( guess < 0.0 ) throw new IllegalArgumentException ( "stddev guess (" + guess + ") must be non-negative" ) ; final BlackImpliedStdDevHelper f = new BlackImpliedStdDevHelper ( optionType , strike , forward , blackPrice / discount ) ; final NewtonSafe solver = new NewtonSafe ( ) ; solver . setMaxEvaluations ( maxIterations ) ; final double minSdtDev = 0.0 , maxstddev = 3.0 ; final double stddev = solver . solve ( f , accuracy , guess , minSdtDev , maxstddev ) ; if ( stddev >= 0.0 ) return stddev ; throw new ArithmeticException ( "a negative value was calculated" ) ; }
black 1976 implied standard deviation , i . e . volatility * sqrt ( timetomaturity )
