Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Quadratic formula
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Formula that provides the solutions to a quadratic equation}} {{confused|quadratic function|quadratic equation}} [[File:Roots of a quadratic function via the quadratic formula.png|alt=A graph of a parabola-shaped function which intersects the x-axis at x = 1 and x = 5|thumb|The roots of the quadratic function {{math|1=''y'' = {{sfrac|1|2}}''x''<sup>2</sup> − 3''x'' + {{sfrac|5|2}}}} are the places where the graph intersects the {{mvar|x}}-axis, the values {{math|1=''x'' = 1}} and {{math|1=''x'' = 5}}. They can be found via the quadratic formula.]] In [[elementary algebra]], the '''quadratic formula''' is a [[closed-form expression]] describing the solutions of a [[quadratic equation]]. Other ways of solving quadratic equations, such as [[completing the square]], yield the same solutions. Given a general quadratic equation of the form {{tmath|1=\textstyle ax^2 + bx + c = 0}}, with {{tmath|x}} representing an unknown, and [[coefficient]]s {{tmath|a}}, {{tmath|b}}, and {{tmath|c}} representing known [[real number|real]] or [[complex number|complex]] numbers with {{tmath|a \neq 0}}, the values of {{tmath|x}} satisfying the equation, called the [[Zero of a function|''roots'']] or ''zeros'', can be found using the quadratic formula, <math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}, </math> where the [[plus–minus sign|plus–minus symbol]] "{{tmath|\pm}}" indicates that the equation has two roots.<ref>{{Citation|last=Sterling|first=Mary Jane|title=Algebra I For Dummies | year=2010 | publisher=Wiley Publishing | isbn=978-0-470-55964-2 | url=https://books.google.com/books?id=2toggaqJMzEC&q=quadratic+formula&pg=PA219 | page=219}}</ref> Written separately, these are: <math display=block> x_1 = \frac{-b + \sqrt {b^2 - 4ac}}{2a}, \qquad x_2 = \frac{-b - \sqrt {b^2 - 4ac}}{2a}. </math> The quantity {{tmath|1=\textstyle \Delta = b^2 - 4ac}} is known as the [[discriminant]] of the quadratic equation.<ref>{{Cite web |mode=cs2 | url=https://www.khanacademy.org/math/algebra/x2f8bb11595b61c86:quadratic-functions-equations/x2f8bb11595b61c86:quadratic-formula-a1/a/discriminant-review|title=Discriminant review|website=Khan Academy|language=en|access-date=2019-11-10}}</ref> If the coefficients {{tmath|a}}, {{tmath|b}}, and {{tmath|c}} are real numbers then when {{tmath|\Delta > 0}}, the equation has two distinct [[real number|real]] roots; when {{tmath|1= \Delta = 0}}, the equation has one [[repeated root|repeated]] real root; and when {{tmath|\Delta < 0}}, the equation has ''no'' real roots but has two distinct complex roots, which are [[complex conjugate]]s of each other. Geometrically, the roots represent the {{tmath|x}} values at which the [[graph of a function|graph]] of the [[quadratic function]] {{tmath|1=\textstyle y = ax^2 + bx + c}}, a [[parabola]], crosses the {{tmath|x}}-axis: the graph's {{tmath|x}}-intercepts.<ref>{{Cite web |mode=cs2 |url=https://www.khanacademy.org/math/algebra/x2f8bb11595b61c86:quadratic-functions-equations/x2f8bb11595b61c86:quadratic-formula-a1/a/quadratic-formula-explained-article| title=Understanding the quadratic formula|website=Khan Academy|language=en|access-date=2019-11-10}}</ref> The quadratic formula can also be used to identify the parabola's [[axis of symmetry]].<ref>{{Cite web |mode=cs2 |url=https://www.mathwarehouse.com/geometry/parabola/axis-of-symmetry.php|title=Axis of Symmetry of a Parabola. How to find axis from equation or from a graph. To find the axis of symmetry ...|website=www.mathwarehouse.com|access-date=2019-11-10}}</ref> == Derivation by completing the square == [[File:Quadratic formula via completing the square.png|thumb|upright=1.25|To complete the square, form a squared binomial on the left-hand side of a quadratic equation, from which the solution can be found by taking the square root of both sides.]] The standard way to derive the quadratic formula is to apply the method of [[completing the square]] to the generic quadratic equation {{tmath|1=\textstyle ax^2 + bx + c = 0}}.<ref>{{citation | title=Schaum's Outline of Theory and Problems of Elementary Algebra | first1=Barnett | last1=Rich |first2=Philip |last2=Schmidt |publisher=The McGraw–Hill Companies | year=2004 |isbn=0-07-141083-X | url=https://books.google.com/books?id=8PRU9cTKprsC | at = [https://books.google.com/books?id=8PRU9cTKprsC&pg=PA291 Chapter 13 §4.4, p. 291]}}</ref><ref>Li, Xuhui. ''An Investigation of Secondary School Algebra Teachers' Mathematical Knowledge for Teaching Algebraic Equation Solving'', p. 56 (ProQuest, 2007): "The quadratic formula is the most general method for solving quadratic equations and is derived from another general method: completing the square."</ref><ref>Rockswold, Gary. ''College algebra and trigonometry and precalculus'', p. 178 (Addison Wesley, 2002).</ref><ref>Beckenbach, Edwin et al. ''Modern college algebra and trigonometry'', p. 81 (Wadsworth Pub. Co., 1986).</ref> The idea is to manipulate the equation into the form {{tmath|1=\textstyle (x + k)^2 = s}} for some expressions {{tmath|k}} and {{tmath|s}} written in terms of the coefficients; take the [[square root]] of both sides; and then isolate {{tmath|x}}. We start by dividing the equation by the quadratic coefficient {{tmath|a}}, which is allowed because {{tmath|a}} is non-zero. Afterwards, we subtract the constant term {{tmath|c/a}} to isolate it on the right-hand side: <math display=block>\begin{align} ax^{2\vphantom|} + bx + c &= 0 \\[3mu] x^2 + \frac{b}{a} x + \frac{c}{a} &= 0 \\[3mu] x^2 + \frac{b}{a} x &= -\frac{c}{a}. \end{align}</math> The left-hand side is now of the form {{tmath|\textstyle x^2 + 2kx}}, and we can "complete the square" by adding a constant {{tmath|\textstyle k^2}} to obtain a squared binomial {{tmath|1=\textstyle x^2 + 2kx + k^2 = {} }}{{wbr}}{{tmath|\textstyle (x + k)^2}}. In this example we add {{tmath|\textstyle (b / 2a)^2}} to both sides so that the left-hand side can be factored (see the figure): <math display=block>\begin{align} x^2 + 2\left(\frac{b}{2a}\right)x + \left(\frac{b}{2a}\right)^2 &= -\frac{c}{a}+\left( \frac{b}{2a} \right)^2 \\[5mu] \left(x + \frac{b}{2a}\right)^2 &= \frac{b^2 - 4ac}{4a^2} . \end{align}</math> Because the left-hand side is now a perfect square, we can easily take the square root of both sides: <math display=block> x + \frac{b}{2a} = \pm\frac{\sqrt{b^2 - 4ac}}{2a}. </math> Finally, subtracting {{tmath|b/2a}} from both sides to isolate {{tmath|x}} produces the quadratic formula: <math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} . </math> == Equivalent formulations == The quadratic formula can equivalently be written using various alternative expressions, for instance <math display=block> x = -\frac{b}{2a} \pm \sqrt{\left(\frac{b}{2a}\right)^2-\frac{c}{a}}, </math> which can be derived by first dividing a quadratic equation by {{tmath|2a}}, resulting in {{tmath|1=\textstyle \tfrac12 x^2 + \tfrac{b}{2a}x + \tfrac{c}{2a} = 0}}, then substituting the new coefficients into the standard quadratic formula. Because this variant allows re-use of the intermediately calculated quantity {{tmath|\tfrac{b}{2a} }}, it can slightly reduce the arithmetic involved. === Square root in the denominator <span class="anchor" id="Citardauq"></span> === A lesser known quadratic formula, first mentioned by [[Giulio Carlo de' Toschi di Fagnano|Giulio Fagnano]],<ref>Specifically, Fagnano began with the equation {{tmath|1= xx + bb = ax}} and found the solutions to be <math display=block>x = \frac{2 bb}{a \mp a \sqrt{1 - \dfrac{4bb}{aa}}}.</math> (In the 18th century, the square {{tmath|\textstyle x^2}} was conventionally written as {{nobr|{{tmath|xx}}.)}} {{pb}} {{citation |last=Fagnano |first=Giulio Carlo |author-link=Giulio Carlo de' Toschi di Fagnano |title=Produzioni matematiche del conte Giulio Carlo di Fagnano, Marchese de' Toschi, e DiSant' Ononio |volume=1 |place=Pesaro |publisher=Gavelliana |year=1750 |chapter=Applicazione dell' algoritmo nuovo Alla resoluzione analitica dell' equazioni del secondo, del terzo, e del quarto grado |trans-chapter=Application of a new algorithm to the analytical resolution of equations of the second, third, and fourth degree |language=it |at=Appendice seconda, eq. 6, {{pgs|467}} |doi=10.3931/e-rara-8663 |doi-access=free |chapter-url=https://era-prod11.ethz.ch/zut/content/zoom/2406151 }}</ref> describes the same roots via an equation with the square root in the denominator (assuming {{tmath|c \neq 0}}): <math display=block> x= \frac{2c}{-b \mp \sqrt {b^2 - 4ac}}. </math> Here the [[minus–plus symbol]] "{{tmath|\mp}}" indicates that the two roots of the quadratic equation, in the same order as the standard quadratic formula, are <math display=block> x_1 = \frac{2c}{-b - \sqrt {b^2 - 4ac}}, \qquad x_2 = \frac{2c}{-b + \sqrt {b^2 - 4ac}}. </math> This variant has been jokingly called the "citardauq" formula ("quadratic" spelled backwards).<ref>{{citation |last=Goff |first=Gerald K. |year=1976 |title=The Citardauq Formula |journal=The Mathematics Teacher |volume=69 |number=7 |pages=550–551 |doi=10.5951/MT.69.7.0550 |jstor=27960584 }}</ref> When {{tmath|-b}} has the opposite sign as either {{tmath|\textstyle +\sqrt {b^2 - 4ac} }} or {{tmath|\textstyle -\sqrt {b^2 - 4ac} }}, subtraction can cause [[catastrophic cancellation]], resulting in poor accuracy in numerical calculations; choosing between the version of the quadratic formula with the square root in the numerator or denominator depending on the sign of {{tmath|b}} can avoid this problem. See {{slink|#Numerical calculation}} below. This version of the quadratic formula is used in [[Muller's method]] for finding the roots of general functions. It can be derived from the standard formula from the identity {{tmath|1= x_1 x_2 = c/a}}, one of [[Vieta's formulas]]. Alternately, it can be derived by dividing each side of the equation {{tmath|1=\textstyle ax^2 + bx + c = 0}} by {{tmath|\textstyle x^2}} to get {{tmath|1=\textstyle cx^{-2} + bx^{-1} + a = 0}}, applying the standard formula to find the two roots {{tmath|\textstyle x^{-1}\! }}, and then taking the reciprocal to find the roots {{tmath|x}} of the original equation. == {{anchor|Derivations}} Other derivations == Any generic method or algorithm for solving quadratic equations can be applied to an equation with symbolic coefficients and used to derive some closed-form expression equivalent to the quadratic formula. Alternative methods are sometimes simpler than completing the square, and may offer interesting insight into other areas of mathematics. === Completing the square by Śrīdhara's method === Instead of dividing by {{tmath|a}} to isolate {{tmath|\textstyle x^2\!}}, it can be slightly simpler to multiply by {{tmath|4a}} instead to produce {{tmath|\textstyle (2ax)^2\!}}, which allows us to complete the square without need for fractions. Then the steps of the derivation are:<ref name="Hoehn1975">{{citation |last=Hoehn |first=Larry |title=A More Elegant Method of Deriving the Quadratic Formula |journal=The Mathematics Teacher |year=1975 |volume=68 |issue=5 |pages=442–443 |jstor=27960212 |doi=10.5951/MT.68.5.0442 }}</ref> # Multiply each side by {{tmath|4a}}. # Add {{tmath|\textstyle b^2 - 4ac}} to both sides to complete the square. # Take the square root of both sides. # Isolate {{tmath|x}}. Applying this method to a generic quadratic equation with symbolic coefficients yields the quadratic formula: <math display=block>\begin{align} ax^2 + bx + c &= 0 \\[3mu] 4 a^2 x^2 + 4abx + 4ac &= 0 \\[3mu] 4 a^2 x^2 + 4abx + b^2 &= b^2 - 4ac \\[3mu] (2ax + b)^2 &= b^2 - 4ac \\[3mu] 2ax + b &= \pm \sqrt{b^2 - 4ac} \\[5mu] x &= \dfrac{-b\pm\sqrt{b^2 - 4ac }}{2a}. \vphantom\bigg) \end{align}</math> This method for completing the square is ancient and was known to the 8th–9th century Indian mathematician [[Śrīdhara]].<ref>Starting from a quadratic equation of the form {{tmath|1=\textstyle ax^2 + bx = c}}, Śrīdhara's method, as quoted by [[ Bhāskara II]] (c. 1150): "Multiply both sides of the equation by a number equal to four times the [coefficient of the] square, and add to them a number equal to the square of the original [coefficient of the] unknown quantity. [Then extract the root.]". {{pb}} {{harvnb|Smith|1923|loc=[https://archive.org/details/historyofmathema0001davi/page/446 {{pgs|446}}]}}</ref> Compared with the modern standard method for completing the square, this alternate method avoids fractions until the last step and hence does not require a rearrangement after step 3 to obtain a common denominator in the right side.<ref name=Hoehn1975/> ===By substitution=== Another derivation uses a [[change of variables]] to eliminate the linear term. Then the equation takes the form {{tmath|1=\textstyle u^2 = s}} in terms of a new variable {{tmath|u}} and some constant expression {{tmath|s}}, whose roots are then {{tmath|1= u = \pm \sqrt s}}. By substituting {{tmath|1= x = u - \tfrac{b}{2a} }} into {{tmath|1=\textstyle ax^2 + bx + c = 0}}, expanding the products and combining like terms, and then solving for {{tmath|\textstyle u^2\!}}, we have: <math display=block>\begin{align} a\left(u-\frac{b}{2a}\right)^2 + b\left(u-\frac{b}{2a}\right) + c &=0 \\[5mu] a\left(u^2-\frac{b}{a}u+\frac{b^2}{4a^2}\right) + b\left(u-\frac{b}{2a}\right) + c &= 0 \\[5mu] au^2 - bu + \frac{b^2}{4a} + bu - \frac{b^2}{2a}+c &= 0 \\[5mu] au^2 + \frac{4ac - b^2}{4a} &= 0 \\[5mu] u^2 &= \frac{b^2 - 4ac}{4a^2}. \end{align}</math> Finally, after taking a square root of both sides and substituting the resulting expression for {{tmath|u}} back into {{tmath|1= x = u - \tfrac{b}{2a},}} the familiar quadratic formula emerges: <math display=block> x = \frac{-b\pm \sqrt{b^2 - 4ac}}{2a}. </math> ===By using algebraic identities=== The following method was used by many historical mathematicians:<ref>{{citation |doi = 10.1080/00207390802642237|title = The legacy of Leonhard Euler – a tricentennial tribute | year = 2009|last1 = Debnath|first1 = Lokenath|journal = International Journal of Mathematical Education in Science and Technology|volume = 40|issue = 3|pages = 353–388 | s2cid = 123048345}}</ref> Let the roots of the quadratic equation {{tmath|1=\textstyle ax^2 + bx + c = 0}} be {{tmath|\alpha}} and {{tmath|\beta}}. The derivation starts from an identity for the square of a difference (valid for any two complex numbers), of which we can take the square root on both sides: <math display=block>\begin{align} (\alpha - \beta)^2 &= (\alpha + \beta)^2 - 4 \alpha\beta \\[3mu] \alpha - \beta &= \pm\sqrt{(\alpha + \beta)^2 - 4 \alpha\beta} . \end{align}</math> Since the coefficient {{tmath|a \neq 0}}, we can divide the quadratic equation by {{tmath|a}} to obtain a [[monic polynomial|monic]] polynomial with the same roots. Namely, <math display=block> x^2 + \frac{b}{a}x + \frac{c}{a} = (x - \alpha)(x - \beta) = x^2 - (\alpha + \beta)x + \alpha\beta . </math> This implies that the sum {{tmath|1= \alpha + \beta = -\tfrac ba}} and the product {{tmath|1= \alpha\beta = \tfrac ca}}. Thus the identity can be rewritten: <math display=block> \alpha - \beta = \pm\sqrt{\left(-\frac{b}{a}\right)^2-4\frac{c}{a}} = \pm\frac{\sqrt{b^2 - 4ac}}{a} . </math> Therefore, <math display=block>\begin{align} \alpha &= \tfrac12(\alpha + \beta) + \tfrac12(\alpha - \beta) = -\frac{b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a}, \\[10mu] \beta &= \tfrac12(\alpha + \beta) - \tfrac12(\alpha - \beta) = -\frac{b}{2a} \mp \frac{\sqrt{b^2 - 4ac}}{2a}. \end{align}</math> The two possibilities for each of {{tmath|\alpha}} and {{tmath|\beta}} are the same two roots in opposite order, so we can combine them into the standard quadratic equation: <math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} .</math> ===By Lagrange resolvents=== {{details|Lagrange resolvents}} An alternative way of deriving the quadratic formula is via the method of [[Lagrange resolvents]],<ref name=Clark>Clark, A. (1984). ''Elements of abstract algebra''. Courier Corporation. p. 146.</ref> which is an early part of [[Galois theory]].<ref name="efei">{{citation |title=Elliptic functions and elliptic integrals |first1=Viktor |last1=Prasolov |first2=Yuri |last2=Solovyev |publisher=AMS Bookstore |year=1997 |isbn=978-0-8218-0587-9 |url=https://books.google.com/books?id=fcp9IiZd3tQC&pg=PA134 |page=134 }}</ref> This method can be generalized to give the roots of [[cubic polynomial]]s and [[quartic polynomial]]s, and leads to Galois theory, which allows one to understand the solution of algebraic equations of any degree in terms of the [[symmetry group]] of their roots, the [[Galois group]]. This approach focuses on the roots themselves rather than algebraically rearranging the original equation. Given a monic quadratic polynomial {{tmath|\textstyle x^2 + px + q}} assume that {{tmath|\alpha}} and {{tmath|\beta}} are the two roots. So the polynomial factors as <math display=block>\begin{align} x^2+px+q &= (x-\alpha)(x-\beta) \\[3mu] &= x^2-(\alpha+\beta)x+\alpha\beta \end{align}</math> which implies {{tmath|1= p = -(\alpha + \beta)}} and {{tmath|1= q = \alpha\beta}}. Since multiplication and addition are both [[commutative property|commutative]], exchanging the roots {{tmath|\alpha}} and {{tmath|\beta}} will not change the coefficients {{tmath|p}} and {{tmath|q}}: one can say that {{tmath|p}} and {{tmath|q}} are [[symmetric polynomials]] in {{tmath|\alpha}} and {{tmath|\beta}}. Specifically, they are the [[elementary symmetric polynomials]] – any symmetric polynomial in {{tmath|\alpha}} and {{tmath|\beta}} can be expressed in terms of {{tmath|\alpha + \beta}} and {{tmath|\alpha\beta}} instead. The Galois theory approach to analyzing and solving polynomials is to ask whether, given coefficients of a polynomial each of which is a symmetric function in the roots, one can "break" the symmetry and thereby recover the roots. Using this approach, solving a polynomial of degree {{tmath|n}} is related to the ways of rearranging ("[[permutation|permuting]]") {{tmath|n}} terms, called the [[symmetric group]] on {{tmath|n}} letters and denoted {{tmath|S_n}}. For the quadratic polynomial, the only ways to rearrange two roots are to either leave them be or to [[Transposition (mathematics)|transpose]] them, so solving a quadratic polynomial is simple. To find the roots {{tmath|\alpha}} and {{tmath|\beta}}, consider their sum and difference: <math display=block> r_1 = \alpha + \beta, \quad r_2 = \alpha - \beta . </math> These are called the ''Lagrange resolvents'' of the polynomial, from which the roots can be recovered as <math display=block> \alpha = \tfrac12 (r_1 + r_2), \quad \beta = \tfrac12(r_1 - r_2). </math> Because {{tmath|1= r_1 = \alpha + \beta}} is a symmetric function in {{tmath|\alpha}} and {{tmath|\beta}}, it can be expressed in terms of {{tmath|p}} and {{tmath|q,}} specifically {{tmath|1= r_1 = -p}} as described above. However, {{tmath|1= r_2 = \alpha - \beta}} is not symmetric, since exchanging {{tmath|\alpha}} and {{tmath|\beta}} yields the additive inverse {{tmath|1= -r_2 = \beta - \alpha}}. So {{tmath|r_2}} cannot be expressed in terms of the symmetric polynomials. However, its square {{tmath|1=\textstyle r_2^2 = (\alpha - \beta)^2}} ''is'' symmetric in the roots, expressible in terms of {{tmath|p}} and {{tmath|q}}. Specifically {{tmath|1=\textstyle r_2^2 = (\alpha - \beta)^2 = {} }}{{wbr}}{{tmath|1=\textstyle (\alpha + \beta)^2 - 4\alpha\beta = {} }}{{wbr}}{{tmath|1=\textstyle p^2 - 4q}}, which implies {{tmath|1=\textstyle r_2 = \pm \sqrt{p^2 - 4q} }}. Taking the positive root "breaks" the symmetry, resulting in <math display=block> r_1 = -p, \qquad r_2 = {\textstyle \sqrt{p^2 - 4q}} </math> from which the roots {{tmath|\alpha}} and {{tmath|\beta}} are recovered as <math display=block> x = \tfrac12(r_1 \pm r_2) = \tfrac{1}{2} \bigl({-p} \pm {\textstyle \sqrt{p^2 - 4q}}\,\bigr) </math> which is the quadratic formula for a monic polynomial. Substituting {{tmath|1= p = b/a}}, {{tmath|1= q = c/a}} yields the usual expression for an arbitrary quadratic polynomial. The resolvents can be recognized as <math display=block> \tfrac12 r_1 = -\tfrac12p = -\frac{b}{2a}, \qquad r_2^2 = p_2 - 4q = \frac{b^2 - 4ac}{a^2}, </math> respectively the vertex and the discriminant of the monic polynomial. A similar but more complicated method works for [[cubic equation]]s, which have three resolvents and a quadratic equation (the "resolving polynomial") relating {{tmath|r_2}} and {{tmath|r_3}}, which one can solve by the quadratic equation, and similarly for a [[quartic equation]] ([[degree of a polynomial|degree]] 4), whose resolving polynomial is a cubic, which can in turn be solved.<ref name=Clark/> The same method for a [[quintic equation]] yields a polynomial of degree 24, which does not simplify the problem, and, in fact, solutions to quintic equations in general cannot be expressed using only roots. == Numerical calculation == The quadratic formula is exactly correct when performed using the idealized arithmetic of [[real number]]s, but when approximate arithmetic is used instead, for example pen-and-paper arithmetic carried out to a fixed number of decimal places or the [[Floating-point arithmetic|floating-point]] binary arithmetic available on computers, the limitations of the number representation can lead to substantially inaccurate results unless great care is taken in the implementation. Specific difficulties include [[catastrophic cancellation]] in computing the sum {{tmath|\textstyle -b \pm \sqrt\Delta}} if {{tmath|\textstyle b \approx \pm \sqrt\Delta}}; catastrophic calculation in computing the discriminant {{tmath|1=\textstyle \Delta = b^2 - 4ac}} itself in cases where {{tmath|\textstyle b^2 \approx 4ac}}; degeneration of the formula when {{tmath|a}}, {{tmath|b}}, or {{tmath|c}} is represented as zero or infinite; and possible [[Floating-point arithmetic#Exception handling|overflow or underflow]] when multiplying or dividing extremely large or small numbers, even in cases where the roots can be accurately represented.<ref>{{citation |last=Forsythe |first=George E. |author-link=George E. Forsythe |year=1969 |chapter=Solving a Quadratic Equation on a Computer |title=The Mathematical Sciences: A Collection of Essays |publisher=MIT Press |pages=138–152 |isbn=0-262-03026-8 |chapter-url=https://archive.org/details/1969.-bers-the-mathematical-sciences.-a-collection-of-essays/page/138/ }}</ref><ref name=goualard>{{cite tech report |mode=cs2 |last=Goualard |first=Frédéric |year=2023 |title=The Ins and Outs of Solving Quadratic Equations with Floating-Point Arithmetic |publisher=University of Nantes |id={{HAL|hal-04116310}} }}</ref> Catastrophic cancellation occurs when two numbers which are approximately equal are subtracted. While each of the numbers may independently be representable to a certain number of digits of precision, the identical leading digits of each number cancel, resulting in a difference of lower relative precision. When {{tmath|\textstyle b \approx \sqrt \Delta}}, evaluation of {{tmath|\textstyle -b + \sqrt \Delta}} causes catastrophic cancellation, as does the evaluation of {{tmath|\textstyle -b - \sqrt \Delta}} when {{tmath|\textstyle b \approx -\sqrt\Delta}}. When using the standard quadratic formula, calculating one of the two roots always involves addition, which preserves the working precision of the intermediate calculations, while calculating the other root involves subtraction, which compromises it. Therefore, naïvely following the standard quadratic formula often yields one result with less relative precision than expected. Unfortunately, introductory algebra textbooks typically do not address this problem, even though it causes students to obtain inaccurate results in other school subjects such as introductory chemistry.<ref>{{citation |last=Thompson, H. Bradford |year=1987 |title=Good numerical technique in chemistry: The quadratic equation |journal=Journal of Chemical Education |volume=64 |number=12 |page=1009 |doi=10.1021/ed064p1009 |bibcode=1987JChEd..64.1009T }}</ref> For example, if trying to solve the equation {{tmath|1=\textstyle x^2 - 1634x + 2 = 0}} using a pocket calculator, the result of the quadratic formula {{tmath|1=\textstyle x = 817 \pm \sqrt{667\,487} }} might be approximately calculated as:<ref> This example comes from: {{pb}} {{citation |title=Essentials of Numerical Analysis with Pocket Calculator Demonstrations |last=Henrici |first=Peter |author-link=Peter Henrici |year=1982 |place=New York |publisher=Wiley |page=13}}</ref> <math display=block>\begin{alignat}{3} x_1 &= 817 + 816.998\,776\,0 &&= 1.633\,998\,776 \times 10^3, \\ x_2 &= 817 - 816.998\,776\,0 &&= 1.224 \times 10^{-3}. \end{alignat}</math> Even though the calculator used ten decimal digits of precision for each step, calculating the difference between two approximately equal numbers has yielded a result for {{tmath|x_2}} with only four correct digits. One way to recover an accurate result is to use the identity {{tmath|1= x_1 x_2 = c/a}}. In this example {{tmath|x_2}} can be calculated as {{tmath|1= x_2 = 2 / x_1 = {} }}{{wbr}}{{tmath|1.223\,991\,125 \times 10^{-3}\!}}, which is correct to the full ten digits. Another more or less equivalent approach is to use the version of the quadratic formula with the square root in the denominator to calculate one of the roots (see {{slink|#Square root in the denominator}} above). Practical computer implementations of the solution of quadratic equations commonly choose which formula to use for each root depending on the sign of {{tmath|b}}.<ref>{{citation |last=Forsythe |first=George E. |title=How Do You Solve a Quadratic Equation |year=1966 |publisher=Stanford University |id=STAN-CS-66-40 (AD639052) |type=Tech report |url=https://apps.dtic.mil/sti/tr/pdf/AD0639052.pdf }}</ref> These methods do not prevent possible overflow or underflow of the floating-point exponent in computing {{tmath|\textstyle b^2}} or {{tmath|4ac}}, which can lead to numerically representable roots not being computed accurately. A more robust but computationally expensive strategy is to start with the substitution {{tmath|1=\textstyle x = -u \sgn(b)\sqrt{\vert c\vert} \big/\! \sqrt{\vert a\vert} }}, turning the quadratic equation into <math display=block> u^2 - 2 \frac{|b|}{2\sqrt{|a|}\sqrt{|c|}}u + \sgn(c) = 0, </math> where {{tmath|\sgn}} is the [[sign function]]. Letting {{tmath|1=\textstyle d = \vert b\vert\big/2\sqrt{\vert a\vert}\sqrt{\vert c\vert} }}, this equation has the form {{tmath|1=\textstyle u^2 - 2du \pm 1 = 0}}, for which one solution is {{tmath|1=\textstyle u_1 = d + \sqrt{d^2 \mp 1} }} and the other solution is {{tmath|1=\textstyle u_2 = \pm1 / u_1}}. The roots of the original equation are then {{tmath|1=\textstyle x_1 = -\sgn(b)\bigl(\sqrt{\vert c\vert} \big/\!\sqrt{\vert a\vert}~\!\bigr) u_1}} and {{tmath|1=\textstyle x_2 = -\sgn(b)\bigl(\sqrt{\vert c\vert} \big/\!\sqrt{\vert a\vert}~\!\bigr) u_2}}.<ref>{{citation |last=Baker |first=Henry G. |year=1998 |title=You Could Learn a Lot from a Quadratic: Overloading Considered Harmful |journal=SIGPLAN Notices |volume=33 |issue=1 |pages=30–38 |doi=10.1145/609742.609746 |doi-access=free }}</ref><ref>{{citation |last1=Mastronardi |first1=Nicola |last2=Van Dooren |first2=Paul |year=2015 |title=Revisiting the stability of computing the roots of a quadratic polynomial |journal=Electronic Transactions on Numerical Analysis |volume=44 |pages=73–83 |arxiv=1409.8072 |url=https://etna.math.kent.edu/volumes/2011-2020/vol44/abstract.php?vol=44&pages=73-82 }}</ref> With additional complication the expense and extra rounding of the square roots can be avoided by approximating them as powers of two, while still avoiding exponent overflow for representable roots.{{r|goualard}} ==Historical development== The earliest methods for solving quadratic equations were geometric. Babylonian cuneiform tablets contain problems reducible to solving quadratic equations.{{sfn|Irving|2013|p=34}} The Egyptian [[Berlin Papyrus 6619|Berlin Papyrus]], dating back to the [[Middle Kingdom of Egypt|Middle Kingdom]] (2050 BC to 1650 BC), contains the solution to a two-term quadratic equation.<ref>{{citation |title=The Cambridge Ancient History Part 2 Early History of the Middle East | url=https://books.google.com/books?id=slR7SFScEnwC&pg=PA530 | year=1971 | publisher=Cambridge University Press | isbn=978-0-521-07791-0 | page=530}}</ref> The Greek mathematician [[Euclid]] (circa 300 BC) used geometric methods to solve quadratic equations in Book 2 of his ''[[Euclid's Elements|Elements]]'', an influential mathematical treatise{{sfn|Irving|2013|p=39}} Rules for quadratic equations appear in the Chinese ''[[The Nine Chapters on the Mathematical Art]]'' circa 200 BC.<ref name=Aitken>{{cite web |mode=cs2 |last=Aitken|first=Wayne|title=A Chinese Classic: The Nine Chapters | url=http://public.csusm.edu/aitken_html/m330/china/ninechapters.pdf | publisher = Mathematics Department, California State University|access-date=28 April 2013}}</ref>{{sfn|Smith|1923|loc=[https://archive.org/details/historyofmathema0001davi/page/380 {{pgs|380}}] }} In his work ''[[Arithmetica]]'', the Greek mathematician [[Diophantus]] (circa 250 AD) solved quadratic equations with a method more recognizably algebraic than the geometric algebra of Euclid.{{sfn|Irving|2013|p=39}} His solution gives only one root, even when both roots are positive.{{sfn|Smith|1923|loc=[https://archive.org/details/historyofmathema0001davi/page/134 {{pgs|134}}] }} The [[Indian mathematics|Indian mathematician]] [[Brahmagupta]] included a generic method for finding one root of a quadratic equation in his treatise ''[[Brāhmasphuṭasiddhānta]]'' (circa 628 AD), written out in words in the style of that time.<ref name=Bradley>Bradley, Michael. ''The Birth of Mathematics: Ancient Times to 1300'', p. 86 (Infobase Publishing 2006).</ref><ref>Mackenzie, Dana. ''The Universe in Zero Words: The Story of Mathematics as Told through Equations'', p. 61 (Princeton University Press, 2012).</ref> His solution of the quadratic equation {{tmath|1=\textstyle ax^2 + bx = c}} was as follows: "To the absolute number multiplied by four times the [coefficient of the] square, add the square of the [coefficient of the] middle term; the square root of the same, less the [coefficient of the] middle term, being divided by twice the [coefficient of the] square is the value."<ref name=Stillwell2004>{{citation |last=Stillwell |first=John |title=Mathematics and Its History |edition=2nd |year=2004 |publisher=Springer |isbn=0-387-95336-1|page=87}}</ref> In modern notation, this can be written {{tmath|1=\textstyle x = \bigl(\sqrt{c \cdot 4a + b^2} - b\bigr) \big/ 2a }}. The Indian mathematician [[Śrīdhara]] (8th–9th century) came up with a similar algorithm for solving quadratic equations in a now-lost work on algebra quoted by [[Bhāskara II]].<ref>{{MacTutor |id=Sridhara |title=Sridhara |year=2000}}</ref> The modern quadratic formula is sometimes called ''Sridharacharya's formula'' in India and ''Bhaskara's formula'' in Brazil.<ref>{{cite thesis |last=Rocha |first=Rodrigo Luis da |title=O uso da expressão 'fórmula de bhaskara' em livros didáticos brasileiros e sua relação com o método resolutivo da equação do 2º grau |trans-title=The use of the expression 'bhaskara formula' in Brazilian textbooks and its relationship with the method for solving quadratic equations |language=pt |hdl=1884/82597 |year=2023 |type=master's thesis |publisher=Universidade Federal do Paraná }} {{pb}} {{cite thesis |year=2019 |last=Guedes |first=Eduardo Gomes |type=master's thesis |hdl=1884/66582 |publisher=Universidade Federal do Paraná |title=A equação quadrática e as contribuições de Bhaskara |trans-title=The quadratic equation and Bhaskara's contributions |language=pt }} {{pb}} {{cite magazine |url=https://www.thejuggernaut.com/fibonacci-sequence-indian-math-history-quadratic-formula |title=India Molded Math. Then Europe Claimed It. |quote=For instance, some Indian schools call the quadratic formula Sridharacharya's formula and some Brazilian schools call it Bhaskara's formula. |magazine=The Juggernaut |last=Banerjee |first=Isha |date=July 2, 2024 |url-access=subscription }}</ref> The 9th-century Persian mathematician [[Muḥammad ibn Mūsā al-Khwārizmī]] solved quadratic equations algebraically.{{sfn|Irving|2013|p=42}} The quadratic formula covering all cases was first obtained by [[Simon Stevin]] in 1594.<ref>{{Citation |title=The Principal Works of Simon Stevin, Mathematics |volume=II-B |first1=D. J. |last1=Struik |first2=Simon |last2=Stevin |publisher=C. V. Swets & Zeitlinger |year=1958 |page=470 |url=http://www.dwc.knaw.nl/pub/bronnen/Simon_Stevin-%5bII_B%5d_The_Principal_Works_of_Simon_Stevin,_Mathematics.pdf}}</ref> In 1637 [[René Descartes]] published ''[[La Géométrie]]'' containing special cases of the quadratic formula in the form we know today.<ref>{{citation |url=http://archive.org/details/TheGeometry|title=The Geometry|last=Rene Descartes|language=en}}</ref> ==Geometric significance== In terms of coordinate geometry, an axis-aligned parabola is a curve whose {{tmath|(x, y)}}-coordinates are the [[graph of a function|graph]] of a second-degree polynomial, of the form {{tmath|1=\textstyle y = ax^2 + bx + c}}, where {{tmath|a}}, {{tmath|b}}, and {{tmath|c}} are real-valued constant coefficients with {{tmath|a \neq 0}}. Geometrically, the quadratic formula defines the points {{tmath|(x, 0)}} on the graph, where the parabola crosses the {{tmath|x}}-axis. Furthermore, it can be separated into two terms, <math display=block> x = \frac{-b\pm\sqrt{b^2 - 4ac }}{2a} = -\frac{b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a}. </math> The first term describes the [[axis of symmetry]], the line {{tmath|1= x = -\tfrac{b}{2a} }}. The second term, {{tmath|\textstyle \sqrt{b^2 - 4ac}\big/ 2a}}, gives the distance the roots are away from the axis of symmetry. If the parabola's vertex is on the {{tmath|x}}-axis, then the corresponding equation has a single repeated root on the line of symmetry, and this distance term is zero; algebraically, the discriminant {{tmath|1=\textstyle b^2 - 4ac = 0}}. If the discriminant is positive, then the vertex is not on the {{tmath|x}}-axis but the parabola opens in the direction of the {{tmath|x}}-axis, crossing it twice, so the corresponding equation has two real roots. If the discriminant is negative, then the parabola opens in the opposite direction, never crossing the {{tmath|x}}-axis, and the equation has no real roots; in this case the two complex-valued roots will be [[complex conjugate]]s whose real part is the {{tmath|x}} value of the axis of symmetry. ==Dimensional analysis== If the constants {{tmath|a}}, {{tmath|b}}, and/or {{tmath|c}} are not [[unitless]] then the quantities {{tmath|x}} and {{tmath|\tfrac ba}} must have the same units, because the terms {{tmath|\textstyle ax^2}} and {{tmath|bx}} agree on their units. By the same logic, the coefficient {{tmath|c}} must have the same units as {{tmath|\tfrac{b^2}{a} }}, irrespective of the units of {{tmath|x}}. This can be a powerful tool for verifying that a quadratic expression of [[physical quantities]] has been set up correctly. ==See also== * [[Fundamental theorem of algebra]] * [[Vieta's formulas]] == Notes == {{Reflist|30em}} == References == * {{citation |last=Smith |first=David Eugene |author-link=David Eugene Smith |title=History of Mathematics |volume=2 | year=1923 |place=Boston |publisher=Ginn |url=https://archive.org/details/historyofmathema0001davi/ }} * {{citation | last=Irving | first=Ron | title=Beyond the Quadratic Formula | url=https://books.google.com/books?id=CV_UInCRO38C | year=2013 | publisher=MAA | isbn=978-0-88385-783-0 }} {{Polynomials}} [[Category:Elementary algebra]] [[Category:Equations]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Citation
(
edit
)
Template:Cite magazine
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite thesis
(
edit
)
Template:Cite web
(
edit
)
Template:Confused
(
edit
)
Template:Details
(
edit
)
Template:Harvnb
(
edit
)
Template:MacTutor
(
edit
)
Template:Math
(
edit
)
Template:Mvar
(
edit
)
Template:Nobr
(
edit
)
Template:Pb
(
edit
)
Template:Polynomials
(
edit
)
Template:R
(
edit
)
Template:Reflist
(
edit
)
Template:Sfn
(
edit
)
Template:Short description
(
edit
)
Template:Slink
(
edit
)
Template:Tmath
(
edit
)
Template:Wbr
(
edit
)