


from math import exp



def      __lowerCAmelCase    (				snake_case						:     float			)							->				float:
   return 8 * x - 2 * exp(-x			)



def      __lowerCAmelCase    (				snake_case						:     float    ,   snake_case						:     float    ,   snake_case						:     int			)							->				float:
   __lowerCamelCase:					Any	 =						lower_bound
   __lowerCamelCase:					int	 =						upper_bound
   for _ in range(0    ,   snake_case			):
      __lowerCamelCase ,  __lowerCamelCase:					Dict	 =						xa, xa - (f(snake_case			) * (xa - xa)) / (f(snake_case			) - f(snake_case			))
   return xa


if __name__ == "__main__":
   print(F"""Example: {secant_method(1, 3, 2)}""")






_A		:					Union[str, Any]          =							1_000



def      __lowerCAmelCase    (				snake_case						:     float			)							->				float:
   return x * x



def      __lowerCAmelCase    (				snake_case						:     Optional[int]    ,   snake_case						:     float    ,   snake_case						:     float    ,   snake_case						:     int = 4			)							->				float:
   assert callable(
       snake_case			), f'the function(object) passed should be callable your input : {function}'
   assert isinstance(snake_case    ,   (float, int)			), f'a should be float or integer your input : {a}'
   assert isinstance(function(snake_case			)    ,   (float, int)			), (
       "the function should return integer or float return type of your function, "
       f'{type(snake_case			)}'
   )
   assert isinstance(snake_case    ,   (float, int)			), f'b should be float or integer your input : {b}'
   assert (
       isinstance(snake_case    ,   snake_case			) and precision > 0
   ), f'precision should be positive integer your input : {precision}'

   # just applying the formula of simpson for approximate integration written in
   # mentioned article in first comment of this file and above this function

   __lowerCamelCase:					List[str]	 =						(b - a) / N_STEPS
   __lowerCamelCase:					Optional[Any]	 =						function(snake_case			) + function(snake_case			)

   for i in range(1    ,   snake_case			):
      __lowerCamelCase:					Dict	 =						a + h * i
      result += function(snake_case			) * (4 if i % 2 else 2)

   result *= h / 3
   return round(snake_case    ,   snake_case			)


if __name__ == "__main__":
   import doctest

   doctest.testmod()


