code: def test_dup_refine_real_root():
      R, x = ring("x", ZZ)
      f = x**2 - 2
  
      assert R.dup_refine_real_root(f, QQ(1), QQ(1), steps=1) == (
          QQ(1),
          QQ(1),
      )
      assert R.dup_refine_real_root(f, QQ(1), QQ(1), steps=9) == (
          QQ(1),
          QQ(1),
      )
  
      raises(
          ValueError, lambda: R.dup_refine_real_root(f, QQ(-2), QQ(2))
      )
  
      s, t = QQ(1, 1), QQ(2, 1)
  
      assert R.dup_refine_real_root(f, s, t, steps=0) == (
          QQ(1, 1),
          QQ(2, 1),
      )
      assert R.dup_refine_real_root(f, s, t, steps=1) == (
          QQ(1, 1),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=2) == (
          QQ(4, 3),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=3) == (
          QQ(7, 5),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=4) == (
          QQ(7, 5),
          QQ(10, 7),
      )
  
      s, t = QQ(1, 1), QQ(3, 2)
  
      assert R.dup_refine_real_root(f, s, t, steps=0) == (
          QQ(1, 1),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=1) == (
          QQ(4, 3),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=2) == (
          QQ(7, 5),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=3) == (
          QQ(7, 5),
          QQ(10, 7),
      )
      assert R.dup_refine_real_root(f, s, t, steps=4) == (
          QQ(7, 5),
          QQ(17, 12),
      )
  
      s, t = QQ(1, 1), QQ(5, 3)
  
      assert R.dup_refine_real_root(f, s, t, steps=0) == (
          QQ(1, 1),
          QQ(5, 3),
      )
      assert R.dup_refine_real_root(f, s, t, steps=1) == (
          QQ(1, 1),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=2) == (
          QQ(7, 5),
          QQ(3, 2),
      )
      assert R.dup_refine_real_root(f, s, t, steps=3) == (
          QQ(7, 5),
          QQ(13, 9),
      )
      assert R.dup_refine_real_root(f, s, t, steps=4) == (
          QQ(7, 5),
          QQ(27, 19),
      )
  
      s, t = QQ(-1, 1), QQ(-2, 1)
  
      assert R.dup_refine_real_root(f, s, t, steps=0) == (
          -QQ(2, 1),
          -QQ(1, 1),
      )
      assert R.dup_refine_real_root(f, s, t, steps=1) == (
          -QQ(3, 2),
          -QQ(1, 1),
      )
      assert R.dup_refine_real_root(f, s, t, steps=2) == (
          -QQ(3, 2),
          -QQ(4, 3),
      )
      assert R.dup_refine_real_root(f, s, t, steps=3) == (
          -QQ(3, 2),
          -QQ(7, 5),
      )
      assert R.dup_refine_real_root(f, s, t, steps=4) == (
          -QQ(10, 7),
          -QQ(7, 5),
      )
  
      raises(
          RefinementFailed,
          lambda: R.dup_refine_real_root(f, QQ(0), QQ(1)),
      )
  
      s, t, u, v, w = QQ(1), QQ(2), QQ(24, 17), QQ(17, 12), QQ(7, 5)
  
      assert R.dup_refine_real_root(f, s, t, eps=QQ(1, 100)) == (u, v)
      assert R.dup_refine_real_root(f, s, t, steps=6) == (u, v)
  
      assert R.dup_refine_real_root(
          f, s, t, eps=QQ(1, 100), steps=5
      ) == (w, v)
      assert R.dup_refine_real_root(
          f, s, t, eps=QQ(1, 100), steps=6
      ) == (u, v)
      assert R.dup_refine_real_root(
          f, s, t, eps=QQ(1, 100), steps=7
      ) == (u, v)
  
      s, t, u, v = QQ(-2), QQ(-1), QQ(-3, 2), QQ(-4, 3)
  
      assert R.dup_refine_real_root(f, s, t, disjoint=QQ(-5)) == (s, t)
      assert R.dup_refine_real_root(f, s, t, disjoint=-v) == (s, t)
      assert R.dup_refine_real_root(f, s, t, disjoint=v) == (u, v)
  
      s, t, u, v = QQ(1), QQ(2), QQ(4, 3), QQ(3, 2)
  
      assert R.dup_refine_real_root(f, s, t, disjoint=QQ(5)) == (s, t)
      assert R.dup_refine_real_root(f, s, t, disjoint=-u) == (s, t)
      assert R.dup_refine_real_root(f, s, t, disjoint=u) == (u, v)
  
imports: from sympy.polys.rings import ring
  from sympy.polys.domains import ZZ, QQ, ZZ_I, EX
  from sympy.polys.polyerrors import DomainError, RefinementFailed, PolynomialError
  from sympy.polys.rootisolation import dup_cauchy_upper_bound, dup_cauchy_lower_bound, dup_mignotte_sep_bound_squared
  from sympy.testing.pytest import raises
label_desc: Use image node_id 5 for calling a global function with example usage: test_dup_refine_real_root() without return types