# Difference between revisions of "TI-BASIC:Quadratic Formula"

(Initial automated import) |
(Automated internal link correction) |
||

(3 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

{{Template:TI-BASIC:Routine | {{Template:TI-BASIC:Routine | ||

− | |picture= | + | |picture= |

|summary=Solves for the complex roots of a quadratic equation. | |summary=Solves for the complex roots of a quadratic equation. | ||

− | |input=''A, B, C'' - the constants in Ax | + | |input=''A, B, C'' - the constants in Ax<sup>2</sup>+Bx+C=0 |

|output=''Ans'' - a 2-element list of the two roots (or the one repeated root) | |output=''Ans'' - a 2-element list of the two roots (or the one repeated root) | ||

|variable=A, B, C | |variable=A, B, C | ||

|compatibility=TI-83/84/+/SE | |compatibility=TI-83/84/+/SE | ||

|author=thornahawk | |author=thornahawk | ||

− | |authors= | + | |authors= |

|url=http://www.unitedti.org/index.php?showtopic=7392&view=findpost&p=116156 United TI | |url=http://www.unitedti.org/index.php?showtopic=7392&view=findpost&p=116156 United TI | ||

|download=[file quadraticformula.zip] | |download=[file quadraticformula.zip] | ||

Line 14: | Line 14: | ||

-2C/(B+{-1,1}√(B²+4ACi² | -2C/(B+{-1,1}√(B²+4ACi² | ||

− | For optimization purposes, an alternate form of the quadratic formula is used (see below for the formulas). The {-1,1} list is used to replace the ± symbol -- lists can be used just as well as numbers in expressions, making the result a list as well. By using ''i''² in the expression in place of subtraction, the routine avoids having to activate [[TI-BASIC: | + | For optimization purposes, an alternate form of the quadratic formula is used (see below for the formulas). The {-1,1} list is used to replace the ± symbol -- lists can be used just as well as numbers in expressions, making the result a list as well. By using ''i''² in the expression in place of subtraction, the routine avoids having to activate [[TI-BASIC:A_Bi|A+bi]] mode to allow complex roots. |

The output is a complex list in [[TI-BASIC:Ans|Ans]] of the two roots. If there is only one root, it will be returned twice. If both roots are real, they will still be returned correctly, but stored internally as complex numbers -- so use the [[TI-BASIC:Real_Func|real(]] command on them if you want to pass them to commands that don't accept complex arguments. | The output is a complex list in [[TI-BASIC:Ans|Ans]] of the two roots. If there is only one root, it will be returned twice. If both roots are real, they will still be returned correctly, but stored internally as complex numbers -- so use the [[TI-BASIC:Real_Func|real(]] command on them if you want to pass them to commands that don't accept complex arguments. | ||

Line 32: | Line 32: | ||

The ordinary quadratic formula, and its alternate form are used: | The ordinary quadratic formula, and its alternate form are used: | ||

− | + | <math> | |

\begin{align} | \begin{align} | ||

\mathrm{For} \hspace{5pt} ax^2+bx+c = 0, \\ \\ | \mathrm{For} \hspace{5pt} ax^2+bx+c = 0, \\ \\ | ||

Line 38: | Line 38: | ||

x = \frac{2c}{-b\pm\sqrt{b^2-4ac}} | x = \frac{2c}{-b\pm\sqrt{b^2-4ac}} | ||

\end{align} | \end{align} | ||

− | + | </math> | |

+ | [[Category:TI-BASIC]] | ||

[[Category:TIBD]] | [[Category:TIBD]] |

## Latest revision as of 19:22, 24 February 2016

**Routine Summary**

Solves for the complex roots of a quadratic equation.

**Inputs**

*A, B, C* - the constants in Ax^{2}+Bx+C=0

**Outputs**

*Ans* - a 2-element list of the two roots (or the one repeated root)

**Variables Used**

A, B, C

**Calculator Compatibility**

TI-83/84/+/SE
**Author**

thornahawk*URL:* United TI
**Download**

-2C/(B+{-1,1}√(B²+4ACi²

For optimization purposes, an alternate form of the quadratic formula is used (see below for the formulas). The {-1,1} list is used to replace the ± symbol -- lists can be used just as well as numbers in expressions, making the result a list as well. By using *i*² in the expression in place of subtraction, the routine avoids having to activate A+bi mode to allow complex roots.

The output is a complex list in Ans of the two roots. If there is only one root, it will be returned twice. If both roots are real, they will still be returned correctly, but stored internally as complex numbers -- so use the real( command on them if you want to pass them to commands that don't accept complex arguments.

# Advanced

The ordinary formula above can give poor results if B is much larger than A and/or C. In that case, an alternate routine can be used:

√(B²+4ACi² If 0>real(Ansconj(B -Ans -.5(B+Ans {Ans/A,C/Ans

# Formulas

The ordinary quadratic formula, and its alternate form are used:

<math> \begin{align} \mathrm{For} \hspace{5pt} ax^2+bx+c = 0, \\ \\ x = \frac{-b\pm\sqrt{b^2-4ac}}{2a} \\ \\ x = \frac{2c}{-b\pm\sqrt{b^2-4ac}} \end{align} </math>