Lambert W Function (hp-42s)
|
10-03-2020, 04:31 PM
(This post was last modified: 12-30-2022 10:41 PM by Albert Chan.)
Post: #41
|
|||
|
|||
RE: Lambert W Function (hp-42s)
We were testing special case x = -r = -1/e
I was curious, is it the same as guess(x) = -x ? guess(x) = r + 0.3*(x+r) + √(2r*(x+r)) = -x → √(2r*(x+r)) = -1.3*(x+r) Let z = x+r, we have √(2/e*z) = -1.3*z → z = 0 → x = -r With this, we can simplify the code greatly, moving the test after guess(x). And, turning repeat until loop into while do loop, remove the test altogether ! Bonus: now it checked both special case, x = -1/e, -1/e + 0j Code: 00 { 56-Byte Prgm } UPDATE: There is a flaw in termination test. I keep this for historical record. Please use corrected version |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)