class_docstr: Tests for methods in newton_vol module.
class_docstr_tok: ["Tests","for","methods","in","newton_vol","module","."]
docstr: Tests the Newton root finder recovers the volatility on Bachelier Model.
  
  These are the cases with negative underlying and strike.
docstr_tok: ["Tests","the","Newton","root","finder","recovers","the","volatility","on","Bachelier","Model",".","These","are","the","cases","with","negative","underlying","and","strike","."]
code: def test_bachelier_negative_underlying(self):
      """Tests the Newton root finder recovers the volatility on Bachelier Model.
  
      These are the cases with negative underlying and strike.
      """
      forwards = np.array([-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])
      strikes = np.array([1.0, 0.0, -1.0, -1.0, -1.0, -1.0, -0.5])
      expiries = np.array([1.0, 1.0, 1.0, 2.0, 0.5, 1.0, 1.0])
      discounts = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
      init_vols = np.array([2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0])
      is_call_options = np.array(
          [True, True, True, True, True, False, False]
      )
      volatilities = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
      prices = np.array(
          [
              0.0084907,
              0.0833155,
              0.3989423,
              0.5641896,
              0.2820948,
              0.3989423,
              0.6977965,
          ]
      )
      implied_vols, converged, failed = self.evaluate(
          tff.black_scholes.implied_vol_newton(
              prices=prices,
              strikes=strikes,
              expiries=expiries,
              forwards=forwards,
              discount_factors=discounts,
              is_call_options=is_call_options,
              initial_volatilities=init_vols,
              underlying_distribution=ImpliedVolUnderlyingDistribution.NORMAL,
              max_iterations=100,
          )
      )
      self.assertTrue(np.all(converged))
      self.assertFalse(np.any(failed))
      self.assertArrayNear(volatilities, implied_vols, 1e-6)
  
file_path: tf-quant-finance/tf_quant_finance/black_scholes/implied_vol_newton_root_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the ImpliedVolNewtonTest obj's underlying member method code with example usage: obj.test_bachelier_negative_underlying() without return types