



'''simple docstring'''






from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
A_				:					Dict							=      9.8_0665




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						None:





       '''simple docstring'''


       if not isinstance(lowerCAmelCase_			,  (int, float)						):
              raise TypeError("""Invalid velocity. Should be a positive number."""						)

       if not isinstance(lowerCAmelCase_			,  (int, float)						):
              raise TypeError("""Invalid angle. Range is 1-90 degrees."""						)

       # Ensure valid angle
       if angle > 90 or angle < 1:
              raise ValueError("""Invalid angle. Range is 1-90 degrees."""						)

       # Ensure valid velocity
       if init_velocity < 0:
              raise ValueError("""Invalid velocity. Should be a positive number."""						)




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						float:





       '''simple docstring'''


       check_args(lowerCAmelCase_			,  lowerCAmelCase_						)
       _UpperCAmelCase    :		Dict     	=					angle_to_radians(2 * angle						)
       return round(init_velocity**2 * sin(lowerCAmelCase_						) / g			,  2						)




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						float:





       '''simple docstring'''


       check_args(lowerCAmelCase_			,  lowerCAmelCase_						)
       _UpperCAmelCase    :		Tuple     	=					angle_to_radians(lowerCAmelCase_						)
       return round(init_velocity**2 * sin(lowerCAmelCase_						) ** 2 / (2 * g)			,  2						)




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						float:





       '''simple docstring'''


       check_args(lowerCAmelCase_			,  lowerCAmelCase_						)
       _UpperCAmelCase    :		Any     	=					angle_to_radians(lowerCAmelCase_						)
       return round(2 * init_velocity * sin(lowerCAmelCase_						) / g			,  2						)




def        snake_case_   (	)->						None:





       '''simple docstring'''


       _UpperCAmelCase	,_UpperCAmelCase    :		Optional[int]     	=					25, 20
       assert horizontal_distance(lowerCAmelCase_			,  lowerCAmelCase_						) == 4_0.9_7
       assert max_height(lowerCAmelCase_			,  lowerCAmelCase_						) == 3.7_3
       assert total_time(lowerCAmelCase_			,  lowerCAmelCase_						) == 1.7_4


if __name__ == "__main__":
   from doctest import testmod

   testmod()

   # Get input from user
   A_				:					Optional[int]							=      float(input("""Initial Velocity: """).strip())

   # Get input from user
   A_				:					int							=      float(input("""angle: """).strip())

   # Print results
   print()
   print("""Results: """)
   print(f"""Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]""")
   print(f"""Maximum Height: {max_height(init_vel, angle)!s} [m]""")
   print(f"""Total Time: {total_time(init_vel, angle)!s} [s]""")








'''simple docstring'''






import numpy as np



