Quadratic Equation solved in ONE step.
#1

I've seen recent postings referring to solving the quadratic equation on the 41. Here's a solution that only takes ONE program line (of user code, of course :=)

Equation: aX^2 + bX + c = 0

Input: a, b, c in Z, Y, and X of the stack.

Output: - if Z=0, then Y=Im(Z), X=Re(Z) complex roots

- if Z#0, then Y=X1, X=X2 real roots

As expected, no data registers, user flags, or any other dependencies needed. Different acoustic tones will sound depending whether real or complex roots. It is *very* fast.

Hope you enjoy, any comments/improvements are welcome.And if you're not into MCODE, then wait until the new SANDBOX Rom comes out, it will of course have it included (together with Hyperbolics and Complex Arithmetic also as machine code functions).

Best, AM

2A0 SETDEC

0F8 READ 3(X)

2BE C=-C-1 MS

10E A=C ALL

078 READ 1(Z)

261060 ?NC XQ ->1898

128 WRIT 4(L)

078 READ 1(Z)

10E A=C ALL

01D060 ?NC XQ ->1807

10E A=C ALL

0B8 READ 2(Y)

2BE C=-C-1 MS

0AE A<>C ALL

261060 ?NC XQ ->1898

0E8 WRIT 3(X)

10E A=C ALL

135060 ?NC XQ ->184D

10E A=C ALL

138 READ 4(L)

01D060 ?NC XQ ->1807

104 CLRF 8

2FE ?C#0 MS

01B JNC +03

2BE C=-C-1 MS

108 SETF 8

2F9060 ?NC XQ ->18BE

10C ?FSET 8

03B JNC +07

0A8 WRIT 2(Y)

04E C=0 ALL

068 WRIT 1(Z)

130050 LDI S&X CON: 80

083 JNC +10

128 WRIT 4(L)

10E A=C ALL

0F8 READ 3(X)

01D060 ?NC XQ ->1807

0A8 WRIT 2(Y)

138 READ 4(L)

2BE C=-C-1 MS

10E A=C ALL

0F8 READ3(X)

01D060 ?NC XQ ->1807

0E8 WRIT 3(X)

1300C6 LDI S&X CON: 198

358 ST=C XP

379058 ?NC XQ ->16DE

260 SETHEX

3E0 RTN



Possibly Related Threads…
Thread Author Replies Views Last Post
  Equation Library/App for the Prime Harold A Climer 3 1,680 10-30-2013, 10:14 AM
Last Post: CompSystems
  Equation Library on the PRIME Harold A Climer 0 1,036 10-26-2013, 10:01 AM
Last Post: Harold A Climer
  Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 1,779 10-07-2013, 05:11 PM
Last Post: CR Haeger
  EOT--TI N-Spire Equation Limit Matt Agajanian 2 1,268 09-22-2013, 12:37 PM
Last Post: Matt Agajanian
  Does Prime Have a Multiple Equation Solver? Norman Dziedzic 2 1,343 09-20-2013, 09:43 AM
Last Post: Norman Dziedzic
  Equation of the parabola given three points Gerson W. Barbosa 27 6,261 09-18-2013, 01:58 PM
Last Post: Gerson W. Barbosa
  Quadratic & Cubic Regression RPN progs Matt Agajanian 9 2,866 09-17-2013, 11:37 AM
Last Post: Jeff O.
  WP-34S: Little issue with program step indicator Miguel Toro 6 2,275 09-06-2013, 12:45 PM
Last Post: Miguel Toro
  WP34s program submission: Quadratic fit Andrew Nikitin 2 1,218 06-13-2013, 02:44 AM
Last Post: Paul Dale
  HP 50g: Customize Your Equation Library Software49g 2 1,231 05-27-2013, 12:39 PM
Last Post: Software49g

Forum Jump: