Hidden WordScanner
Private scans · No account required

DuckieDai Cubic Inequality Solver

Solve a cubic inequality by finding its rational zeros with their multiplicities, then reading the sign of each interval.

Using the full toolkit? Read the step-by-step Polynomial Toolkit guide for quartic, cubic, and quadratic workflows, worked examples, and a reminder to keep every root you find.

algebra · MIT License

Overview

Solve a cubic inequality by finding its rational zeros with their multiplicities, then reading the sign of each interval.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 3648 bytes
  • No imports

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
  • The leading coefficient a is nonzero.
  • Every zero of the cubic is rational.
  • Zeros are found with the Rational Zero Theorem, so a cubic with an irrational or complex zero reports Could not factor.

Try the DuckieDai calculator screen

Follow the program's prompts and result flow before downloading.

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

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.

Exact reviewed bytes

Source code

Download .py

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

  1. """DuckieDai Cubic Inequality Solver for TI-84 Plus CE Python."""
  2. def duckiedai_intro(program_name, wait=True):
  3. title = program_name[:16]
  4. empty = 16 - len(title)
  5. left = empty // 2
  6. right = empty - left
  7. print("+----------------------+")
  8. print("| " + " " * left + title + " " * right + " |")
  9. print("| |")
  10. print("| __ |")
  11. print("| ___(o )> quack! |")
  12. print("| \\ <_. ) |")
  13. print("| `---' |")
  14. print("| by DuckieDai |")
  15. print("| hiddenwordscanner.com|")
  16. print("+----------------------+")
  17. print("Loading...")
  18. if wait:
  19. input("Press enter to start ")
  20. print("\n" * 8)
  21. def factors(n):
  22. n=abs(n)
  23. if n==0:
  24. return [0]
  25. f=[]
  26. for i in range(1,n+1):
  27. if n%i==0:
  28. f.append(i)
  29. return f
  30. def frac(x):
  31. for d in range(1,101):
  32. n=round(x*d)
  33. if abs(x-n/d)<0.000001:
  34. if d==1:
  35. return str(n)
  36. return str(n)+"/"+str(d)
  37. return str(round(x,4))
  38. def divide(c,r):
  39. q=[c[0]]
  40. for i in range(1,len(c)-1):
  41. q.append(c[i]+q[-1]*r)
  42. rem=c[-1]+q[-1]*r
  43. return q,rem
  44. duckiedai_intro("Cubic Inequality")
  45. a=int(input("a: "))
  46. b=int(input("b: "))
  47. c=int(input("c: "))
  48. d=int(input("d: "))
  49. print("1 >0")
  50. print("2 >=0")
  51. print("3 <0")
  52. print("4 <=0")
  53. op=input("Choice: ")
  54. coef=[a,b,c,d]
  55. # Rational Zero Theorem candidates
  56. cand=[]
  57. if d==0:
  58. cand.append(0)
  59. p=factors(d)
  60. q=factors(a)
  61. for x in p:
  62. for y in q:
  63. if y!=0:
  64. r=x/y
  65. if r not in cand:
  66. cand.append(r)
  67. if -r not in cand:
  68. cand.append(-r)
  69. roots=[]
  70. mult=[]
  71. # Find roots and multiplicities
  72. for r in cand:
  73. count=0
  74. while len(coef)>1:
  75. new,rem=divide(coef,r)
  76. if abs(rem)<0.000001:
  77. count+=1
  78. coef=new
  79. else:
  80. break
  81. if count>0:
  82. roots.append(r)
  83. mult.append(count)
  84. if len(coef)>1:
  85. print("Could not factor")
  86. else:
  87. # sort roots
  88. for i in range(len(roots)):
  89. for j in range(i+1,len(roots)):
  90. if roots[i]>roots[j]:
  91. roots[i],roots[j]=roots[j],roots[i]
  92. mult[i],mult[j]=mult[j],mult[i]
  93. n=len(roots)
  94. print("Roots:")
  95. for i in range(n):
  96. print(frac(roots[i]),"mult",mult[i])
  97. # Interval signs
  98. signs=[0]*(n+1)
  99. if a>0:
  100. signs[n]=1
  101. else:
  102. signs[n]=-1
  103. for i in range(n-1,-1,-1):
  104. signs[i]=signs[i+1]
  105. if mult[i]%2==1:
  106. signs[i]=-signs[i]
  107. if op=="1" or op=="2":
  108. want=1
  109. else:
  110. want=-1
  111. include=(op=="2" or op=="4")
  112. print("Solution:")
  113. found=False
  114. for i in range(n+1):
  115. if signs[i]==want:
  116. found=True
  117. if i==0:
  118. left="-inf"
  119. lb="("
  120. else:
  121. left=frac(roots[i-1])
  122. if include:
  123. lb="["
  124. else:
  125. lb="("
  126. if i==n:
  127. right="inf"
  128. rb=")"
  129. else:
  130. right=frac(roots[i])
  131. if include:
  132. rb="]"
  133. else:
  134. rb=")"
  135. print(lb+left+","+right+rb)
  136. # Include isolated zeros for >= or <=
  137. if include:
  138. for i in range(n):
  139. if signs[i]!=want and signs[i+1]!=want:
  140. found=True
  141. s=frac(roots[i])
  142. print("["+s+","+s+"]")
  143. if not found:
  144. print("EMPTY SET")
Filename
wcsol.py
Size
3648 bytes
SHA-256
793d3d805b839c643fe2a3c4892559264ec1224cdb2870f5c0bda9bb18a48513

Usage

Inputs

  • Integer coefficients a, b, c, and d for ax^3 + bx^2 + cx + d
  • One menu choice: 1 greater than zero, 2 greater than or equal, 3 less than zero, 4 less than or equal

Outputs

  • Each rational zero as a whole number or fraction, with its multiplicity
  • Solution intervals, including single points for the or-equal choices when a repeated zero touches the axis
  • EMPTY SET when nothing satisfies the inequality
  • Could not factor when the cubic does not split completely into rational zeros

Units: Polynomial coefficients; no physical units.

Assumptions and limitations

Assumptions

  • The leading coefficient a is nonzero.
  • Every zero of the cubic is rational.

Constraints

  • Zeros are found with the Rational Zero Theorem, so a cubic with an irrational or complex zero reports Could not factor.
  • A zero is accepted when its synthetic-division remainder is within 0.000001 of zero.
  • The search tries every factor of d over every factor of a, so very large coefficients take longer.

Known failures

  • A cubic such as x^3 - 2 has no complete rational factoring and reports Could not factor.
  • An a value of zero is not a cubic and is outside the supported input domain.
  • A menu choice other than 1 to 4 is treated as choice 3.
  • Non-integer input uses the calculator Python input error path.

Compatibility and review

Review status
Owner-tested on a TI calculator
Tested on
Owner reports personally testing this program on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
What happened
Owner reported pass on the calculator before the DuckieDai opening screen and website line were added. The steps after the opening screen are unchanged and were compared with the owner's file on desktop; this exact file has not yet been rerun on a calculator.
Dependencies
No imports
Suggested calculator name
WCSOL — 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.

Transfer and launch

  1. Confirm that your calculator is the Python-capable model named above. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
  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. WCSOL 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.

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.