Solving equation with four unknowns
7 次查看(过去 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!