

'''simple docstring'''






from __future__ import annotations

from collections.abc import MutableSequence






class 			lowercase_	:




  """simple docstring"""




  def __init__(      self   :     List[Any]					,lowercase__   :     int					,lowercase__   :     MutableSequence[float]			):
   if len(lowercase__			) != degree + 1:
    raise ValueError(
        '''The number of coefficients should be equal to the degree + 1.'''			)

   __lowercase							  = list(lowercase__			)
   __lowercase							  = degree






  def __add__(      self   :     Optional[int]					,lowercase__   :     Polynomial			):

   if self.degree > polynomial_a.degree:
    __lowercase							  = self.coefficients[:]
    for i in range(polynomial_a.degree + 1			):
     coefficients[i] += polynomial_a.coefficients[i]
    return Polynomial(self.degree					,lowercase__			)
   else:
    __lowercase							  = polynomial_a.coefficients[:]
    for i in range(self.degree + 1			):
     coefficients[i] += self.coefficients[i]
    return Polynomial(polynomial_a.degree					,lowercase__			)






  def __sub__(      self   :     Optional[Any]					,lowercase__   :     Polynomial			):
   return self + polynomial_a * Polynomial(0					,[-1]			)






  def __neg__(      self   :     List[str]			):
   return Polynomial(self.degree					,[-c for c in self.coefficients]			)






  def __mul__(      self   :     Optional[Any]					,lowercase__   :     Polynomial			):
   __lowercase							  = [0] * (self.degree + polynomial_a.degree + 1)
   for i in range(self.degree + 1			):
    for j in range(polynomial_a.degree + 1			):
     coefficients[i + j] += (
         self.coefficients[i] * polynomial_a.coefficients[j]
     )

   return Polynomial(self.degree + polynomial_a.degree					,lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     int					,lowercase__   :     int | float			):
   __lowercase							  = 0
   for i in range(self.degree + 1			):
    result += self.coefficients[i] * (substitution**i)
   return result






  def __str__(      self   :     str			):
   __lowercase							  = ''''''
   for i in range(self.degree					,-1					,-1			):
    if self.coefficients[i] == 0:
     continue
    elif self.coefficients[i] > 0:
     if polynomial:
      polynomial += " + "
    else:
     polynomial += " - "

    if i == 0:
     polynomial += str(abs(self.coefficients[i]			)			)
    elif i == 1:
     polynomial += str(abs(self.coefficients[i]			)			) + "x"
    else:
     polynomial += str(abs(self.coefficients[i]			)			) + "x^" + str(lowercase__			)

   return polynomial






  def __repr__(      self   :     Optional[int]			):
   return self.__str__()






  def 					SCREAMING_SNAKE_CASE      (      self   :     Optional[int]			):
   __lowercase							  = [0] * self.degree
   for i in range(self.degree			):
    __lowercase							  = self.coefficients[i + 1] * (i + 1)
   return Polynomial(self.degree - 1					,lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     str					,lowercase__   :     int | float = 0			):
   __lowercase							  = [0] * (self.degree + 2)
   __lowercase							  = constant
   for i in range(self.degree + 1			):
    __lowercase							  = self.coefficients[i] / (i + 1)
   return Polynomial(self.degree + 1					,lowercase__			)






  def __eq__(      self   :     List[Any]					,lowercase__   :     object			):
   if not isinstance(lowercase__					,lowercase__			):
    return False

   if self.degree != polynomial_a.degree:
    return False

   for i in range(self.degree + 1			):
    if self.coefficients[i] != polynomial_a.coefficients[i]:
     return False

   return True






  def __ne__(      self   :     int					,lowercase__   :     object			):
   return not self.__eq__(lowercase__			)






'''simple docstring'''




def 				lowerCAmelCase_   (	_lowerCamelCase:   float       ,      _lowerCamelCase:   list[float]					):
		if discount_rate < 0:
				raise ValueError("""Discount rate cannot be negative"""					)
		if not cash_flows:
				raise ValueError("""Cash flows list cannot be empty"""					)
		__SCREAMING_SNAKE_CASE       :		List[str]           =		sum(
		    cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_lowerCamelCase					)					)
		return round(_lowerCamelCase       ,      ndigits=2					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()