How to get only real output from (-3)^(1/3)

4 ビュー (過去 30 日間)
Apurbo Roy Chowdhury
Apurbo Roy Chowdhury 2021 年 8 月 22 日
(-3)^(1/3)
ans = 0.7211 + 1.2490i
I need the ans: -1.44224957.

回答 (2 件)

Steven Lord
Steven Lord 2021 年 8 月 22 日
You can use the nthroot function.
y = nthroot(-3, 3)
y = -1.4422
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 22 日
... I went looking for that, as I thought I remembered it existing. It is not mentioned in the documentation for power() or realroot() .
Apurbo Roy Chowdhury
Apurbo Roy Chowdhury 2021 年 8 月 23 日
nthroot worked, thanks.

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


Walter Roberson
Walter Roberson 2021 年 8 月 22 日
format long g
syms x
solve(x^3==-3 & imag(x) == 0)
ans = 
double(ans)
ans =
-1.44224957030741
  3 件のコメント
Wan Ji
Wan Ji 2021 年 8 月 22 日
編集済み: Wan Ji 2021 年 8 月 22 日
solve it with real syms
syms x real; % add real to make sure it is real
% following is what you want to
g(x) = ...;
x = solve(g(x)==x^(1/3))
Apurbo Roy Chowdhury
Apurbo Roy Chowdhury 2021 年 8 月 23 日
It shows x=0.

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

カテゴリ

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