






import random







class 		_a       :





   '''simple docstring'''






   def __init__(   self			,				UpperCAmelCase_			,				UpperCAmelCase_)	-> Any:




          '''simple docstring'''




          lowercase__:    Tuple        =      x
          lowercase__:    Dict        =      y





   def __lowercase    (   self)	-> List[str]:




          '''simple docstring'''




          return (self.x**2 + self.y**2) <= 1





   @classmethod
   def __lowercase    (   cls)	-> Optional[int]:




          '''simple docstring'''




          return cls(x=random.random()			,				y=random.random())







def     A(  snake_case_		):
       """simple docstring"""





       if number_of_simulations < 1:
              raise ValueError("At least one simulation is necessary to estimate PI."		)

       lowercase__:    Any        =      0
       for _ in range(_lowerCAmelCase		):
              lowercase__:    str        =      Point.random_unit_square()

              if random_point.is_in_unit_circle():
                     number_in_unit_circle += 1

       return 4 * number_in_unit_circle / number_of_simulations


if __name__ == "__main__":
  # import doctest

  # doctest.testmod()
  from math import pi

  UpperCamelCase			=      """Please enter the desired number of Monte Carlo simulations: """
  UpperCamelCase			=      estimate_pi(int(input(prompt).strip()))
  print(F"An estimate of PI is {my_pi} with an error of {abs(my_pi - pi)}")














"""simple docstring"""





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

import numpy
from matplotlib import pyplot

UpperCamelCase			=      0.25 + 0.0j
UpperCamelCase			=      -0.4 + 0.6j
UpperCamelCase			=      -0.1 + 0.651j
UpperCamelCase			=      -2.0
UpperCamelCase			=      56
UpperCamelCase			=      2.0
UpperCamelCase			=      6_66






def     A(  snake_case_						,       snake_case_		):
       """simple docstring"""





       return numpy.exp(snake_case_		) + c_parameter






def     A(  snake_case_						,       snake_case_		):
       """simple docstring"""





       return z_values * z_values + c_parameter






def     A(  snake_case_						,       snake_case_		):
       """simple docstring"""





       lowercase__:    str        =      numpy.linspace(-window_size						,       snake_case_						,       snake_case_		)
       lowercase__:    Union[str, Any]        =      x.reshape((nb_pixels, 1)		)
       lowercase__:    Any        =      numpy.linspace(-window_size						,       snake_case_						,       snake_case_		)
       lowercase__:    List[Any]        =      y.reshape((1, nb_pixels)		)
       return x + 1.0J * y






def     A(  snake_case_						,       snake_case_						,       snake_case_						,       snake_case_						,       snake_case_ = None						,       ):
       """simple docstring"""





       lowercase__:    List[Any]        =      z_a.astype("complex64"		)
       for _ in range(snake_case_		):
              lowercase__:    Any        =      eval_function(snake_case_						,       snake_case_		)
              if infinity is not None:
                     numpy.nan_to_num(snake_case_						,       copy=snake_case_						,       nan=snake_case_		)
                     lowercase__:    Union[str, Any]        =      infinity
       return z_n






def     A(  snake_case_						,       snake_case_						,       snake_case_						,       snake_case_						,       ):
       """simple docstring"""





       lowercase__:    Union[str, Any]        =      (abs(snake_case_		)).transpose()
       lowercase__:    List[Any]        =      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     A(  ):
       """simple docstring"""





       warnings.filterwarnings(
           "ignore"						,       category=snake_case_						,       message="overflow encountered in multiply"		)
       warnings.filterwarnings(
           "ignore"						,       category=snake_case_						,       message="invalid value encountered in multiply"						,       )
       warnings.filterwarnings(
           "ignore"						,       category=snake_case_						,       message="overflow encountered in absolute"		)
       warnings.filterwarnings(
           "ignore"						,       category=snake_case_						,       message="overflow encountered in exp"		)


if __name__ == "__main__":
  UpperCamelCase			=      prepare_grid(window_size, nb_pixels)

  ignore_overflow_warnings()  # See file header for explanations

  UpperCamelCase			=      24
  UpperCamelCase			=      2 * abs(c_cauliflower) + 1
  UpperCamelCase			=      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)

  UpperCamelCase			=      64
  UpperCamelCase			=      2 * abs(c_polynomial_a) + 1
  UpperCamelCase			=      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)

  UpperCamelCase			=      1_61
  UpperCamelCase			=      2 * abs(c_polynomial_a) + 1
  UpperCamelCase			=      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)

  UpperCamelCase			=      12
  UpperCamelCase			=      10_000.0
  UpperCamelCase			=      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)






