Hidden WordScanner
Private scans · No account required

DuckieDai Hooke's Law and Elastic Energy

Solve spring force, spring constant, displacement, or elastic potential energy with Hooke's law and PE = 0.5*k*x^2.

Version 1.0.0 · Tested on a TI calculator

← Back to Calculator Program Library

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.

physics · MIT License

Overview

Solve spring force, spring constant, displacement, or elastic potential energy with Hooke's law and PE = 0.5*k*x^2.

Usage

Inputs

  • Requested spring quantity
  • Known force, displacement, spring constant, or elastic energy as required

Outputs

  • Requested spring value, including both possible displacement signs when solving from energy

Units: Use newtons, metres, newtons per metre, and joules consistently.

Assumptions and limitations

Assumptions

  • The spring behaves linearly within its elastic range.

Constraints

  • Spring constant must be positive and divisor values cannot be zero.

Known failures

  • Hooke's law is inaccurate beyond the spring's elastic limit.
  • Force and displacement signs must follow one consistent direction convention.

Compatibility and review

Review status
Tested on a TI calculator
Tested on
TI-84 Plus CE Python; OS 5.8.3; Python App 5.8.3.0048; exact paginated .py transferred through TI Connect CE into RAM and tested individually
What happened
Passed: branded intro, multi page spring menu, Hooke law and elastic energy workflows, and answer screens ran on the physical calculator
Dependencies
math
Suggested calculator name
HOOKELAW — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Browser preview

Try the DuckieDai calculator screen

