Python Forum
looking for a math function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for a math function
#11
(Dec-06-2023, 02:07 PM)EdwardMatthew Wrote: Embrace the sqrt() function in math for calculating cube roots,

the above is what confused me in this thread, in addition to using imprecise representations of 1/3, which a correct implementation of .cbrt() would avoid, perhaps with the Newton-Raphson method as seen on YouTube here. what i might do is use the pow or log method to make the NR guess and run 2 or 3 fixed NR iterations to get a more accurate value. the guess could be spot-on in most cases, given finite floating point representation. but, if you use type Decimal.decimal or another extended precision type, you might need to do more NR iterations. you'll need to figure out how many to do or when to end (i would repeat until 2 or 3 stable iterations).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020