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

조회 수: 3 (최근 30일)
Apurbo Roy Chowdhury
Apurbo Roy Chowdhury 2021년 8월 22일
댓글: Apurbo Roy Chowdhury 2021년 8월 23일
(-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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by