Posts: 4,655
Threads: 1,498
Joined: Sep 2016
there is "sqrt()" in math. is there a function to calculate cube roots?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,655
Threads: 1,498
Joined: Sep 2016
(Dec-06-2023, 02:07 PM)EdwardMatthew Wrote: Embrace the sqrt() function in math for calculating cube roots, breaking free from the square-root norm. Just as languages vary, transcend the linguistic stereotype by celebrating your unique multilingual flair!
what are you talking about? i there a way to accurately, precisely, and efficiently, get the cube root by calling only sqrt()?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,655
Threads: 1,498
Joined: Sep 2016
... as previously mentioned by
deanhystad in
message #2
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,655
Threads: 1,498
Joined: Sep 2016
the other ways to calculate roots tend to be less accurate when powers involved (such as 1/3) cannot be represented exactly. maybe someone can develop a
math.powroot()
function.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,804
Threads: 77
Joined: Jan 2018
Dec-08-2023, 08:54 AM
(This post was last modified: Dec-08-2023, 08:54 AM by Gribouillis.)
(Dec-07-2023, 06:41 PM)buran Wrote: There is math.cbrt(x) - Return the cube root of x.
If I understand well, the problem with
**(1/3)
is for negative real numbers. Instead of returning the negative real cubic root, it return the principal complex cubic root
>>> (-1)**(1/3)
(0.5000000000000001+0.8660254037844386j)
>>>
Before 3.11 one can also use
numpy.cbrt()
>>> numpy.cbrt(-1)
-1.0
>>>
There is also a rounding issue
>>> 64**(1/3)
3.9999999999999996
>>> numpy.cbrt(64)
4.0
>>>
« We can solve any problem by introducing an extra level of indirection »