Skip to content

Added the algorithm to compute the time period of a simple pendulum #10265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
imported g form scipy and changed doctests accordingly
  • Loading branch information
pluto-tofu committed Oct 23, 2023
commit ebb4ebd297bfdd425a3d4786f1bb30f30c6a46cb
10 changes: 5 additions & 5 deletions physics/time_period_simple_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@

Reference : https://byjus.com/jee/simple-pendulum/
"""

from scipy.constants import g

def time_period_simple_pendulum(length: float) -> float:
"""
>>> time_period_simple_pendulum(1.23)
2.2259685262423705
2.2252136710666166
>>> time_period_simple_pendulum(2.37)
3.089873051721361
3.088825235169592
>>> time_period_simple_pendulum(5.63)
4.762342885477521
4.760727912429414
>>> time_period_simple_pendulum(-12)
Traceback (most recent call last):
...
Expand All @@ -49,7 +49,7 @@ def time_period_simple_pendulum(length: float) -> float:
"""
if length < 0:
raise ValueError("The length should be non-negative")
return (2 * 3.14159) * (length / 9.8) ** 0.5
return (2 * 3.14159) * (length / g) ** 0.5


if __name__ == "__main__":
Expand Down