class 				lowercase			:


 """simple docstring"""


 def __init__(				self    ,a_=5    ,a_=5				)						->  Tuple:
        _UpperCAmelCase    :		Dict     	=					depth
        _UpperCAmelCase    :		List[str]     	=					0
        _UpperCAmelCase    :		List[str]     	=					None
        _UpperCAmelCase    :		Optional[int]     	=					None
        _UpperCAmelCase    :		Tuple     	=					min_leaf_size
        _UpperCAmelCase    :		int     	=					None







 def _snake_case					(				self    ,a_    ,a_				)						->  Optional[int]:
        if labels.ndim != 1:
               print("""Error: Input labels must be one dimensional"""				)

        return np.mean((labels - prediction) ** 2				)







 def _snake_case					(				self    ,a_    ,a_				)						->  int:
        if x.ndim != 1:
               print("""Error: Input data set must be one dimensional"""				)
               return
        if len(a_				) != len(a_				):
               print("""Error: X and y have different lengths"""				)
               return
        if y.ndim != 1:
               print("""Error: Data set labels must be one dimensional"""				)
               return

        if len(a_				) < 2 * self.min_leaf_size:
               _UpperCAmelCase    :		Union[str, Any]     	=					np.mean(a_				)
               return

        if self.depth == 1:
               _UpperCAmelCase    :		Dict     	=					np.mean(a_				)
               return

        _UpperCAmelCase    :		Union[str, Any]     	=					0
        _UpperCAmelCase    :		Optional[Any]     	=					self.mean_squared_error(a_    ,np.mean(a_				)				) * 2
        for i in range(len(a_				)				):
               if len(x[:i]				) < self.min_leaf_size:
                      continue
               elif len(x[i:]				) < self.min_leaf_size:
                      continue
               else:
                      _UpperCAmelCase    :		Dict     	=					self.mean_squared_error(x[:i]    ,np.mean(y[:i]				)				)
                      _UpperCAmelCase    :		Any     	=					self.mean_squared_error(x[i:]    ,np.mean(y[i:]				)				)
                      _UpperCAmelCase    :		Optional[Any]     	=					error_left + error_right
                      if error < min_error:
                             _UpperCAmelCase    :		Union[str, Any]     	=					i
                             _UpperCAmelCase    :		Optional[int]     	=					error

        if best_split != 0:
               _UpperCAmelCase    :		int     	=					x[:best_split]
               _UpperCAmelCase    :		Optional[Any]     	=					y[:best_split]
               _UpperCAmelCase    :		Optional[int]     	=					x[best_split:]
               _UpperCAmelCase    :		Dict     	=					y[best_split:]

               _UpperCAmelCase    :		List[str]     	=					x[best_split]
               _UpperCAmelCase    :		List[Any]     	=					DecisionTree(
                   depth=self.depth - 1    ,min_leaf_size=self.min_leaf_size				)
               _UpperCAmelCase    :		Union[str, Any]     	=					DecisionTree(
                   depth=self.depth - 1    ,min_leaf_size=self.min_leaf_size				)
               self.left.train(a_    ,a_				)
               self.right.train(a_    ,a_				)
        else:
               _UpperCAmelCase    :		Any     	=					np.mean(a_				)

        return







 def _snake_case					(				self    ,a_				)						->  List[Any]:
        if self.prediction is not None:
               return self.prediction
        elif self.left or self.right is not None:
               if x >= self.decision_boundary:
                      return self.right.predict(a_				)
               else:
                      return self.left.predict(a_				)
        else:
               print("""Error: Decision tree not yet trained"""				)
               return None







class 				lowercase			:


 """simple docstring"""


 @staticmethod
 def _snake_case					(				a_    ,a_				)						->  int:
        _UpperCAmelCase    :		Union[str, Any]     	=					float(0				)
        for label in labels:
               squared_error_sum += (label - prediction) ** 2

        return float(squared_error_sum / labels.size				)







def        snake_case_   (	)->						Optional[int]:





       '''simple docstring'''


       _UpperCAmelCase    :		Tuple     	=					np.arange(-1.0			,  1.0			,  0.0_0_5						)
       _UpperCAmelCase    :		Optional[int]     	=					np.sin(lowerCAmelCase_						)

       _UpperCAmelCase    :		int     	=					DecisionTree(depth=10			,  min_leaf_size=10						)
       tree.train(lowerCAmelCase_			,  lowerCAmelCase_						)

       _UpperCAmelCase    :		Any     	=					(np.random.rand(10						) * 2) - 1
       _UpperCAmelCase    :		Dict     	=					np.array([tree.predict(lowerCAmelCase_						) for x in test_cases]						)
       _UpperCAmelCase    :		Optional[Any]     	=					np.mean((predictions - test_cases) ** 2						)

       print("""Test values: """ + str(lowerCAmelCase_						)						)
       print("""Predictions: """ + str(lowerCAmelCase_						)						)
       print("""Average error: """ + str(lowerCAmelCase_						)						)


if __name__ == "__main__":
   main()
   import doctest

   doctest.testmod(name="""mean_squarred_error""", verbose=True)



