### Question:
CoxRossRubinsteinLatticeSpecification implements LatticeSpecification { @Override public DoubleArray getParametersTrinomial(double volatility, double interestRate, double dt) { double dx = volatility * Math.sqrt(2d * dt); double upFactor = Math.exp(dx); double downFactor = Math.exp(-dx); double factor1 = Math.exp(0.5 * interestRate * dt); double factor2 = Math.exp(0.5 * dx); double factor3 = Math.exp(-0.5 * dx); double upProbability = pow2((factor1 - factor3) / (factor3 - factor2)); double downProbability = pow2((factor2 - factor1) / (factor3 - factor2)); double middleProbability = 1d - upProbability - downProbability; return DoubleArray.of(upFactor, 1d, downFactor, upProbability, middleProbability, downProbability); }  @Override DoubleArray getParametersTrinomial(double volatility, double interestRate, double dt);  }### Answer:
@Test public void test_formula() { CoxRossRubinsteinLatticeSpecification test = new CoxRossRubinsteinLatticeSpecification(); DoubleArray computed = test.getParametersTrinomial(VOL, RATE, DT); double u = Math.exp(VOL * Math.sqrt(2.0 * DT)); double d = Math.exp(-VOL * Math.sqrt(2.0 * DT)); double up = Math.pow((Math.exp(0.5 * RATE * DT) - Math.exp(-VOL * Math.sqrt(0.5 * DT))) / (Math.exp(VOL * Math.sqrt(0.5 * DT)) - Math.exp(-VOL * Math.sqrt(0.5 * DT))), 2); double dp = Math.pow((Math.exp(VOL * Math.sqrt(0.5 * DT)) - Math.exp(0.5 * RATE * DT)) / (Math.exp(VOL * Math.sqrt(0.5 * DT)) - Math.exp(-VOL * Math.sqrt(0.5 * DT))), 2); DoubleArray expected = DoubleArray.of(u, 1d, d, up, 1d - up - dp, dp); assertThat(DoubleArrayMath.fuzzyEquals(computed.toArray(), expected.toArray(), 1.0e-14)).isTrue(); }