{"record":{"id":"48feee07788fab9f","repo":"TheAlgorithms/Python","slug":"x-values-must-be-equally-spaced-according-to-step","errorCode":null,"errorMessage":"x-values must be equally spaced according to step size.","messagePattern":"x-values must be equally spaced according to step size\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"maths/numerical_analysis/adams_bashforth.py","lineNumber":65,"sourceCode":"    x_initials: list[float]\n    y_initials: list[float]\n    step_size: float\n    x_final: float\n\n    def __post_init__(self) -> None:\n        if self.x_initials[-1] >= self.x_final:\n            raise ValueError(\n                \"The final value of x must be greater than the initial values of x.\"\n            )\n\n        if self.step_size <= 0:\n            raise ValueError(\"Step size must be positive.\")\n\n        if not all(\n            round(x1 - x0, 10) == self.step_size\n            for x0, x1 in zip(self.x_initials, self.x_initials[1:])\n        ):\n            raise ValueError(\"x-values must be equally spaced according to step size.\")\n\n    def step_2(self) -> np.ndarray:\n        \"\"\"\n        >>> def f(x, y):\n        ...     return x\n        >>> AdamsBashforth(f, [0, 0.2], [0, 0], 0.2, 1).step_2()\n        array([0.  , 0.  , 0.06, 0.16, 0.3 , 0.48])\n\n        >>> AdamsBashforth(f, [0, 0.2, 0.4], [0, 0, 0.04], 0.2, 1).step_2()\n        Traceback (most recent call last):\n            ...\n        ValueError: Insufficient initial points information.\n        \"\"\"\n\n        if len(self.x_initials) != 2 or len(self.y_initials) != 2:\n            raise ValueError(\"Insufficient initial points information.\")\n\n        x_0, x_1 = self.x_initials[:2]","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/maths/numerical_analysis/adams_bashforth.py#L47-L83","documentation":"Error \"x-values must be equally spaced according to step size.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at maths/numerical_analysis/adams_bashforth.py:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure consecutive x-values differ by exactly the given step size.","Recompute x-values as x0 + i*step_size before calling the method."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}