





"""simple docstring"""




from math import pi, sqrt, tan





def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  if side_length < 0:
    raise ValueError('surface_area_cube() only accepts non-negative values'					)
  return 6 * side_length**2





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if length < 0 or breadth < 0 or height < 0:
    raise ValueError('surface_area_cuboid() only accepts non-negative values'					)
  return 2 * ((length * breadth) + (breadth * height) + (length * height))





def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  if radius < 0:
    raise ValueError('surface_area_sphere() only accepts non-negative values'					)
  return 4 * pi * radius**2





def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  if radius < 0:
    raise ValueError('surface_area_hemisphere() only accepts non-negative values'					)
  return 3 * pi * radius**2





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if radius < 0 or height < 0:
    raise ValueError('surface_area_cone() only accepts non-negative values'					)
  return pi * radius * (radius + (height**2 + radius**2) ** 0.5)





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if radius_a < 0 or radius_a < 0 or height < 0:
    raise ValueError(
        'surface_area_conical_frustum() only accepts non-negative values'					)
  A_  :       str										=  (height**2 + (radius_a - radius_a) ** 2) ** 0.5
  return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if radius < 0 or height < 0:
    raise ValueError('surface_area_cylinder() only accepts non-negative values'					)
  return 2 * pi * radius * (height + radius)





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if torus_radius < 0 or tube_radius < 0:
    raise ValueError('surface_area_torus() only accepts non-negative values'					)
  if torus_radius < tube_radius:
    raise ValueError(
        'surface_area_torus() does not support spindle or self intersecting tori'					)
  return 4 * pow(__UpperCamelCase ,					2					) * torus_radius * tube_radius





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if length < 0 or width < 0:
    raise ValueError('area_rectangle() only accepts non-negative values'					)
  return length * width





def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  if side_length < 0:
    raise ValueError('area_square() only accepts non-negative values'					)
  return side_length**2





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if base < 0 or height < 0:
    raise ValueError('area_triangle() only accepts non-negative values'					)
  return (base * height) / 2





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if sidea < 0 or sidea < 0 or sidea < 0:
    raise ValueError('area_triangle_three_sides() only accepts non-negative values'					)
  elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
    raise ValueError('Given three sides do not form a triangle'					)
  A_  :       Union[str, Any]										=  (sidea + sidea + sidea) / 2
  A_  :       Any										=  sqrt(
      semi_perimeter
      * (semi_perimeter - sidea)
      * (semi_perimeter - sidea)
      * (semi_perimeter - sidea)					)
  return area





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if base < 0 or height < 0:
    raise ValueError('area_parallelogram() only accepts non-negative values'					)
  return base * height





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if basea < 0 or basea < 0 or height < 0:
    raise ValueError('area_trapezium() only accepts non-negative values'					)
  return 1 / 2 * (basea + basea) * height





def 						UpperCAmelCase__		(     _UpperCAmelCase					):






  """simple docstring"""





  if radius < 0:
    raise ValueError('area_circle() only accepts non-negative values'					)
  return pi * radius**2





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if radius_x < 0 or radius_y < 0:
    raise ValueError('area_ellipse() only accepts non-negative values'					)
  return pi * radius_x * radius_y





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if diagonal_a < 0 or diagonal_a < 0:
    raise ValueError('area_rhombus() only accepts non-negative values'					)
  return 1 / 2 * diagonal_a * diagonal_a





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase					):






  """simple docstring"""





  if not isinstance(__UpperCamelCase ,					__UpperCamelCase					) or sides < 3:
    raise ValueError(
        'area_reg_polygon() only accepts integers greater than or \\nequal to three as number of sides'					)
  elif length < 0:
    raise ValueError(
        'area_reg_polygon() only accepts non-negative values as \\nlength of a side'					)
  return (sides * length**2) / (4 * tan(pi / sides					))
  return (sides * length**2) / (4 * tan(pi / sides					))


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

   print('[DEMO] Areas of various geometric shapes: \n')
   print(F"Rectangle: {area_rectangle(10, 20) = }")
   print(F"Square: {area_square(10) = }")
   print(F"Triangle: {area_triangle(10, 10) = }")
   print(F"Triangle: {area_triangle_three_sides(5, 12, 13) = }")
   print(F"Parallelogram: {area_parallelogram(10, 20) = }")
   print(F"Rhombus: {area_rhombus(10, 20) = }")
   print(F"Trapezium: {area_trapezium(10, 20, 30) = }")
   print(F"Circle: {area_circle(20) = }")
   print(F"Ellipse: {area_ellipse(10, 20) = }")
   print('\nSurface Areas of various geometric shapes: \n')
   print(F"Cube: {surface_area_cube(20) = }")
   print(F"Cuboid: {surface_area_cuboid(10, 20, 30) = }")
   print(F"Sphere: {surface_area_sphere(20) = }")
   print(F"Hemisphere: {surface_area_hemisphere(20) = }")
   print(F"Cone: {surface_area_cone(10, 20) = }")
   print(F"Conical Frustum: {surface_area_conical_frustum(10, 20, 30) = }")
   print(F"Cylinder: {surface_area_cylinder(10, 20) = }")
   print(F"Torus: {surface_area_torus(20, 10) = }")
   print(F"Equilateral Triangle: {area_reg_polygon(3, 10) = }")
   print(F"Square: {area_reg_polygon(4, 10) = }")
   print(F"Reqular Pentagon: {area_reg_polygon(5, 10) = }")
