

from collections.abc import Callable

_lowerCAmelCase :	Optional[Any]     				=    Callable[[float], float]  # type alias for a real -> real function







def a_		(       UpperCamelCase_   :							Any   ,					UpperCamelCase_   :							Optional[int]   ,					UpperCamelCase_   :							Optional[int]   ,					)							->   Any:







 """simple docstring"""

 lowerCamelCase      						=    float(__A  )
 while True:
  try:
   lowerCamelCase      						=    prev_guess - function(__A  ) / derivative(__A  )
  except ZeroDivisionError:
   raise ZeroDivisionError('Could not find root'  ) from None
  if abs(prev_guess - next_guess  ) < 1_0**-5:
   return next_guess
  lowerCamelCase      						=    next_guess







def a_		(       UpperCamelCase_   :							List[str]  )							->   Tuple:







 """simple docstring"""

 return (x**3) - (2 * x) - 5







def a_		(       UpperCamelCase_   :							Union[str, Any]  )							->   str:







 """simple docstring"""

 return 3 * (x**2) - 2


if __name__ == "__main__":
     print(newton(f, fa, 3))







from __future__ import annotations


class     lowerCAmelCase				:


       '''simple docstring'''







       def __init__(	self					:  Dict						,	__snake_case					:  int     )   -> None:







        '''simple docstring'''

        lowerCamelCase      						=    vertices
        lowerCamelCase      						=    [[0] * vertices for _ in range(__snake_case     )]

       def   lowerCamelCase__						(	self					:  List[str]						,	__snake_case					:  list[int]     )   -> None:







        '''simple docstring'''

        print('Vertex \t Distance from Source'     )
        for vertex in range(self.vertices     ):
         print(__snake_case						,	'\t\t'						,	distances_from_source[vertex]     )

       def   lowerCamelCase__						(	self					:  Optional[int]						,	__snake_case					:  list[int]						,	__snake_case					:  list[bool]     )   -> int:







        '''simple docstring'''

        lowerCamelCase      						=    1e7
        lowerCamelCase      						=    0

        # Search not nearest vertex not in the shortest path tree
        for vertex in range(self.vertices     ):
         if distances_from_source[vertex] < minimum and visited[vertex] is False:
          lowerCamelCase      						=    distances_from_source[vertex]
          lowerCamelCase      						=    vertex
        return min_index





       def   lowerCamelCase__						(	self					:  Optional[Any]						,	__snake_case					:  int     )   -> None:







        '''simple docstring'''

        lowerCamelCase      						=    [int(1e7     )] * self.vertices  # distances from the source
        lowerCamelCase      						=    0
        lowerCamelCase      						=    [False] * self.vertices

        for _ in range(self.vertices     ):
         lowerCamelCase      						=    self.minimum_distance(__snake_case						,	__snake_case     )
         lowerCamelCase      						=    True

         # Update dist value of the adjacent vertices
         # of the picked vertex only if the current
         # distance is greater than new distance and
         # the vertex in not in the shortest path tree
         for v in range(self.vertices     ):
          if (
              self.graph[u][v] > 0
              and visited[v] is False
              and distances[v] > distances[u] + self.graph[u][v]
          ):
           lowerCamelCase      						=    distances[u] + self.graph[u][v]

        self.print_solution(__snake_case     )


if __name__ == "__main__":
     _lowerCAmelCase :	Dict     				=    Graph(9)
     _lowerCAmelCase :	int     				=    [
         [0, 4, 0, 0, 0, 0, 0, 8, 0],
         [4, 0, 8, 0, 0, 0, 0, 1_1, 0],
         [0, 8, 0, 7, 0, 4, 0, 0, 2],
         [0, 0, 7, 0, 9, 1_4, 0, 0, 0],
         [0, 0, 0, 9, 0, 1_0, 0, 0, 0],
         [0, 0, 4, 1_4, 1_0, 0, 2, 0, 0],
         [0, 0, 0, 0, 0, 2, 0, 1, 6],
         [8, 1_1, 0, 0, 0, 0, 1, 0, 7],
         [0, 0, 2, 0, 0, 0, 6, 7, 0],
     ]
     graph.dijkstra(0)




