How do you enter the command for a cube root?

1,014 ビュー (過去 30 日間)
Ricky Smith
Ricky Smith 2016 年 9 月 7 日
回答済み: Hamad Al-Mulla 2021 年 11 月 24 日
I'm re-working the volume of a sphere equation (V=(4*pi*r^3)/3) to solve for the radius(r).

採用された回答

John D'Errico
John D'Errico 2016 年 9 月 7 日
編集済み: John D'Errico 2016 年 9 月 7 日
Two simple options:
x^(1/3)
Or,
nthroot(x,3)
Be very careful though. If x is negative, it will return a complex number, because there are indeed THREE cube roots of a negative number. Two of them are complex. nthroot will give you the root you would expect however.
(-2)^(1/3)
ans =
0.62996 + 1.0911i
nthroot(-2,3)
ans =
-1.2599
In your case, it is not relevant, since the number will be non-negative.
  2 件のコメント
James Tursa
James Tursa 2018 年 11 月 7 日
編集済み: James Tursa 2018 年 11 月 7 日
"... there are indeed THREE cube roots of a negative number ..."
To complete John's thought, there are three distinct cube roots of every non-zero number (positive real, negative real, complex), not just of the negative real numbers. And as John points out, some of these roots are complex, so you need to know how the tools you are using behave in order to get the answer(s) you want. (In general, there are n distinct n'th roots of every non-zero real or complex number)
John D'Errico
John D'Errico 2020 年 11 月 17 日
Good completion/correction. My statement was sloppy as I wrote it.

サインインしてコメントする。

その他の回答 (2 件)

Andre Oliveira
Andre Oliveira 2018 年 11 月 7 日
nthroot(-2,3)

Hamad  Al-Mulla
Hamad Al-Mulla 2021 年 11 月 24 日
nthroot(10,3)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by