MATLAB: How do i calculate these 3 unknows in these Equations

equations and unknown numbersSymbolic Math Toolbox

a^2 + b^2 + a.b = x^2,
b^2 + c^2 + b.c = y^2
c^2 + a^2 + a.c = z^2,
I need to get a,b,c from given x y z values in these Equations.
I will be going to use different values of x y z and i want to change from those values time to time and i want to get a b c according to those values

Best Answer

Easy enough.
syms a b c x y z
EQ(1) = a^2 + b^2 + a*b == x^2;
EQ(2) = b^2 + c^2 + b*c == y^2;
EQ(3) = a^2 + c^2 + a*c == z^2;
abc = solve(EQ,a,b,c)
abc =
struct with fields:
a: [4×1 sym]
b: [4×1 sym]
c: [4×1 sym]
So 4 distinct solutions to this quadratic system. They are highly complex, but who cares? One big reason we use computers is to alleviate this very problem.
subs(abc.a,[x,y,z],[1 2 3])
ans =
(3*7^(1/2))/7
(3*7^(1/2))/7
-(3*7^(1/2))/7
-(3*7^(1/2))/7
subs(abc.b,[x,y,z],[1 2 3])
ans =
-(2*7^(1/2))/7
-(2*7^(1/2))/7
(2*7^(1/2))/7
(2*7^(1/2))/7
subs(abc.c,[x,y,z],[1 2 3])
ans =
(6*7^(1/2))/7
(6*7^(1/2))/7
-(6*7^(1/2))/7
-(6*7^(1/2))/7
Pick the solution that makes you happy.