MATLAB: Solving equation with four unknowns

vpasolve

clear all
aa=1.5;
m=(0.5)^(aa);
syms x y w z
S=vpasolve([x^2+y^2+z^2+w^2==m, x+y+z+w==1],[x y z w],[0 1],'Random',true)
S =
struct with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
w: [1×1 sym]
>> S.x
ans =
0.5 + 0.27059805007309849219986160268319i
>> S.y
ans =
0.5 - 0.27059805007309849219986160268319i
>> S.z
ans =
0
>> S.w
ans =
0
>>
I am trying to find four probalities (x,y, z, and w) such that:
x^2+y^2+z^2+w^2==m, and x+y+z+w==1; where m is a constant. I wrote the code as above, but because i specified the range of probabilities to [0 1], i get yhe following message: "Incompatible starting points and variables". When i remove the range, then i get unique solutions like above. But i feel there should be more that one solution to such an equation. I will appreciate any help.
Thanks

Best Answer

You need to explore the solutions in detail:
aa=1.5;
m=(0.5)^(aa);
syms x y w z z1 z2
S=solve([x^2+y^2+z^2+w^2==m, x+y+z+w==1],[x y z w],'ReturnConditions',true)
X = solve(S.x,[z1,z2]);
Roots = vpa(X.z1)
produces:
Roots =
0.5 + 0.27059805007309849219986160268319i
0.5 - 0.27059805007309849219986160268319i
These are ‘z1’ and ‘z2’, the two roots of your equation.