



'''simple docstring'''




from __future__ import annotations

from collections.abc import Callable


def 				lowerCAmelCase_   (	_lowerCamelCase:   Callable[[int | float], int | float]       ,      _lowerCamelCase:   int | float       ,      _lowerCamelCase:   int | float       ,      _lowerCamelCase:   int = 1_00       ,      ):
		__SCREAMING_SNAKE_CASE       :		str           =		x_start
		__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		fnc(_lowerCamelCase					)
		__SCREAMING_SNAKE_CASE       :		Any           =		0.0
		for _ in range(_lowerCamelCase					):
				# Approximates small segments of curve as linear and solve
				# for trapezoidal area
				__SCREAMING_SNAKE_CASE       :		str           =		(x_end - x_start) / steps + xa
				__SCREAMING_SNAKE_CASE       :		Dict           =		fnc(_lowerCamelCase					)
				area += abs(fxa + fxa					) * (xa - xa) / 2
				# Increment step
				__SCREAMING_SNAKE_CASE       :		int           =		xa
				__SCREAMING_SNAKE_CASE       :		Any           =		fxa
		return area


if __name__ == "__main__":


						def 				lowerCAmelCase_   (	_lowerCamelCase:   Optional[int]					):
								return x**3 + x**2

						print('''f(x) = x^3 + x^2''')
						print('''The area between the curve, x = -5, x = 5 and the x axis is:''')
						UpperCamelCase__       :	Union[str, Any]    = 10
						while i <= 10_00_00:
												print(f"with {i} steps: {trapezoidal_area(f, -5, 5, i)}")
												i *= 10




'''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()