code: def test_gh_5557():
      # Show that without the changes in 5557 brentq and brenth might
      # only achieve a tolerance of 2*(xtol + rtol*|res|).
  
      # f linearly interpolates (0, -0.1), (0.5, -0.1), and (1,
      # 0.4). The important parts are that |f(0)| < |f(1)| (so that
      # brent takes 0 as the initial guess), |f(0)| < atol (so that
      # brent accepts 0 as the root), and that the exact root of f lies
      # more than atol away from 0 (so that brent doesn't achieve the
      # desired tolerance).
      def f(x):
          if x < 0.5:
              return -0.1
          else:
              return x - 0.6
  
      atol = 0.51
      rtol = 4 * _FLOAT_EPS
      methods = [zeros.brentq, zeros.brenth]
      for method in methods:
          res = method(f, 0, 1, xtol=atol, rtol=rtol)
          assert_allclose(0.6, res, atol=atol, rtol=rtol)
  
imports: import pytest
  from math import sqrt, exp, sin, cos
  from functools import lru_cache
  from numpy.testing import assert_warns, assert_, assert_allclose, assert_equal, assert_array_equal, suppress_warnings
  import numpy
  from numpy import finfo, power, nan, isclose
  from scipy.optimize import zeros, newton, root_scalar
  from scipy._lib._util import getfullargspec_no_self
  from scipy.optimize._tstutils import get_tests, functions, fstrings
label_desc: Use image node_id 10 for calling a global function with example usage: test_gh_5557() and returns: unknown, unknown