(11C) Quadratic Equation - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (11C) Quadratic Equation (/thread-10362.html) |
(11C) Quadratic Equation - Gamo - 03-21-2018 06:50 AM The program calculates the real or complex solutions of a quadratic equation. aX^2 + bX + c = 0 c [ENTER] > b [ENTER] > a > [LBL A] briefly shown [+] or [-] solution. If Positive (+) then two real solutions with R/S for second answer. If Negative (-) then two complex solutions with X<>Y for complex of +,- Program: Code:
Example: 1) 2x^2 + 5x + 3 = 0 3 ENTER 5 ENTER 2 [A] > 0.0625 (Show briefly with positive) so the solutions are real: Answer: -1.5 > [R/S] > -1 X={-1.5, -1} 2) 2x^2 + 3x + 4 = 0 4 ENTER 3 ENTER 2 [A] > -1.4375 (Show briefly with negative) so the solutions are complex: Answer: -0.75 > [X<>Y] > 1.1990 round to 1.2 x1 = -0.75 + 1.2i x2 = -0.75 - 1.2i 3) Here are examples of quadratic equations lacking the linear coefficient or the “bX”: 6x² + 144 = 0 144 ENTER 0 ENTER 6 [A] > -24 (Briefly show negative) solution are complex: Answer: 0 > [X<>Y] > 4.8990 x1 = 4.8990i x2 = -4.8990i x² – 16 = 0 16 CHS ENTER 0 ENTER 1 [A] > (Briefly show positive) solution are real. Answer: 4 > [R/S] > -4 x={4, -4} 4) Here are examples of quadratic equations lacking the constant term or “c”: 2x² + 8x = 0 0 ENTER 8 ENTER 2 [A] > (Briefly show positive) real solution. Answer: -4 [R/S] > 0 x={0, -4} Gamo RE: (11C) Quadratic Equation - Dieter - 03-22-2018 10:18 AM (03-21-2018 06:50 AM)Gamo Wrote: The program calculates the real or complex solutions of a quadratic equation. One of my first books on RPN and HP calculators also had a program for quadratic equations. To distinguish real and complex solutions it displayed "1111111111" for the latter case. In the calculator display this looks like a line of "i"s that indicate a solution with an imaginary part. ;-) I like this idea, so here is an adapted version. It differs from yours in three points: - The coefficients are entered a [ENTER] b [ENTER] c - Two real solutions are directly returned in X and Y - An imaginary solution is indicated by a line of 1s, then real and imaginary part are returned in X and Y again. Edit: The program now also handles a=0, i.e. a simple linear equation. The previous versions returned an error in this case. Code: LBL A Examples: 2x² + 5x + 3 = 0 2 [ENTER] 5 [ENTER] 3 [A] => –1,0000 [X↔Y] –1,5000 Two real solutions: –1 and –1,5. 2x² + 3x + 4 = 0 2 [ENTER] 3 [ENTER] 4 [A] => "1111111111" –0,7500 [X↔Y] 1,1990 Two conjugate complex solutions: –0,75 ± 1,199 i BTW, for those who want to try more sophisticated quadratic equation solvers: take a look at the HP15C Advanced Functions Handbook (appendix, "Example 6 continued"). It includes a special version of such a program that shows how the limitations of the standard methods can be overcome. However, note that this solves ax²–2bx+c=0. Dieter RE: (11C) Quadratic Equation - Thomas Klemm - 08-11-2018 10:34 AM (03-22-2018 10:18 AM)Dieter Wrote: BTW, for those who want to try more sophisticated quadratic equation solvers: take a look at the HP15C Advanced Functions Handbook (appendix, "Example 6 continued"). It includes a special version of such a program that shows how the limitations of the standard methods can be overcome. However, note that this solves ax²–2bx+c=0. Cf. Solve the real quadratic equation \(c-2bz+az^2=0\) for real or complex roots. RE: (11C) Quadratic Equation - Albert Chan - 08-11-2018 04:39 PM (03-22-2018 10:18 AM)Dieter Wrote: One of my first books on RPN and HP calculators also had a program for quadratic equations. I did a Quadratic Solver for Casio FX-3650P: Instead of using a special number for signaling complex roots. I CRASH the program, on purpose, by taking square root of negative discriminant. (complex roots = X +/- Y * I, stored in memory X, Y) If user is still not warned about roots being complex, I don't know what will :-) Edit: I had revised the solver, allowed for adjustable discriminant (if more precise available). Since discriminant is shown, it's sign signaled real or complex roots. |