MATLAB Answers

Solving equation with four unknowns

10 views (last 30 days)
Tchilabalo
Tchilabalo on 31 May 2019
Commented: Star Strider on 31 May 2019
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

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 31 May 2019
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.

  2 Comments

Tchilabalo
Tchilabalo on 31 May 2019
Thanks Star for your prompt your response. I have tried to find the equations of x,y,z, and w as bellow. It definitely looks like we have multiple solutions. But since these are probabilities, i don't want negative numbers. I am wondering if there is a way to put constraint on the values of x,y,z, and w.
Thanks again!
0.5 + 0.3262096038214856734433746782838i
0.5 - 0.3262096038214856734433746782838i
>> S.y
ans =
1/2 - z2/2 - (2^(1/2)*(- 6755399441055744*z1^2 - 4503599627370496*z1*z2 + 4503599627370496*z1 - 6755399441055744*z2^2 + 4503599627370496*z2 - 958480442803811)^(1/2))/134217728 - z1/2
(2^(1/2)*(- 6755399441055744*z1^2 - 4503599627370496*z1*z2 + 4503599627370496*z1 - 6755399441055744*z2^2 + 4503599627370496*z2 - 958480442803811)^(1/2))/134217728 - z2/2 - z1/2 + 1/2
>> S.x
ans =
(2^(1/2)*(- 6755399441055744*z1^2 - 4503599627370496*z1*z2 + 4503599627370496*z1 - 6755399441055744*z2^2 + 4503599627370496*z2 - 958480442803811)^(1/2))/134217728 - z2/2 - z1/2 + 1/2
1/2 - z2/2 - (2^(1/2)*(- 6755399441055744*z1^2 - 4503599627370496*z1*z2 + 4503599627370496*z1 - 6755399441055744*z2^2 + 4503599627370496*z2 - 958480442803811)^(1/2))/134217728 - z1/2
>> S.z
ans =
z1
z1
>> S.w
ans =
z2
z2
Star Strider
Star Strider on 31 May 2019
As always, my pleasure.
The absolute values of both are the same, that being: 0.568527312187693, so they fit within your constraints in that respect. You are solving two equations in four unknowns, so only two unknowns will have nonzero values.
If you want only real results, you can declare:
syms x y w z real
or:
syms x y w z z1 z2 real
however the result are empty solutions.
Perhaps if you post a new Question specifically describing your problem and the probabilities you want to estimate, and in those terms, you can resolve this. I doubt that it’s possible to go further here.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by