

import colorsys

from PIL import Image  # type: ignore

def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   float     ,					SCREAMING_SNAKE_CASE_		:   float     ,					SCREAMING_SNAKE_CASE_		:   int      ):



     '''simple docstring'''





     lowercase__   :       Union[str, Any]				=	x
     lowercase__   :       Optional[Any]				=	y
     for step in range(SCREAMING_SNAKE_CASE_      ):  # noqa: B007
          lowercase__   :       Tuple				=	a * a - b * b + x
          lowercase__   :       str				=	2 * a * b + y
          lowercase__   :       Union[str, Any]				=	a_new

          # divergence happens for all complex number with an absolute value
          # greater than 4
          if a * a + b * b > 4:
               break
     return step / (max_step - 1)

def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   float      ):



     '''simple docstring'''





     if distance == 1:
          return (0, 0, 0)
     else:
          return (255, 255, 255)

def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   float      ):



     '''simple docstring'''





     if distance == 1:
          return (0, 0, 0)
     else:
          return tuple(round(i * 255      ) for i in colorsys.hsv_to_rgb(SCREAMING_SNAKE_CASE_     ,					1     ,					1      )      )

def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   int = 800     ,					SCREAMING_SNAKE_CASE_		:   int = 600     ,					SCREAMING_SNAKE_CASE_		:   float = -0.6     ,					SCREAMING_SNAKE_CASE_		:   float = 0     ,					SCREAMING_SNAKE_CASE_		:   float = 3.2     ,					SCREAMING_SNAKE_CASE_		:   int = 50     ,					SCREAMING_SNAKE_CASE_		:   bool = True     ,					):



     '''simple docstring'''





     lowercase__   :       Optional[int]				=	Image.new('RGB'     ,					(image_width, image_height)      )
     lowercase__   :       Optional[int]				=	img.load()

     # loop through the image-coordinates
     for image_x in range(SCREAMING_SNAKE_CASE_      ):
          for image_y in range(SCREAMING_SNAKE_CASE_      ):
               # determine the figure-coordinates based on the image-coordinates
               lowercase__   :       Union[str, Any]				=	figure_width / image_width * image_height
               lowercase__   :       Union[str, Any]				=	figure_center_x + (image_x / image_width - 0.5) * figure_width
               lowercase__   :       Tuple				=	figure_center_y + (image_y / image_height - 0.5) * figure_height

               lowercase__   :       Any				=	get_distance(SCREAMING_SNAKE_CASE_     ,					SCREAMING_SNAKE_CASE_     ,					SCREAMING_SNAKE_CASE_      )

               # color the corresponding pixel based on the selected coloring-function
               if use_distance_color_coding:
                    lowercase__   :       Optional[int]				=	get_color_coded_rgb(SCREAMING_SNAKE_CASE_      )
               else:
                    lowercase__   :       Optional[int]				=	get_black_and_white_rgb(SCREAMING_SNAKE_CASE_      )

     return img


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       # colored version, full figure
       snake_case_        =			get_image()

       # uncomment for colored version, different section, zoomed in
       # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
       # figure_width = 0.8)

       # uncomment for black and white version, full figure
       # img = get_image(use_distance_color_coding = False)

       # uncomment to save the image
       # img.save("mandelbrot.png")

       img.show()




from __future__ import annotations

from collections.abc import Callable

def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   Callable[[int | float], int | float]     ,					SCREAMING_SNAKE_CASE_		:   int | float     ,					SCREAMING_SNAKE_CASE_		:   int | float     ,					SCREAMING_SNAKE_CASE_		:   int = 100     ,					):



     '''simple docstring'''





     lowercase__   :       Tuple				=	x_start
     lowercase__   :       Tuple				=	fnc(SCREAMING_SNAKE_CASE_      )
     lowercase__   :       List[Any]				=	0.0
     for _ in range(SCREAMING_SNAKE_CASE_      ):
          # Approximates small segments of curve as linear and solve
          # for trapezoidal area
          lowercase__   :       Any				=	(x_end - x_start) / steps + xa
          lowercase__   :       Optional[Any]				=	fnc(SCREAMING_SNAKE_CASE_      )
          area += abs(fxa + fxa      ) * (xa - xa) / 2
          # Increment step
          lowercase__   :       Any				=	xa
          lowercase__   :       str				=	fxa
     return area


if __name__ == "__main__":

       def      snake_case__      (   SCREAMING_SNAKE_CASE_		:   Tuple      ):



            '''simple docstring'''





            return x**3 + x**2

       print('''f(x) = x^3 + x^2''')
       print('''The area between the curve, x = -5, x = 5 and the x axis is:''')
       snake_case_        =			10
       while i <= 100_000:
              print(F'''with {i} steps: {trapezoidal_area(f, -5, 5, i)}''')
              i *= 10

