Solving equation with four unknowns
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2019 年 5 月 31 日
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 件のコメント
Star Strider
2019 年 5 月 31 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!