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

1 visualizzazione (ultimi 30 giorni)
Apurbo Roy Chowdhury
Apurbo Roy Chowdhury il 22 Ago 2021
(-3)^(1/3)
ans = 0.7211 + 1.2490i
I need the ans: -1.44224957.

Risposte (2)

Steven Lord
Steven Lord il 22 Ago 2021
You can use the nthroot function.
y = nthroot(-3, 3)
y = -1.4422
  2 Commenti
Walter Roberson
Walter Roberson il 22 Ago 2021
... I went looking for that, as I thought I remembered it existing. It is not mentioned in the documentation for power() or realroot() .

Accedi per commentare.


Walter Roberson
Walter Roberson il 22 Ago 2021
format long g
syms x
solve(x^3==-3 & imag(x) == 0)
ans = 
double(ans)
ans =
-1.44224957030741
  3 Commenti
Wan Ji
Wan Ji il 22 Ago 2021
Modificato: Wan Ji il 22 Ago 2021
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))

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by