Follow the reviewed program's real menu, prompts, validation, calculation, and result flow before downloading.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. """DuckieDai Springs for TI-84 Plus CE Python."""
  2. from math import sqrt
  3. def duckiedai_intro(program_name, wait=True):
  4. """Show the reusable DuckieDai program opening."""
  5. title = program_name[:16]
  6. empty = 16 - len(title)
  7. left = empty // 2
  8. right = empty - left
  9. print("+----------------------+")
  10. print("| " + " " * left + title + " " * right + " |")
  11. print("| |")
  12. print("| __ |")
  13. print("| ___(o )> quack! |")
  14. print("| \\ <_. ) |")
  15. print("| `---' |")
  16. print("| by DuckieDai |")
  17. print("+----------------------+")
  18. print("Loading...")
  19. if wait:
  20. input("Press enter to start ")
  21. print("\n" * 6)
  22. def number(prompt):
  23. """Allow positive, negative, or zero values."""
  24. while True:
  25. try:
  26. value = float(input(prompt))
  27. if value > -1e100 and value < 1e100:
  28. return value
  29. except ValueError:
  30. pass
  31. print("Enter a valid number.")
  32. def nonzero_number(prompt):
  33. """Require a number other than zero."""
  34. while True:
  35. value = number(prompt)
  36. if value != 0:
  37. return value
  38. print("Value cannot be zero.")
  39. def positive_number(prompt):
  40. """Require a value greater than zero."""
  41. while True:
  42. try:
  43. value = float(input(prompt))
  44. if value > 0 and value < 1e100:
  45. return value
  46. except ValueError:
  47. pass
  48. print("Enter a number above 0.")
  49. def nonnegative_number(prompt):
  50. """Allow zero or positive values."""
  51. while True:
  52. try:
  53. value = float(input(prompt))
  54. if value >= 0 and value < 1e100:
  55. return value
  56. except ValueError:
  57. pass
  58. print("Enter 0 or greater.")
  59. def show_answer(name, value, unit):
  60. input("Press enter for answer ")
  61. print("\n" * 6)
  62. print("ANSWER")
  63. print(name + " = " + str(value))
  64. print(unit)
  65. def main():
  66. duckiedai_intro("SPRING ENERGY")
  67. print("HOOKE'S LAW")
  68. print("& ELASTIC ENERGY")
  69. print()
  70. print("Fs = -k*x")
  71. print("PE = 0.5*k*x^2")
  72. input("Press enter for menu ")
  73. print("\n" * 6)
  74. print()
  75. print("What do you need?")
  76. print()
  77. print("1. Spring force")
  78. print("2. Spring constant")
  79. print(" from force")
  80. print("3. Displacement")
  81. print(" from force")
  82. input("Press enter for more ")
  83. print("\n" * 6)
  84. print("4. Elastic PE")
  85. print("5. Spring constant")
  86. print(" from PE")
  87. print("6. Displacement")
  88. print(" from PE")
  89. print()
  90. choice = input("Choose 1-6: ")
  91. print()
  92. # ==========================================
  93. # 1. SPRING FORCE
  94. #
  95. # Fs = -k*x
  96. # ==========================================
  97. if choice == "1":
  98. k = positive_number("k (N/m): ")
  99. x = number("Displacement (m): ")
  100. force = -k * x
  101. print()
  102. print("Using:")
  103. print("Fs = -k*x")
  104. print()
  105. print("Fs = -" + str(k))
  106. print("x " + str(x))
  107. show_answer(
  108. "Fs",
  109. force,
  110. "newtons"
  111. )
  112. print()
  113. print("Minus sign means")
  114. print("restoring force is")
  115. print("opposite displacement.")
  116. # ==========================================
  117. # 2. SPRING CONSTANT FROM FORCE
  118. #
  119. # k = -Fs/x
  120. # ==========================================
  121. elif choice == "2":
  122. force = number("Spring force (N): ")
  123. x = nonzero_number("Displacement (m): ")
  124. k = -force / x
  125. print()
  126. print("Using:")
  127. print("Fs = -k*x")
  128. print()
  129. print("Rearranged:")
  130. print("k = -Fs/x")
  131. if k <= 0:
  132. print()
  133. print("Result gives k <= 0.")
  134. print("Check force and")
  135. print("direction signs.")
  136. else:
  137. show_answer(
  138. "k",
  139. k,
  140. "N/m"
  141. )
  142. # ==========================================
  143. # 3. DISPLACEMENT FROM FORCE
  144. #
  145. # x = -Fs/k
  146. # ==========================================
  147. elif choice == "3":
  148. force = number("Spring force (N): ")
  149. k = positive_number("k (N/m): ")
  150. x = -force / k
  151. print()
  152. print("Using:")
  153. print("Fs = -k*x")
  154. print()
  155. print("Rearranged:")
  156. print("x = -Fs/k")
  157. show_answer(
  158. "x",
  159. x,
  160. "meters"
  161. )
  162. # ==========================================
  163. # 4. ELASTIC POTENTIAL ENERGY
  164. #
  165. # PE = 0.5*k*x^2
  166. # ==========================================
  167. elif choice == "4":
  168. k = positive_number("k (N/m): ")
  169. x = number("Displacement (m): ")
  170. pe = (
  171. 0.5 *
  172. k *
  173. x ** 2
  174. )
  175. print()
  176. print("Using:")
  177. print("PE = 0.5*k*x^2")
  178. print()
  179. print("PE = 0.5 x")
  180. print(str(k) + " x")
  181. print(str(x) + "^2")
  182. show_answer(
  183. "PE",
  184. pe,
  185. "joules"
  186. )
  187. # ==========================================
  188. # 5. SPRING CONSTANT FROM ENERGY
  189. #
  190. # k = 2*PE/x^2
  191. # ==========================================
  192. elif choice == "5":
  193. pe = nonnegative_number("Elastic PE (J): ")
  194. x = nonzero_number("Displacement (m): ")
  195. k = (
  196. 2 * pe /
  197. (x ** 2)
  198. )
  199. print()
  200. print("Using:")
  201. print("PE = 0.5*k*x^2")
  202. print()
  203. print("Rearranged:")
  204. print("k = 2*PE/x^2")
  205. show_answer(
  206. "k",
  207. k,
  208. "N/m"
  209. )
  210. # ==========================================
  211. # 6. DISPLACEMENT FROM ENERGY
  212. #
  213. # x = +/- sqrt(2*PE/k)
  214. # ==========================================
  215. elif choice == "6":
  216. pe = nonnegative_number("Elastic PE (J): ")
  217. k = positive_number("k (N/m): ")
  218. x = sqrt(
  219. (2 * pe) / k
  220. )
  221. print()
  222. print("Using:")
  223. print("PE = 0.5*k*x^2")
  224. print()
  225. print("Rearranged:")
  226. print("x = +/-sqrt(2*PE/k)")
  227. print()
  228. input("Press enter for answer ")
  229. print("\n" * 6)
  230. print("ANSWER")
  231. print("|x| = " + str(x))
  232. print("meters")
  233. print()
  234. print("Possible positions:")
  235. print("x = " + str(x))
  236. print("or")
  237. print("x = -" + str(x))
  238. else:
  239. print("Invalid choice.")
  240. print()
  241. print("DuckieDai says: done!")
  242. # TI-Python imports the selected AppVar rather than
  243. # setting __name__ to main.
  244. main()
Filename
HOOKELAW.py
Size
7070 bytes
SHA-256
12c4705772c67397d3761f1be5252249edfc811ffd6f11985993b7b9e1473a48

Transfer and launch

  1. Confirm that your calculator is the Python-capable model named above. Check that its OS and Python App versions match the reviewed record.
  2. Download the .py source above and verify its SHA-256 digest if your computer provides that option.
  3. Use TI Connect CE to send the Python file to a compatible calculator. HOOKELAW is a suggested name; you may choose another valid, unique calculator name.
  4. Open the Python App, select the program, and check sample inputs before relying on other results.

Read the complete installation, launch, troubleshooting, and removal guide.

Availability does not mean a teacher, school, or exam permits this program. Follow the applicable rules.

Version history

Any source change requires a new immutable version and digest. Historical downloads remain available only while their review records remain valid.