How do i calculate these 3 unknows in these Equations
1 view (last 30 days)
Show older comments
MUHAMMED AKBULUT
on 21 Jan 2020
Commented: MUHAMMED AKBULUT
on 22 Jan 2020
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
0 Comments
Accepted Answer
John D'Errico
on 21 Jan 2020
Edited: John D'Errico
on 21 Jan 2020
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.
3 Comments
John D'Errico
on 22 Jan 2020
Well you don't actually show what you did. You just showed the error message, and only part of it.
I showed the exact code that solves your problem, when run in MATLAB. That is, if you have the symbolic toolbox installed, for a current release. I cannot say what will happen if you do something else, or if you do not understand how to use MATLAB. I think the latter problem is where you are.
My guess is that you actually tried to execute the code that you saw. But the file that you are executing has the line:
abc=
in it.
I think that perhaps you don't understand that that was the OUTPUT from the solve statement.
Again, IF you execute the following lines:
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)
then you will get the result that you wish to see. That result will be the variable abc.
More Answers (0)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!