Small challenge
|
04-28-2023, 08:37 PM
Post: #38
|
|||
|
|||
RE: Small challenge
(04-24-2023 01:07 PM)Albert Chan Wrote:(04-23-2023 11:10 AM)robve Wrote: It is common to find exponentiation by squaring for integer powers, which tends to be more accurate than repeated multiplication and log*exp closed forms. Yes and no. I should have provided more context. You're right that simulating exponentiation by squaring in BASIC, C or Lua or other PL may produce rounding errors (and less accurate results compared to exp-log) if guard digits are rounded away. However, calculators since the mid 70s use one or more guard digits. It is perfectly safe to use this method with small integer powers \( n \) to speed up \( x^n \) since we can perform multiplications with guard digits. I would not be surprised if some HP calculators use exponentiation by squaring if there is enough ROM space to add the necessary logic. But I'm not an expert on the history of HP math internals and so I can't tell. As for exp-log in IEEE-754, library implementations are free to use extra guard digits. Or use higher precision floats, see e.g. Elementary Functions - Algorithms and Implementation. We can do that too, when computing \( x^n \) with squaring. With IEEE-754 representations without guard digits, the method is indeed less effective. It depends on the mantissa value of \( x \) if we can avoid rounding completely, given a small integer power \( n \). If all else fails, we can place an upper bound on the final error to bound integer powers within an acceptable range. - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)