How to obtain all the solutions of quadratic equations with multiple variables?
6 views (last 30 days)
Show older comments
I am trying to solve quadratic equations with multiple variables. For example, I want to solve
a^2+b^2 = 1.25;
c^2+d^2 = 0.58;
a*c+b*d = 0.55;
a*d-b*c = 0.65;
The code I wrote is as follows.
>> syms a b c d
>> eqns = [a^2+b^2 == 1.25, c^2+d^2 == 0.58, a*c+b*d == 0.55, a*d-b*c == 0.65];
[sola,solb,solc,sold] = solve(eqns,[a b c d])
sola =
-(11*2^(1/2)*29^(1/2))/116
(11*2^(1/2)*29^(1/2))/116
solb =
(13*2^(1/2)*29^(1/2))/116
-(13*2^(1/2)*29^(1/2))/116
solc =
-(2^(1/2)*29^(1/2))/10
(2^(1/2)*29^(1/2))/10
sold =
0
0
Matlab provides two sets of solutions, but they are not all the sets of solutions. At least [1, -0.5, 0.7, 0.3] is another set of solution. Why Matlab doesn't provide all the solutions when using 'solve' function? How to obtain all the solution?
Can anyone help? Thanks in advance.
0 Comments
Accepted Answer
Bruno Luong
on 17 Oct 2018
Edited: Bruno Luong
on 17 Oct 2018
I have impression the 4 equations are not independent, and that might confuse MATLAB.
For any 2x2 rotation matrix
R = [cos(theta), -sin(theta);
sin(theta) cos(theta)}
I believe if (a,b,c,d) a solution, if I define
abp = R*[a;b];
cdp = R*[c;d];
then
(abp(1),abp(2),cdp(1),cdp(2))
is another solution for any theta not a multiple of 2*pi.
So actually there are an infinity of solutions. Of course MATLAB won't be able to list them. But pretending cardinal of all solutions is 2 is obviously very wrong.
And can also prove that any solution is rotated (as described above) from another.
4 Comments
Bruno Luong
on 18 Oct 2018
As I don't own SYMBOLIC TBx I can't help you to deal with MATLAB, but at least with some though. Thanks, glad to help.
More Answers (1)
madhan ravi
on 17 Oct 2018
As you can see you got all the solutions , each variable has two solutions. So I don’t see anything wrong in it.
15 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!