Solve the real quadratic equation \(c2bz+az^2=0\) for real or complex roots.

09232014, 12:05 AM
Post: #1




Solve the real quadratic equation \(c2bz+az^2=0\) for real or complex roots.
Abstract
This article refers to "Example 6: The Smaller Root of a Quadratic" in the "Advanced Functions Handbook" for the HP15C (p. 191). It attempts to explain how the \(\Sigma\) key can be used to guarantee nine correct significant digits on a 10digit calculator. It is recommended that you are familiar with both programs "A" and "B" that can be found in "Example 6 Continued" (pp.205). Both programs "A" and "B" are also attached to this article as listing and statefile for the Nonpareil emulator. How to avoid destruction cancellation There are two cases during the calculation of the solutions where cancellation may happen. One is when a solution is close to 0. This can be avoided by calculating the root with the bigger absolute value first and then use Viëta's formula \(x_1\cdot x_2=\frac{c}{a}\) to calculate the 2nd solution. Quote:The method uses \(d=b^2a\cdot c\). However there's another problem when calculating \(d=b^2a\cdot c\). We may encounter cancellation when \(b^2\) and \(a\cdot c\) are close. Quote:The program exploits a tricky property of the \(\Sigma\) and \(\Sigma+\) keys whereby certain calculations can be carried out to 13 signficant digits before rounded back to 10. How to calculate \(b^2  a \cdot c\) with \(\Sigma xy\) Let's have a look at the back label of the HP15C: R₂: \(n\) R₃: \(\Sigma x\) R₄: \(\Sigma x^2\) R₅: \(\Sigma y\) R₆: \(\Sigma y^2\) R₇: \(\Sigma xy\) This code snipet is from program "B": Code: 047  45 8 RCL 8 ; b Example a = 11713 b = 735246 c = 46152709 Code: b² = 735246² = 540586680516 ≈ 5.405866805⋅10¹¹ When using the \(\Sigma\) key the subtraction is executed with 13 digits. But keep in mind that we can store only 10 significant digits of b²: Code: 735246 The result is 17 as we're calculating: Code:
Transformation of the coordinate system using Horner's method We want to shift the coordinate system so that \(x_0\) becomes the new origin. Horner's method can be used to calculate the coefficients of the polynomial in the new coordinates: \[ \begin{matrix} & a & 2b & c \\ x_0: & a & a\cdot x_02b & (a\cdot x_02b)\cdot x_0 + c \\ x_0: & a & 2a\cdot x_02b & \\ x_0: & a & & \\ \end{matrix} \] Now we can calculate the coefficients a', b' and c' of the quadratic polynomial in the new coordinates: \[ \begin{align} a' & = a \\ 2b' & = 2a\cdot x_02b \\ b' & = b  a\cdot x_0 \\ c' & = (a\cdot x_02b)\cdot x_0 + c \\ & = c b\cdot x_0 (b a\cdot x_0)\cdot x_0 \\ & = c b\cdot x_0 b'\cdot x_0 \\ \end{align} \] It turnes out that all the operations are of the form: \(u  v\cdot x_0\) We want to shift the coordinate system so that b' becomes 0: \[ \begin{align} b' & =ba\cdot x_0 = 0 \\ x_0 & =\frac{b}{a} \\ \end{align} \] But in doing so we may encounter cancellation. To avoid it we use only the first 3 significant digits of \(x_0\). This is done by using the rounding function RND with the scientific display SCI 2. Together with the 10 digits of the other multiplicand this ensures that we are within the limits of 13 internal digits. Using Σ avoids rounding the product to 10 digits before the subtraction is executed. Thus we shift the coordinate system multiple times in steps of 3 digits. When we finally reach \(b=0\) the calculation becomes: \(d=a\cdot c\) This is the section of program "B" where the coefficients of the polynomial in the new coordinates are calculated: Code: 012  45 8 RCL 8 ; b The rest of program "B" (lines 045082) is similar to how the roots are calculated in program "A". I hope that with this article I could shed some light on how the "Cadillac" Quadratic Solver works under the hood. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)