Are there any programs (or built-in methods I'm overlooking) for the 35s to find the roots of equations higher than second order?
Thank you.
35s - find roots of 3rd and higher order equations
|
|
« Next Oldest | Next Newest »
|
▼
02-19-2012, 08:42 PM
Are there any programs (or built-in methods I'm overlooking) for the 35s to find the roots of equations higher than second order? Thank you. ▼
02-20-2012, 04:10 AM
Quote: Sure. Have a look at this article of mine, it features a short program for the HP35s (plus assorted examples) which will allow you to find any roots, real or complex, of most any equation, polynomial or not: HP35s - Going back to the roots
Best regards from V. ▼
02-20-2012, 07:01 PM
Nice one, thanks Valentin :-)
02-20-2012, 07:45 PM
Valentín, Is there a reference for the algorithm on which you based this superb program? I'd like to start there, rather than reverse-engineer your program. Thanks! ▼
02-20-2012, 09:00 PM
How about a 34s port for inclusion as an internal complex solve command? :-)
▼
02-21-2012, 06:16 AM
It is in the library now :-) Not sure if I ported it over completely properly or not but it handles the first example from the PDF article okay.
02-21-2012, 08:06 PM
In order to analyze Valentin's program I've translated it to Python while trying to keep it as close to the original as possible. You will find the whole program at the end. The examples are added as well. Let me go through it step by step.
First we need the definition of some constants: Z = 1 + 0j
Now we use the function: U = F(X) / Y This leaves us with: U = 2F(X)
For the next step some approximations are used:
V, W = (W + V - U) / T, Y * (V - W) / S
So we end up with:
Next step is to divide F"(X) by F'(X):
V /= W Now we have: V ~ F"(X)/F'(X)
Since I don't have a stack I use a variable D which is not used in Valentin's program: D = ( (Z - V * U / W) ** Y - Z ) / V This gives the following expression:
Compare this with the 2nd formula in Halley-Verfahren but don't ask me why it's missing in the English version:
To see that both formulas are equivalent use the following abbreviations:
The trick is to use the binomial theorem (a + b)(a - b) = a2 - b2:
Kind regards
from math import pi, copysign ▼
02-21-2012, 08:53 PM
This is so cool, it deserves its own permanent article.
02-21-2012, 09:31 PM
Thomas, It'll take me some time to work through your analysis of Valentin's program, but I must thank you now; I'm very grateful for the effort you've gone to, and I hope I can do it justice by understanding it well enough to write an RPL program (for 48G or 50g) that will do all that the 35S program does. Many thanks! ▼
02-21-2012, 10:14 PM
Meanwhile I found another reference: Let me know if something is not clear in my analysis and please post your RPL program.
Cheers
▼
02-22-2012, 06:31 PM
The numerical analysis Halley’s method is a root-finding algorithm used for functions of one variable with a continuous second derivative.
Where f is the function were are investigating for roots.
Posing Hal(x)= 2.F(x)*F’(x) / ( 2 * [F’(x)]^2 – F(x).F(“(x)) )
In RPL, the code to follow such an iterative method will be as simple as the following: « (1,0) * @ Converting x0 into complex z0 In RPL, invoking R.Halley may return the closest root from the inputted initial. It is quite like the LBL A program on HP-35C. Nut this will be true only if the user function Hal is the appropriate one. From the above formula, one may calculate the Hal function from any given secondly derivative continuous function and input it in the RPL calculator.
In RPL, a general formulae of the Hal user’function may be : « -> xWhere F(x), dF(x) and d2F(x) stand respectively for function, first derivate and second derivate of the function under investigation.
One major advantage of RPL is that they all are able to formally derivate any given function.
One way is to use one initialization program of the form : « DUP ->STRU @ copy ‘x’ as unquote string “x”
The user have to enter formal definition of the function/expression to investigate in level 2: and the name of the variable to scan in level 1:. Then pressing INIT will built up first and second derivate and create a soft menu with dedicated key. Examples:
To solve xx=PI : >> x x ^ PI – x INIT (takes a few secondes on an HP-28S)The soft key can easily be use to check results or to show formulae : >> x [ dF ] returns ‘x^x+LN(x)*x^x’And >> 'dF' RCL return « -> x 'x^x+LN(x)*x^x' »
>> 'x*x*x-3*x*x+4*x-2' COLCT x [INIT] 0 [R.HALL] (2,3) [R.HALL] (2,3)[CHS] [R.HALL] 5 FIX
>> 'X^3-(1,10)*X*X-(33,-6)*X+(5,-40)' COLCT X [INIT] 1 [R.HALL] (1,1) [R.HALL] (0,1)[CHS] [R.HALL]
Edited: 22 Feb 2012, 6:48 p.m. ▼
02-25-2012, 02:55 PM
%%HP: T(3)A(D)F(.); However I encountered a problem when I tried to solve Valentin's 4th problem:
Quote: When I use the same intital values I always get the same result for 1 as well as for -6:
>> 'x^3+2*x^2+10*x-20' x [INIT ] It is obvious that from real initial values you will never get complex roots. That's the benefit of using Halley's Irrational Formula because a square root is used. But thanks to your clever design all I had to do was to replace the program Hal. In your version of Hal both functions F(x) and dF(x) are called twice with the same value. That's why I save the result of the function calls in local variables u and v (well not exactly that, but their quotients):
Hal With this program I get the same results as with the HP-35S:
>> 1 [R.HAL] -6 [R.HAL] Thanks for posting your program: I've learned a lot from the ideas of your INIT routine. Very nice!
Kind regards |