The program will prompt for A, B, C from f(x) = ax2+bx+c and then tell you what type of solution to expect one or two real solutions or two complex solutions. The solutions will them be left on the stack in x and y in the case of a single real solution x and y should be the same. For additional information the value of the discriminate will also be on the stack in z.
Coment | Lbl | Number | Command |
Label | Q | 001 | LBL Q |
Get the value for A | Q | 002 | INPUT A |
If A is 0 this is not a quadratic: | Q | 003 | x=0? |
So go handle the error and try again. | Q | 004 | GTO Q022 |
Get the value for B | Q | 005 | INPUT B |
Get the value for C | Q | 006 | INPUT C |
Calculate the value of the discriminate. | Q | 007 | B^2-4*A*C |
Store the Discriminate in D | Q | 008 | STO D |
Set the display equations flag. | Q | 009 | SF 10 |
If the discriminate is 0: | Q | 010 | x=0? |
Then there is one real solution for x. | Q | 011 | ONE X |
If the discrminate is greather than 0: | Q | 012 | x>0? |
Then there are two real solutions for x. | Q | 013 | TWO X |
Clear the display equations flag | Q | 014 | CF 10 |
If the discriminate is less than 0: | Q | 015 | x<0? |
Goto the code for handling imaginary solutions. | Q | 016 | GTO Q036 |
Positive 1 for adding the discriminate. | Q | 017 | 1 |
Execute the real discrimiate subroutine. | Q | 018 | XEQ Q027 |
Negative 1 for subracting the discriminate. | Q | 019 | -1 |
Execute the real discrimiate subroutine. | Q | 020 | XEQ Q027 |
End of the main subroutine | Q | 021 | RTN |
Begin the A can't be 0 code. Set dispay equations. | Q | 022 | SF 10 |
Q | 023 | A CANT BE 0 | |
Q | 024 | PSE | |
Q | 025 | CF 10 | |
Goto ask users for input again. | Q | 026 | GTO Q002 |
There real solution subroutine./ Retrieve the discriminate. | Q | 027 | RCL D |
Square root the descriminate. | Q | 028 | SQRT(x) |
Multiply by the value we dropped on the stack before.(1/-1) | Q | 029 | * |
Get B. | Q | 030 | RCL B |
Invert B because we need to add or subtract negative B. | Q | 031 | +/- |
Add the discriminate (which may be negative) to B. | Q | 032 | + |
Calculate 2A | Q | 033 | 2*A |
Calculate one solution of x leaving it on the stack | Q | 034 | / |
Return to the main subroutine. | Q | 035 | RTN |
The Complex code./Set display equations. | Q | 036 | SF 10 |
Q | 037 | COMPLEX | |
Reset the equation display flag. | Q | 038 | CF 10 |
Retrieve the discriminate. | Q | 039 | RCL D |
Invert the discriminate so we can square root it. | Q | 040 | +/- |
Square root the discriminate. | Q | 041 | SQRT(x) |
Calculate 2*A | Q | 042 | 2*A |
Divide the imaginary part of the quadratic by the bottom. | Q | 043 | / |
Drop the imaginary i on the stack | Q | 044 | i |
Multiply the imaginary part by i to make it imaginary. | Q | 045 | * |
Store the imaginary part. | Q | 046 | STO I |
Retrieve B. | Q | 047 | RCL B |
Invert B so we can have a negative B. | Q | 048 | +/- |
Calculate the bottom for the real part. | Q | 049 | 2*A |
Divide to get the whole real part. | Q | 050 | / |
Save the real part. | Q | 051 | STO R |
Calculate the add solution. Leaving it on the stack. | Q | 052 | R+I |
Calculate the subtrac solution. Leaving it on the stack. | Q | 053 | R-I |
End complex code./End program. | Q | 054 | RTN |
LN=219, CK=52E5 |