


'''simple docstring'''


def      lowerCamelCase					(      lowerCamelCase  :      int):
      A_						:  int          =				generate_pascal_triangle(lowerCamelCase)
      for row_idx in range(lowerCamelCase):
            # Print left spaces
            for _ in range(num_rows - row_idx - 1):
                  print(end=""" """)
            # Print row values
            for col_idx in range(row_idx + 1):
                  if col_idx != row_idx:
                        print(triangle[row_idx][col_idx]							,						end=""" """)
                  else:
                        print(triangle[row_idx][col_idx]							,						end="""""")
            print()




def      lowerCamelCase					(      lowerCamelCase  :      int):

      if not isinstance(lowerCamelCase							,						lowerCamelCase):
            raise TypeError("""The input value of 'num_rows' should be 'int'""")

      if num_rows == 0:
            return []
      elif num_rows < 0:
            raise ValueError(
                """The input value of 'num_rows' should be greater than or equal to 0""")

      A_						:  list[list[int]]          =				[]
      for current_row_idx in range(lowerCamelCase):
            A_						:  Dict          =				populate_current_row(lowerCamelCase							,						lowerCamelCase)
            triangle.append(lowerCamelCase)
      return triangle




def      lowerCamelCase					(      lowerCamelCase  :      list[list[int]]							,						lowerCamelCase  :      int):
      A_						:  List[Any]          =				[-1] * (current_row_idx + 1)
      # first and last elements of current row are equal to 1
      A_   ,					A_						:  Any          =				1, 1
      for current_col_idx in range(1							,						lowerCamelCase):
            calculate_current_element(
                lowerCamelCase							,						lowerCamelCase							,						lowerCamelCase							,						lowerCamelCase)
      return current_row




def      lowerCamelCase					(      lowerCamelCase  :      list[list[int]]							,						lowerCamelCase  :      list[int]							,						lowerCamelCase  :      int							,						lowerCamelCase  :      int							,						):
      A_						:  int          =				triangle[current_row_idx - 1][current_col_idx - 1]
      A_						:  int          =				triangle[current_row_idx - 1][current_col_idx]
      A_						:  int          =				above_to_left_elt + above_to_right_elt




def      lowerCamelCase					(      lowerCamelCase  :      int):

      if not isinstance(lowerCamelCase							,						lowerCamelCase):
            raise TypeError("""The input value of 'num_rows' should be 'int'""")

      if num_rows == 0:
            return []
      elif num_rows < 0:
            raise ValueError(
                """The input value of 'num_rows' should be greater than or equal to 0""")

      A_						:  list[list[int]]          =				[[1]]

      for row_index in range(1							,						lowerCamelCase):
            A_						:  Dict          =				[0] + result[-1] + [0]
            A_						:  Any          =				row_index + 1
            # Calculate the number of distinct elements in a row
            A_						:  Optional[Any]          =				sum(divmod(lowerCamelCase							,						2))
            A_						:  Tuple          =				[
                temp_row[i - 1] + temp_row[i] for i in range(1							,						distinct_elements + 1)
            ]
            A_						:  str          =				row_first_half[: (row_index + 1) // 2]
            row_second_half.reverse()
            A_						:  Optional[int]          =				row_first_half + row_second_half
            result.append(lowerCamelCase)

      return result




def      lowerCamelCase					(      ):
      from collections.abc import Callable
      from timeit import timeit

      def benchmark_a_function(lowerCamelCase  :      Callable							,						lowerCamelCase  :      int) -> None:
            A_						:  Union[str, Any]          =				F'{func.__name__}({value})'
            A_						:  str          =				timeit(F'__main__.{call}'							,						setup="""import __main__""")
            # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
            print(F'{call:38} -- {timing:.4f} seconds')

      for value in range(15):  # (1, 7, 14):
            for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
                  benchmark_a_function(lowerCamelCase							,						lowerCamelCase)
            print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()




'''simple docstring'''


from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403




def      lowerCamelCase					(      lowerCamelCase  :      str							,						lowerCamelCase  :      complex							,						lowerCamelCase  :      str = "x"							,						lowerCamelCase  :      float = 10**-10							,						lowerCamelCase  :      int = 1							,						):
      A_						:  int          =				symbols(lowerCamelCase)
      A_						:  List[Any]          =				lambdify(lowerCamelCase							,						lowerCamelCase)
      A_						:  List[str]          =				lambdify(lowerCamelCase							,						diff(lowerCamelCase							,						lowerCamelCase))

      A_						:  str          =				starting_point

      while True:
            if diff_function(lowerCamelCase) != 0:
                  A_						:  int          =				prev_guess - multiplicity * func(lowerCamelCase) / diff_function(
                      lowerCamelCase)
            else:
                  raise ZeroDivisionError("""Could not find root""") from None

            # Precision is checked by comparing the difference of consecutive guesses
            if abs(next_guess - prev_guess) < precision:
                  return next_guess

            A_						:  Union[str, Any]          =				next_guess


# Let's Execute
if __name__ == "__main__":
     # Find root of trigonometric function
     # Find value of pi
     print(f"""The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}""")

     # Find root of polynomial
     # Find fourth Root of 5
     print(f"""The root of x**4 - 5 = 0 is {newton_raphson('x**4 -5', 0.4 +5j)}""")

     # Find value of e
     print(
         'The root of log(y) - 1 = 0 is ',
         f"""{newton_raphson('log(y) - 1', 2, variable='y')}""",
     )

     # Exponential Roots
     print(
         'The root of exp(x) - 1 = 0 is',
         f"""{newton_raphson('exp(x) - 1', 10, precision=0.0_0_5)}""",
     )

     # Find root of cos(x)
     print(f"""The root of cos(x) = 0 is {newton_raphson('cos(x)', 0)}""")
