Arctangent function program [HP-42S, Free42]
|
09-17-2024, 04:32 PM
Post: #22
|
|||
|
|||
RE: Arctangent function program [HP-42S, Free42]
(09-17-2024 04:23 AM)Gerson W. Barbosa Wrote: Anyway, I’ve found out that [for tan(x)] more than 9 iterations are needed. It depends on domain. see https://demonstrations.wolfram.com/Conti...ntFunction If tan argument limited to ±pi/4, 8 iterations already have 16+ digits accuracy. Instead of getting CF result bottom-up, with fixed iterations, we can also do this top-down. see https://www.ams.org/journals/mcom/1952-0...9650-3.pdf, Method III Note: there is a typo in formula, it should be 1+p(i) = 1 / (1 + r(i)*(1+p(i-1))) This is why I use variable p1 = 1+p instead. Code: function my_tan(x) lua> my_tan(pi/4) 1 0.2032910765367568 0.9886892399342051 2 0.011098440980763355 0.9997876809149685 3 0.00021018750072653323 0.999997868415695 4 2.1181106602376684e-06 0.9999999865263552 5 1.341497025916972e-08 0.9999999999413255 6 5.84877225566155e-11 0.9999999999998133 7 1.8641515888296674e-13 0.9999999999999997 8 4.534798657058108e-16 1.0000000000000002 9 8.698065146274166e-19 1.0000000000000002 1.0000000000000002 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)