maths.line_length ================= .. py:module:: maths.line_length Functions --------- .. autoapisummary:: maths.line_length.f maths.line_length.line_length Module Contents --------------- .. py:function:: f(x) .. py:function:: line_length(fnc: collections.abc.Callable[[float], float], x_start: float, x_end: float, steps: int = 100) -> float Approximates the arc length of a line segment by treating the curve as a sequence of linear lines and summing their lengths :param fnc: a function which defines a curve :param x_start: left end point to indicate the start of line segment :param x_end: right end point to indicate end of line segment :param steps: an accuracy gauge; more steps increases accuracy :return: a float representing the length of the curve >>> def f(x): ... return x >>> f"{line_length(f, 0, 1, 10):.6f}" '1.414214' >>> def f(x): ... return 1 >>> f"{line_length(f, -5.5, 4.5):.6f}" '10.000000' >>> def f(x): ... return math.sin(5 * x) + math.cos(10 * x) + x * x/10 >>> f"{line_length(f, 0.0, 10.0, 10000):.6f}" '69.534930'