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
Tried it? Did this program work on your calculator?
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.
TI-84 Plus CE Python · screen preview
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
- Enter a, b, and c. Whole numbers, decimals, and fractions such as 1/2 are accepted.
- The program shows the discriminant and how many roots to expect, then the roots.
- Complex roots are shown as decimals and in exact form.
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
- Move everything to one side first so the equation equals 0.
- D greater than 0 gives two real roots, D equal to 0 gives one repeated root, and D less than 0 gives two complex roots.
- Keep the signs: in x^2 - 5x + 6, b is -5.
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
"""DuckieDai Quadratic Solver for TI-84 Plus CE Python."""from math import sqrtdef duckiedai_intro(program_name, wait=True):title = program_name[:16]empty = 16 - len(title)left = empty // 2right = empty - leftprint("+----------------------+")print("| " + " " * left + title + " " * right + " |")print("| |")print("| __ |")print("| ___(o )> quack! |")print("| \\ <_. ) |")print("| `---' |")print("| by DuckieDai |")print("| hiddenwordscanner.com|")print("+----------------------+")print("Loading...")if wait:input("Press enter to start ")print("\n" * 8)def clear_screen():print("\n" * 8)def clean_num(n):if abs(n - round(n)) < 0.0000001:return int(round(n))return round(n, 6)def number(prompt):while True:try:text = input(prompt)if "/" in text:parts = text.split("/")if len(parts) != 2:raise ValueErrortop = float(parts[0])bottom = float(parts[1])if bottom == 0:print("Cannot divide by 0")continuereturn top / bottomreturn float(text)except ValueError:print("Enter a number")print("or fraction")def run_solver():clear_screen()print("ENTER QUADRATIC")print("ax^2+bx+c=0")print("")a = number("a: ")b = number("b: ")c = number("c: ")if a == 0:clear_screen()print("NOT QUADRATIC")print("a cannot be 0")returndisc = b * b - 4 * a * c# SCREEN 1clear_screen()print("DISCRIMINANT")print("------------")print(clean_num(disc))if disc > 0:print("2 real roots")elif abs(disc) < 0.0000001:print("1 repeated root")else:print("2 complex roots")input("\nPress enter ")# SCREEN 2clear_screen()print("ROOTS")print("-----")if abs(disc) < 0.0000001:x = -b / (2 * a)print("x =", clean_num(x))elif disc > 0:x1 = (-b + sqrt(disc)) / (2 * a)x2 = (-b - sqrt(disc)) / (2 * a)print("x1 =", clean_num(x1))print("x2 =", clean_num(x2))input("\nPress enter ")# SCREEN 3clear_screen()print("EXACT FORM")print("----------")print(clean_num(-b), "+/-")print("sqrt(", clean_num(disc), ")")print("over", clean_num(2 * a))else:real = -b / (2 * a)imag = sqrt(-disc) / abs(2 * a)print("x1 =")print(clean_num(real), "+")print(clean_num(imag), "i")print("")print("x2 =")print(clean_num(real), "-")print(clean_num(imag), "i")input("\nPress enter ")# SCREEN 3clear_screen()print("EXACT COMPLEX")print("-------------")imag_disc = int(round(-disc))outside = 1inside = imag_discfactor = 2while factor * factor <= inside:square = factor * factorwhile inside % square == 0:outside *= factorinside //= squarefactor += 1den = int(round(abs(2 * a)))# Reduce outside / denominatorx = outsidey = denwhile y != 0:x, y = y, x % ycommon = xoutside //= commonden //= commonif abs(real) < 0.0000001:if outside == 1 and den == 1:print("x = +/- i")print("* sqrt(", inside, ")")elif den == 1:print("x = +/-", outside, "i")print("* sqrt(", inside, ")")else:print("x = +/-")print(outside, "i*sqrt(", inside, ")")print("over", den)else:print("Real part:")print(clean_num(real))print("")print("Imaginary part:")if outside == 1 and den == 1:print("+/- i")print("* sqrt(", inside, ")")elif den == 1:print("+/-", outside, "i")print("* sqrt(", inside, ")")else:print("+/-")print(outside, "i*sqrt(", inside, ")")print("over", den)duckiedai_intro("Quadratic")while True:run_solver()print("")again = input("Again? y/n: ")if again.lower() != "y":breakclear_screen()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
- 1.0.1 — current version, published . Download this reviewed version
- 1.0.0 — superseded by 1.0.1, published . Download this reviewed version
Related learning
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.