Asked by xueqi
on 6 Jan 2013

Hi,

I am using the code below so solve function

syms x solve(1-x-x^0.3 == 0,x)

and MATLAB gives me the answer

2.2806043918081745336771958436901 0.301860807970099685692066514691 0.29115437161383716945904165867324 + 0.29287833041472217013239499780749*i 0.42827262660009503368869244743538 - 0.77711337147723605404039493650918*i 0.42827262660009503368869244743538 + 0.77711337147723605404039493650918*i 1.9090820154790144088601993088112 - 0.85475656146972727566334457636303*i 0.29115437161383716945904165867324 - 0.29287833041472217013239499780749*i 1.0802583864179162783074354058896 + 1.1426229105821451060150636481001*i 1.9090820154790144088601993088112 + 0.85475656146972727566334457636303*i 1.0802583864179162783074354058896 - 1.1426229105821451060150636481001*i

Clearly matlab sovle this problem numerically. The problem is that I find the first answer is wrong since I type

1-2.2806043918081745336771958436901-2.2806043918081745336771958436901^0.3

in the command code and get the result is

ans =

-2.5612

This is really bizzar! Is there anyone could tell me why? Really appreciated!

*No products are associated with this question.*

Answer by Roger Stafford
on 6 Jan 2013

That first answer is not as wrong (or bizarre) as you might think. When you present 'solve' with fractional powers you must expect some unusual behavior. In the case of that first value, 2.28060439...., if you interpret its 0.3 power as the cube of its tenth root, one of those tenth roots is -1.085937913... whose cube is -1.280604392... and that will satisfy your equation.

In order to achieve a solution to your original equation, very likely 'solve' converted your problem to the polynomial equation 1 - y^10 - y^3 = 0 with the substitution y = x^(1/10) and got ten y roots. Then it took each of these to the tenth power to obtain the x values and those ten values you received are the result. You can check that by giving that equation in y to 'solve' and then taking each solution to the tenth power.

xueqi
on 8 Jan 2013

Walter Roberson
on 8 Jan 2013

Yes: do not use floating point exponents when you solve(); it is just going to confuse you and confuse the readers.

When x and a are specific floating point numbers, x^a is calculated as exp(ln(x)*a) . When x is negative and a is real, then this produces a complex-valued result.

When you use symbolic forms, x symbolic and a real, then unless you are careful about what you are doing, then for x^a, the a is converted to the rational fraction in lowest terms, c/d, leading to x^(c/d) . (c, d integer). This is then calculated algebraically (x^c)/(x^d) which is going to come out real-valued for negative x if "c" is even, a distinctly different value than if x^a had been calculated numerically.

You need to decide which of the several possible meanings you want for x^a when a is floating point.

Roger Stafford
on 8 Jan 2013

Log in to comment.

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments

Log in to comment.