Search code examples
ti-basic

quadratic formula program trouble


So I made this program to solve the quadratic formula. This program also displays the discriminant of the quadratic formula. the formula is this (-B ± √(B^2 -4AC))/2A and the discriminant is B^2 -4AC. For some reason, the program only will spit out the correct answers when A is 1. There are no syntax errors that will prevent the code from running. Can I have a fresh set of eyes look at it?

Prompt A
Prompt B
Prompt C
(B)²-4AC→Z


(­B-√(Z))→Y
(­B+√(Z))→X

Disp "DISCRIMINANT"

Disp Z

Disp "X: "
(X)/2*A→D
(Y)/2*A→E
Disp D,E

Solution

  • I see two issues with your code.

    1. You're using B, not -B
    2. You're doing /2*A, not /(2*A). The ti83/84 family of calculators evaluates multiplication and division strictly from left to right. So /2*A is "divide by two, then multiply by A".

    I would cleanup your code as follows:

    Prompt A,B,C
    B²-4AC→Z
    Disp "DISCRIMINANT:", Z
    
    -B-√(Z)→Y
    -­B+√(Z)→X
    X/(2A)→D
    Y/(2A)→E
    Disp  "X:",D,E