Hidden WordScanner
Private scans · No account required

DuckieDai Quadratic Solver

Solve a quadratic equation, classify its discriminant, and display real or complex roots.

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 quadratic equation, classify its discriminant, and display real or complex roots.

  • Tested on a TI calculator
  • Downloaded 67 times
  • Version 1.0.1
  • 4817 bytes
  • Uses math

Before you run it

  • TI-84 Plus CE Python · tested on OS 5.8.3, Python App 5.8.3.0048
  • TI Connect CE .py conversion to a Python AppVar in RAM; physically tested one program at a time
  • Exact-form simplification for complex roots assumes integer-like negative discriminants.
  • The leading coefficient a cannot be zero.
  • Non-integer negative discriminants can make the exact complex-form simplification less suitable.

Try the DuckieDai calculator screen

A browser implementation of the documented calculation flow. It does not execute the downloaded Python.

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.

Learn the math

How solving a quadratic equation works

The idea

A quadratic equation has an x-squared term, and it can have two real solutions, one repeated solution, or two complex ones. The quadratic formula finds them every time, even when factoring fails.

The part under the square root, the discriminant, tells you which case you are in before you finish the arithmetic.

The formula

x = (-b +/- sqrt(b^2 - 4*a*c))/(2*a)

D = b^2 - 4*a*c

a, b, c
coefficients of ax^2 + bx + c = 0, with a not 0
D
the discriminant
x
the roots

Using the program

Worked example

Solve x^2 - 5x + 6 = 0. Enter a = 1, b = -5, and c = 6.

D = (-5)^2 - 4 x 1 x 6 = 1

The program shows a discriminant of 1 with 2 real roots, then x1 = 3 and x2 = 2.

Tips and common mistakes

Where this comes up

Quadratic equations run through algebra 1, algebra 2, and college algebra, and they reappear in physics whenever a projectile or a falling object is involved.

Go further: How to Find All the Zeros of a Polynomial

Go further: Solving Quadratic Equations: Factoring, Completing the Square, or the Formula

Exact reviewed bytes

Source code

