HP35S - Cubic (and incidentally quadratic) equations solver
|
04-10-2023, 02:21 PM
Post: #5
|
|||
|
|||
RE: HP35S - Cubic (and incidentally quadratic) equations solver
As usual we divide all coefficients of the original polynomial \(ax^3 + bx^2 + cx + d\) by \(a\), so we start with the following polynomial:
\( f(x) = x^3 + px^2 + qx + r \) Using Horner's method we can reuse the intermediate values \(x_0 + p \) and \(x_0(x_0 + p) + q\) while calculating the derivative: \( \begin{matrix} & 1 & p & q & r \\ x_0 & 1 & x_0 + p & x_0(x_0 + p) + q & x_0(x_0(x_0 + p) + q) + r = f(x_0) \\ x_0 & 1 & 2 x_0 + p & x_0(3 x_0 + 2 p) + q = f'(x_0) & \\ \end{matrix} \) This allows calculating the derivative and synthetic division in one step. Registers R00: \(p = \frac{b}{a}\) R01: \(q = \frac{c}{a}\) R02: \(r = \frac{d}{a}\) R03: \(x_0 + p\) R04: \(x_0(x_0 + p) + q\) HP-42S Code: 00 { 69-Byte Prgm } HP-15C Code: 001 { 42 21 13 } f LBL C Example \( x^3 - x^2 - x - 1 = 0 \) 1 ENTER -1 ENTER ENTER XEQ "CBRT" X: 1.83928675521 R/S Y: -0.41964 - i0.60629 X: -0.41964 + i0.60629 Caveat The value \(- \frac{r}{q}\) is used as initial value for Newton's iteration. This is the next guess when you start with \(0\). However, this might not always be the best value. I was a bit sloppy with the termination criterion. It may never be reached, but I've never experienced it. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)