0

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
Cpu_55
  • 3
  • 2
  • is this the full thing? Where are you setting a,b and c? whats the purpose of this? what have you tried? please provide more detail! – Baby_Boy Nov 08 '20 at 23:23
  • @Baby_Boy - In TI-Basic "Prompt" gets user input and sets a variable. The code provided here seems reasonably clear. – ibid Nov 20 '20 at 01:07

1 Answers1

0

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
ibid
  • 162
  • 1
  • 7