Download .py

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

  1. """DuckieDai Quadratic Solver for TI-84 Plus CE Python."""
  2. from math import sqrt
  3. def duckiedai_intro(program_name, wait=True):
  4. title = program_name[:16]
  5. empty = 16 - len(title)
  6. left = empty // 2
  7. right = empty - left
  8. print("+----------------------+")
  9. print("| " + " " * left + title + " " * right + " |")
  10. print("| |")
  11. print("| __ |")
  12. print("| ___(o )> quack! |")
  13. print("| \\ <_. ) |")
  14. print("| `---' |")
  15. print("| by DuckieDai |")
  16. print("| hiddenwordscanner.com|")
  17. print("+----------------------+")
  18. print("Loading...")
  19. if wait:
  20. input("Press enter to start ")
  21. print("\n" * 8)
  22. def clear_screen():
  23. print("\n" * 8)
  24. def clean_num(n):
  25. if abs(n - round(n)) < 0.0000001:
  26. return int(round(n))
  27. return round(n, 6)
  28. def number(prompt):
  29. while True:
  30. try:
  31. text = input(prompt)
  32. if "/" in text:
  33. parts = text.split("/")
  34. if len(parts) != 2:
  35. raise ValueError
  36. top = float(parts[0])
  37. bottom = float(parts[1])
  38. if bottom == 0:
  39. print("Cannot divide by 0")
  40. continue
  41. return top / bottom
  42. return float(text)
  43. except ValueError:
  44. print("Enter a number")
  45. print("or fraction")
  46. def run_solver():
  47. clear_screen()
  48. print("ENTER QUADRATIC")
  49. print("ax^2+bx+c=0")
  50. print("")
  51. a = number("a: ")
  52. b = number("b: ")
  53. c = number("c: ")
  54. if a == 0:
  55. clear_screen()
  56. print("NOT QUADRATIC")
  57. print("a cannot be 0")
  58. return
  59. disc = b * b - 4 * a * c
  60. # SCREEN 1
  61. clear_screen()
  62. print("DISCRIMINANT")
  63. print("------------")
  64. print(clean_num(disc))
  65. if disc > 0:
  66. print("2 real roots")
  67. elif abs(disc) < 0.0000001:
  68. print("1 repeated root")
  69. else:
  70. print("2 complex roots")
  71. input("\nPress enter ")
  72. # SCREEN 2
  73. clear_screen()
  74. print("ROOTS")
  75. print("-----")
  76. if abs(disc) < 0.0000001:
  77. x = -b / (2 * a)
  78. print("x =", clean_num(x))
  79. elif disc > 0:
  80. x1 = (-b + sqrt(disc)) / (2 * a)
  81. x2 = (-b - sqrt(disc)) / (2 * a)
  82. print("x1 =", clean_num(x1))
  83. print("x2 =", clean_num(x2))
  84. input("\nPress enter ")
  85. # SCREEN 3
  86. clear_screen()
  87. print("EXACT FORM")
  88. print("----------")
  89. print(clean_num(-b), "+/-")
  90. print("sqrt(", clean_num(disc), ")")
  91. print("over", clean_num(2 * a))
  92. else:
  93. real = -b / (2 * a)
  94. imag = sqrt(-disc) / abs(2 * a)
  95. print("x1 =")
  96. print(clean_num(real), "+")
  97. print(clean_num(imag), "i")
  98. print("")
  99. print("x2 =")
  100. print(clean_num(real), "-")
  101. print(clean_num(imag), "i")
  102. input("\nPress enter ")
  103. # SCREEN 3
  104. clear_screen()
  105. print("EXACT COMPLEX")
  106. print("-------------")
  107. imag_disc = int(round(-disc))
  108. outside = 1
  109. inside = imag_disc
  110. factor = 2
  111. while factor * factor <= inside:
  112. square = factor * factor
  113. while inside % square == 0:
  114. outside *= factor
  115. inside //= square
  116. factor += 1
  117. den = int(round(abs(2 * a)))
  118. # Reduce outside / denominator
  119. x = outside
  120. y = den
  121. while y != 0:
  122. x, y = y, x % y
  123. common = x
  124. outside //= common
  125. den //= common
  126. if abs(real) < 0.0000001:
  127. if outside == 1 and den == 1:
  128. print("x = +/- i")
  129. print("* sqrt(", inside, ")")
  130. elif den == 1:
  131. print("x = +/-", outside, "i")
  132. print("* sqrt(", inside, ")")
  133. else:
  134. print("x = +/-")
  135. print(outside, "i*sqrt(", inside, ")")
  136. print("over", den)
  137. else:
  138. print("Real part:")
  139. print(clean_num(real))
  140. print("")
  141. print("Imaginary part:")
  142. if outside == 1 and den == 1:
  143. print("+/- i")
  144. print("* sqrt(", inside, ")")
  145. elif den == 1:
  146. print("+/-", outside, "i")
  147. print("* sqrt(", inside, ")")
  148. else:
  149. print("+/-")
  150. print(outside, "i*sqrt(", inside, ")")
  151. print("over", den)
  152. duckiedai_intro("Quadratic")
  153. while True:
  154. run_solver()
  155. print("")
  156. again = input("Again? y/n: ")
  157. if again.lower() != "y":
  158. break
  159. clear_screen()
  160. print("DuckieDai says: done!")
Filename
P4QUAD.py
Size
4817 bytes
SHA-256
e1fae75e367e370c296c35bd491ebd5d5c9f2d865d5de050a5530f5182bccd0e

Usage

Inputs

  • Coefficients a, b, and c for a*x^2 + b*x + c = 0

Outputs

  • Discriminant classification
  • Real or complex roots and an exact-form display

Units: Inputs represent a quadratic equation with a not equal to zero.

Assumptions and limitations

Assumptions

  • Exact-form simplification for complex roots assumes integer-like negative discriminants.

Constraints

  • The leading coefficient a cannot be zero.

Known failures

  • Non-integer negative discriminants can make the exact complex-form simplification less suitable.

Compatibility and review

Review status
Tested on a TI calculator
Tested on
Owner-tested TI-84 Plus CE Python calculator; exact branded .py transferred and launched individually
What happened
Passed: owner tested the exact 1.0.1 branded source bytes on a TI 84 Plus CE Python calculator.
Dependencies
math
Suggested calculator name
P4QUAD — 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

Download the .py file, send it to your calculator with TI Connect CE as P4QUAD or another name, then open the Python App and try the worked example on this page first.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

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, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.