'''simple docstring'''

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



def snake_case_      (					__snake_case  :							str	,   __snake_case  :							complex	,   __snake_case  :							str = "x"	,   __snake_case  :							float = 10**-10	,   __snake_case  :							int = 1	,   )			->					complex:
   lowerCAmelCase_			=      symbols(__snake_case)
   lowerCAmelCase_			=      lambdify(__snake_case	,   __snake_case)
   lowerCAmelCase_			=      lambdify(__snake_case	,   diff(__snake_case	,   __snake_case))

   lowerCAmelCase_			=      starting_point

   while True:
      if diff_function(__snake_case) != 0:
         lowerCAmelCase_			=      prev_guess - multiplicity * func(__snake_case) / diff_function(
             __snake_case)
      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

      lowerCAmelCase_			=      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.005)}''',
 )

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






'''simple docstring'''

import os



def snake_case_      (					__snake_case  :							List[Any])			->					str:
   lowerCAmelCase_			=      len(grid[0])
   lowerCAmelCase_			=      len(__snake_case)

   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0

   # Check vertically, horizontally, diagonally at the same time (only works
   # for nxn grid)
   for i in range(__snake_case):
      for j in range(n_rows - 3):
         lowerCAmelCase_			=      grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
         lowerCAmelCase_			=      grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

         # Left-to-right diagonal (\) product
         if i < n_columns - 3:
            lowerCAmelCase_			=      (
                grid[i][j]
                * grid[i + 1][j + 1]
                * grid[i + 2][j + 2]
                * grid[i + 3][j + 3]
            )

         # Right-to-left diagonal(/) product
         if i > 2:
            lowerCAmelCase_			=      (
                grid[i][j]
                * grid[i - 1][j + 1]
                * grid[i - 2][j + 2]
                * grid[i - 3][j + 3]
            )

         lowerCAmelCase_			=      max(
             __snake_case	,   __snake_case	,   __snake_case	,   __snake_case)
         if max_product > largest:
            lowerCAmelCase_			=      max_product

   return largest



def snake_case_      (					)			->					List[Any]:
   lowerCAmelCase_			=      []
   with open(os.path.dirname(__snake_case) + '''/grid.txt''') as file:
      for line in file:
         grid.append(line.strip('''\n''').split(''' '''))

   lowerCAmelCase_			=      [[int(__snake_case) for i in grid[j]] for j in range(len(__snake_case))]

   return largest_product(__snake_case)


if __name__ == "__main__":
 print(solution())





