maths.numerical_analysis.intersection ===================================== .. py:module:: maths.numerical_analysis.intersection Functions --------- .. autoapisummary:: maths.numerical_analysis.intersection.f maths.numerical_analysis.intersection.intersection Module Contents --------------- .. py:function:: f(x: float) -> float function is f(x) = x^3 - 2x - 5 >>> f(2) -1.0 .. py:function:: intersection(function: collections.abc.Callable[[float], float], x0: float, x1: float) -> float function is the f we want to find its root x0 and x1 are two random starting points >>> intersection(lambda x: x ** 3 - 1, -5, 5) 0.9999999999954654 >>> intersection(lambda x: x ** 3 - 1, 5, 5) Traceback (most recent call last): ... ZeroDivisionError: float division by zero, could not find root >>> intersection(lambda x: x ** 3 - 1, 100, 200) 1.0000000000003888 >>> intersection(lambda x: x ** 2 - 4 * x + 3, 0, 2) 0.9999999998088019 >>> intersection(lambda x: x ** 2 - 4 * x + 3, 2, 4) 2.9999999998088023 >>> intersection(lambda x: x ** 2 - 4 * x + 3, 4, 1000) 3.0000000001786042 >>> intersection(math.sin, -math.pi, math.pi) 0.0 >>> intersection(math.cos, -math.pi, math.pi) Traceback (most recent call last): ... ZeroDivisionError: float division by zero, could not find root