{"record":{"id":"93f0b196d07be259","repo":"TheAlgorithms/Python","slug":"non-positive-frequency-implies-vs-v-or-v0-v-in-th","errorCode":null,"errorMessage":"Non-positive frequency implies vs>v or v0>v (in the opposite direction)","messagePattern":"Non-positive frequency implies vs>v or v0>v \\(in the opposite direction\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"physics/doppler_frequency.py","lineNumber":95,"sourceCode":"        ...\n    ZeroDivisionError: Division by zero implies vs=v and observer in front of the source\n    >>> doppler_effect(100, 330, 10, 340)  # source moving faster than the wave\n    Traceback (most recent call last):\n        ...\n    ValueError: Non-positive frequency implies vs>v or v0>v (in the opposite direction)\n    >>> doppler_effect(100, 330, -340, 10)  # observer moving faster than the wave\n    Traceback (most recent call last):\n        ...\n    ValueError: Non-positive frequency implies vs>v or v0>v (in the opposite direction)\n    \"\"\"\n\n    if wave_vel == src_vel:\n        raise ZeroDivisionError(\n            \"Division by zero implies vs=v and observer in front of the source\"\n        )\n    doppler_freq = (org_freq * (wave_vel + obs_vel)) / (wave_vel - src_vel)\n    if doppler_freq <= 0:\n        raise ValueError(\n            \"Non-positive frequency implies vs>v or v0>v (in the opposite direction)\"\n        )\n    return doppler_freq\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n","sourceCodeStart":77,"sourceCodeEnd":105,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/physics/doppler_frequency.py#L77-L105","documentation":"Error \"Non-positive frequency implies vs>v or v0>v (in the opposite direction)\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at physics/doppler_frequency.py:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep source and observer speeds below the wave speed so the observed frequency stays positive."],"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"}