Lambert W Function (hp-42s)
|
10-01-2020, 12:33 PM
(This post was last modified: 10-01-2020 01:06 PM by Albert Chan.)
Post: #33
|
|||
|
|||
RE: Lambert W Function (hp-42s)
(10-01-2020 09:37 AM)Werner Wrote: nitpicking: it won't recognize (-1/e,0). I don't like testing special cases, if I can avoid it. Better approach is to not returning guess y0 = 1/e, even if x ≈ -1/e One way is to take advantage of calculator internal extra precision of PI (lets call it π) Free42: [PI] [SIN] → -1.158028306006248941790250554076922e-34 SIN(PI) = SIN(π - PI) ≈ π - PI Instead of adding an ε to 1/e, we get more bang for the buck if ε added to (x+1/e) Thus, another approach is to remove testing x = -1/e altogether, replacing Line 1 to 11 to this: Code: 01▸LBL "eW" To have guess returning r = 1/e, we need: y0 = r + √(2r*(x+r+ε)) + 0.3 (x+r+ε) = r → √(x+r+ε) [ √(2r) + 0.3 √(x+r+ε) ] = 0 → √(x+r+ε) = 0 or (-√(2r)/0.3 ≈ -2.859213) When (x+r) approaching -ε, (x+r) will suffer massive cancellations, thus x+r+ε ≠ 0 √(x+r+ε) > 0 or gone complex. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)