Symbolic expressions: abs(x^(1/3)) =?= abs(x)^(1/3)

6 ビュー (過去 30 日間)
Thomas
Thomas 2013 年 4 月 17 日
I have Matlab 2011b and when i do this:
>> x = sym('x')
x =
x
>> abs(x^(1/3))
ans =
abs(x)^(1/3)
then Matlab swaps the abs() and the ^(1/3).
Someone please correct me, but I would assume that x^(1/3) has three solutions, one real and two complex ones. (like here: http://en.wikipedia.org/wiki/Cubic_root#Real_numbers)
So putting the abs() around the root should yield exaxtly the one real(non-complex) solution (with multiplicity 3 if you want), because the magnitude of all three real and complex solutions should be identical.
However, by swapping abs() and the root to abs(x)^(1/3) i still get three solutions (one real, two complex again).
So where is my error or is it a bug?
Btw, if x is a lengthy expression itself it is annoying that i cannot make matlab evaluate this in the real numbers by putting an abs() around the root...
  1 件のコメント
Thomas
Thomas 2013 年 4 月 18 日
Anyone?

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

回答 (2 件)

the cyclist
the cyclist 2013 年 4 月 18 日
I think you do have an error in thinking about this, but it is a subtle one.
First, and I think this is the important part, the expression
>> fx1 = abs(x).^(1/3);
and the expression
>> fx2 = abs(x.^(1/3));
are equal for all values of x. Agreed?
Note that there is nothing about root-finding of a function here. Those are just two expressions. x.^(1/3) does not have any "solutions". There is no equation there!
If you want to find roots before you do the absolute value, then do the root-finding on the equation first [x.^(1/3) - 1 == 0, or whatever], then do the absolute value.
Does that make sense?
  3 件のコメント
bym
bym 2013 年 4 月 18 日
maybe you can start off by declaring your variables to be real e.g.
syms x y z real
Thomas
Thomas 2013 年 4 月 19 日
Thanks for the idea. I already did this, however it does not solve the problem, since result is still complex.

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


Ahmed A. Selman
Ahmed A. Selman 2013 年 4 月 19 日
編集済み: Ahmed A. Selman 2013 年 4 月 19 日
Some times we get confused between mathematics and programming, it is an often thing. Yet, mathematics means logic, programs try to reason that logic with numbers to us. So in mathematics, there's no difference between:
abs(-2^(1/3)) = 1.2599
(abs(-2)) ^(1/3) = 1.2599
assuming that the function abs is meaningless for positive real arguments. Now, let's elaborate more:
y= (-2)^(1/3)
y= 0.6300 + 1.0911i
no matter how many times I tried that with Matlab it gives the same, i.e., no random numbers here. One more thing:
abs(y)= 1.2599
The same as above!
Would Matlab be having a problem if it said so? I don't think that.
However, if you tried, e.g.,
syms x z
y=abs(x^z)
y=
abs(x^z)
leaving mathematical possibilities for any values of z to be reasonably usable.
  1 件のコメント
Thomas
Thomas 2013 年 4 月 19 日
Take a look at:
  • (8)^(1/3) ----> 2 (good)
  • (-8)^(1/3) ----> 1.0000 + 1.7321i (would like -2 more as an answer...)
So i can use
  • nthroot(-8,3) ----> -2 (better now)
However, nthroot doesn't work for symbolic expressions. But as i have seen now, matlab 2013 offers a function "surd" that seems to do what i need - unfortunately i don't have M2013 yet...

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

Community Treasure Hunt

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

Start Hunting!

Translated by