import numpy as np
import skfuzzy as fuzz

if __name__ == "__main__":
   # Create universe of discourse in Python using linspace ()
   __lowerCamelCase			: List[Any]							   =		np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False)

   # Create two fuzzy sets by defining any membership function
   # (trapmf(), gbellmf(), gaussmf(), etc).
   __lowerCamelCase			: int							   =		[0, 25, 50]
   __lowerCamelCase			: Tuple							   =		[25, 50, 75]
   __lowerCamelCase			: List[str]							   =		fuzz.membership.trimf(X, abca)
   __lowerCamelCase			: Tuple							   =		fuzz.membership.trimf(X, abca)

   # Compute the different operations using inbuilt functions.
   __lowerCamelCase			: List[str]							   =		np.ones(75)
   __lowerCamelCase			: Tuple							   =		np.zeros((75,))
   # 1. Union = max(µA(x), µB(x))
   __lowerCamelCase			: str							   =		fuzz.fuzzy_or(X, young, X, middle_aged)[1]
   # 2. Intersection = min(µA(x), µB(x))
   __lowerCamelCase			: int							   =		fuzz.fuzzy_and(X, young, X, middle_aged)[1]
   # 3. Complement (A) = (1- min(µA(x))
   __lowerCamelCase			: Union[str, Any]							   =		fuzz.fuzzy_not(young)
   # 4. Difference (A/B) = min(µA(x),(1- µB(x)))
   __lowerCamelCase			: Union[str, Any]							   =		fuzz.fuzzy_and(X, young, X, fuzz.fuzzy_not(middle_aged)[1])[1]
   # 5. Algebraic Sum = [µA(x) + µB(x) – (µA(x) * µB(x))]
   __lowerCamelCase			: List[Any]							   =		young + middle_aged - (young * middle_aged)
   # 6. Algebraic Product = (µA(x) * µB(x))
   __lowerCamelCase			: int							   =		young * middle_aged
   # 7. Bounded Sum = min[1,(µA(x), µB(x))]
   __lowerCamelCase			: int							   =		fuzz.fuzzy_and(X, one, X, young + middle_aged)[1]
   # 8. Bounded difference = min[0,(µA(x), µB(x))]
   __lowerCamelCase			: str							   =		fuzz.fuzzy_or(X, zero, X, young - middle_aged)[1]

   # max-min composition
   # max-product composition

   # Plot each set A, set B and each operation result using plot() and subplot().
   from matplotlib import pyplot as plt

   plt.figure()

   plt.subplot(4, 3, 1)
   plt.plot(X, young)
   plt.title('''Young''')
   plt.grid(True)

   plt.subplot(4, 3, 2)
   plt.plot(X, middle_aged)
   plt.title('''Middle aged''')
   plt.grid(True)

   plt.subplot(4, 3, 3)
   plt.plot(X, union)
   plt.title('''union''')
   plt.grid(True)

   plt.subplot(4, 3, 4)
   plt.plot(X, intersection)
   plt.title('''intersection''')
   plt.grid(True)

   plt.subplot(4, 3, 5)
   plt.plot(X, complement_a)
   plt.title('''complement_a''')
   plt.grid(True)

   plt.subplot(4, 3, 6)
   plt.plot(X, difference)
   plt.title('''difference a/b''')
   plt.grid(True)

   plt.subplot(4, 3, 7)
   plt.plot(X, alg_sum)
   plt.title('''alg_sum''')
   plt.grid(True)

   plt.subplot(4, 3, 8)
   plt.plot(X, alg_product)
   plt.title('''alg_product''')
   plt.grid(True)

   plt.subplot(4, 3, 9)
   plt.plot(X, bdd_sum)
   plt.title('''bdd_sum''')
   plt.grid(True)

   plt.subplot(4, 3, 10)
   plt.plot(X, bdd_difference)
   plt.title('''bdd_difference''')
   plt.grid(True)

   plt.subplots_adjust(hspace=0.5)
   plt.show()
