





from math import exp

def      __snake_case						(					_lowerCAmelCase : float	) ->						float:
   return 8 * x - 2 * exp(-x	)

def      __snake_case						(					_lowerCAmelCase : float				,				_lowerCAmelCase : float				,				_lowerCAmelCase : int	) ->						float:
   A_					:				Tuple          =			lower_bound
   A_					:				List[Any]          =			upper_bound
   for _ in range(0				,				_lowerCAmelCase	):
      A_      ,						A_					:				List[str]          =			xa, xa - (f(_lowerCAmelCase	) * (xa - xa)) / (f(_lowerCAmelCase	) - f(_lowerCAmelCase	))
   return xa


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







import warnings
from collections.abc import Callable
from typing import Any

import numpy
from matplotlib import pyplot

_lowerCAmelCase							:      Union[str, Any]						=	0.25 + 0.0j
_lowerCAmelCase							:      str						=	-0.4 + 0.6j
_lowerCAmelCase							:      Optional[int]						=	-0.1 + 0.6_5_1j
_lowerCAmelCase							:      Union[str, Any]						=	-2.0
_lowerCAmelCase							:      str						=	56
_lowerCAmelCase							:      Optional[Any]						=	2.0
_lowerCAmelCase							:      Dict						=	666

def      __snake_case						(					_lowerCAmelCase : complex				,				_lowerCAmelCase : numpy.ndarray	) ->						numpy.ndarray:
   return numpy.exp(_lowerCAmelCase	) + c_parameter

def      __snake_case						(					_lowerCAmelCase : complex				,				_lowerCAmelCase : numpy.ndarray	) ->						numpy.ndarray:
   return z_values * z_values + c_parameter

def      __snake_case						(					_lowerCAmelCase : float				,				_lowerCAmelCase : int	) ->						numpy.ndarray:
   A_					:				Tuple          =			numpy.linspace(-window_size				,				_lowerCAmelCase				,				_lowerCAmelCase	)
   A_					:				Optional[int]          =			x.reshape((nb_pixels, 1)	)
   A_					:				str          =			numpy.linspace(-window_size				,				_lowerCAmelCase				,				_lowerCAmelCase	)
   A_					:				Tuple          =			y.reshape((1, nb_pixels)	)
   return x + 1.0j * y

def      __snake_case						(					_lowerCAmelCase : Callable[[Any, numpy.ndarray], numpy.ndarray]				,				_lowerCAmelCase : Any				,				_lowerCAmelCase : int				,				_lowerCAmelCase : numpy.ndarray				,				_lowerCAmelCase : float | None = None				,				) ->						numpy.ndarray:
   A_					:				List[Any]          =			z_a.astype("complex64"	)
   for _ in range(_lowerCAmelCase	):
      A_					:				List[Any]          =			eval_function(_lowerCAmelCase				,				_lowerCAmelCase	)
      if infinity is not None:
         numpy.nan_to_num(_lowerCAmelCase				,				copy=_lowerCAmelCase				,				nan=_lowerCAmelCase	)
         A_					:				List[Any]          =			infinity
   return z_n

def      __snake_case						(					_lowerCAmelCase : str				,				_lowerCAmelCase : Any				,				_lowerCAmelCase : float				,				_lowerCAmelCase : numpy.ndarray				,				) ->						None:
   A_					:				Optional[int]          =			(abs(_lowerCAmelCase	)).transpose()
   A_					:				Optional[int]          =			abs_z_final[::-1, :]
   pyplot.matshow(abs_z_final < escape_radius	)
   pyplot.title(f"Julia set of ${function_label}$, $c={function_params}$"	)
   pyplot.show()

def      __snake_case						(					) ->						None:
   warnings.filterwarnings(
       "ignore"				,				category=_lowerCAmelCase				,				message="overflow encountered in multiply"	)
   warnings.filterwarnings(
       "ignore"				,				category=_lowerCAmelCase				,				message="invalid value encountered in multiply"				,				)
   warnings.filterwarnings(
       "ignore"				,				category=_lowerCAmelCase				,				message="overflow encountered in absolute"	)
   warnings.filterwarnings(
       "ignore"				,				category=_lowerCAmelCase				,				message="overflow encountered in exp"	)


if __name__ == "__main__":
 _lowerCAmelCase							:      List[str]						=	prepare_grid(window_size, nb_pixels)

 ignore_overflow_warnings()  # See file header for explanations

 _lowerCAmelCase							:      str						=	24
 _lowerCAmelCase							:      str						=	2 * abs(c_cauliflower) + 1
 _lowerCAmelCase							:      Optional[Any]						=	iterate_function(
     eval_quadratic_polynomial,
     c_cauliflower,
     nb_iterations,
     z_a,
     infinity=1.1 * escape_radius,
 )
 show_results('''z^2+c''', c_cauliflower, escape_radius, z_final)

 _lowerCAmelCase							:      Optional[int]						=	64
 _lowerCAmelCase							:      List[Any]						=	2 * abs(c_polynomial_a) + 1
 _lowerCAmelCase							:      List[str]						=	iterate_function(
     eval_quadratic_polynomial,
     c_polynomial_a,
     nb_iterations,
     z_a,
     infinity=1.1 * escape_radius,
 )
 show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)

 _lowerCAmelCase							:      Tuple						=	161
 _lowerCAmelCase							:      int						=	2 * abs(c_polynomial_a) + 1
 _lowerCAmelCase							:      List[Any]						=	iterate_function(
     eval_quadratic_polynomial,
     c_polynomial_a,
     nb_iterations,
     z_a,
     infinity=1.1 * escape_radius,
 )
 show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)

 _lowerCAmelCase							:      List[str]						=	12
 _lowerCAmelCase							:      str						=	1_0000.0
 _lowerCAmelCase							:      Tuple						=	iterate_function(
     eval_exponential,
     c_exponential,
     nb_iterations,
     z_a + 2,
     infinity=1.0e10,
 )
 show_results('''e^z+c''', c_exponential, escape_radius, z_final)
