HP-11C/15C Code optimization
|
10-26-2024, 10:24 PM
(This post was last modified: 10-26-2024 10:59 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: HP-11C/15C Code optimization
Hi, jam
It may be simpler to solve Colebrook with lambertw function. x = -2 * log10(a*x + b) // {a,b} switched to match https://en.wikipedia.org/wiki/Darcy_fric...r_formulae let y = a*x+b, k = 2a/ln(10) (y-b)/a = -k/a * ln(y) y + k*ln(y) = b --> y = k * W(z) , where z = e^(b/k)/k OP example lua> a = 2.51/126400 lua> b = 4.2e-5/3.7 lua> k = 2*a/log(10) lua> z = exp(b/k)/k lua> z -- guess for exp(W(z)) 111963.8779391653 lua> (_ + z) / (log(_) + 1) 17735.543271562103 lua> (_ + z) / (log(_) + 1) 12027.775216761022 lua> (_ + z) / (log(_) + 1) 11928.038961742051 lua> (_ + z) / (log(_) + 1) 11927.999039108403 lua> (_ + z) / (log(_) + 1) -- = exp(W(z)) 11927.99903910197 lua> z / _ -- = W(z) 9.386643775886386 lua> (k*_ - b)/a -- = x 7.5814974176865215 Or, slightly more complicated Newton setup, straight for W(z) lua> log(z) -- guess for W(z) 11.625931579856678 lua> _ - (_ + log(_/z)) / (1+1/_) 9.366995046326272 lua> _ - (_ + log(_/z)) / (1+1/_) 9.386641790802015 lua> _ - (_ + log(_/z)) / (1+1/_) 9.386643775886366 lua> _ - (_ + log(_/z)) / (1+1/_) 9.386643775886386 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
HP-11C/15C Code optimization - jam - 10-26-2024, 03:14 PM
RE: HP-11C/15C Code optimization - Thomas Klemm - 10-26-2024, 08:04 PM
RE: HP-11C/15C Code optimization - jam - 10-26-2024, 08:56 PM
RE: HP-11C/15C Code optimization - naddy - 10-26-2024, 09:22 PM
RE: HP-11C/15C Code optimization - jam - 10-27-2024, 12:21 AM
RE: HP-11C/15C Code optimization - Albert Chan - 10-26-2024 10:24 PM
RE: HP-11C/15C Code optimization - jam - 10-27-2024, 12:28 AM
|
User(s) browsing this thread: 1 Guest(s)