Collaborative collection of useful userRPL snippets
|
01-13-2019, 09:39 AM
Post: #20
|
|||
|
|||
RE: Collaborative collection of useful userRPL snippets
(01-12-2019 09:43 PM)cdmackay Wrote: please consider this snippet, for an arbitrary base logarithm: I'd guess that LOG uses LN internally, so to make it just that little bit more accurate and faster I'd probably use: Code: \<< LN SWAP LN / \>> The CORDIC algorithms that I know get you the natural logarithm of a number, not the decimal logarithm. Internally, the machine probably calculates \( \frac {ln(x)} {ln(10)} \) with \( ln(10) \) stored as a constant in ROM. At least that's how my floating point library does it To use this as a programmable function in its own right then use local variables: Code: \<< \-> b x \<< x LN b LN / \>> \>> Store it as "LOGBX" and you can invoke it as LOGBX(2,8) for example, which should return 3. Need to analyse the function at some point? Make it an algebraic: Code: \<< \-> b x 'LN(x)/LN(b)' \>> If you now want to derive that function, you can (on a 48GX): Code: 'LOGBX(B,X)' 'X' ∂ That gets you: Code: '1/X/LN(B)' |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)