Solving a system of equations with dependent variables symbolically
11 views (last 30 days)
Show older comments
I have got 4 equations defined symbolically
y = a*b -c
z = d*a+b
x = c*a+b
s = c*b-a
The unknowns are {a, b, c ,d} and they are all real.
I have got difficulties to write the system of equations with implicit variables in matrix form.
What would be the best method to solve the set of equations above, please? I have thought about substitution, but it is challenging.
Does matlab have already programmed functions in MuPad to solve such a system, please?
0 Comments
Accepted Answer
Askic V
on 26 Feb 2023
syms a b c d x z y s
sol = solve([y==a*b-c,z==d*a+b,x==c*a+b,s==c*b-a],[a,b,c,d],'Real',true)
sol.a, sol.b,sol.c, sol.d
11 Comments
Walter Roberson
on 26 Feb 2023
syms a b c d e f g
syms x y z w u v s
syms cte1 cte2
eqns = [x == a *cte1 - e * c, y == - (b * e) / cte2, z == (a * g) / cte2, w == d * g - b * f, u == (a * e) / cte2, v == cte1 * b + e * d, s == a * f + c * g];
a_partial = solve(eqns(1), a)
eqns2 = subs(eqns(2:end), a, a_partial);
b_partial = solve(eqns2(1), b)
eqns3 = subs(eqns2(2:end), b, b_partial);
c_partial = solve(eqns3(end), c)
eqns4 = subs(eqns3(1:end-1), c, c_partial);
d_partial = solve(eqns4(end), d)
eqns5 = subs(eqns4(1:end-1), d, d_partial);
e_partial = solve(eqns5(end), e)
eqns6 = subs(eqns5(1:end-1), e, e_partial); %now has two rows because two e solutions
f_partial_a_sol = solve(eqns6(1,1), f, 'returnconditions', true)
f_partial_a = f_partial_a_sol.f
f_partial_a_sol.conditions
f_partial_b_sol = solve(eqns6(2,1), f, 'returnconditions', true)
f_partial_b = f_partial_b_sol.f
f_partial_b_sol.conditions
eqns7_a = subs(eqns6(1,2:end), f, f_partial_a)
eqns7_b = subs(eqns6(2,2:end), f, f_partial_b)
g_partial_aa = solve(eqns7_a(1,1), g)
g_partial_ab = solve(eqns7_a(2,1), g)
g_partial_ba = solve(eqns7_b(1,1), g)
g_partial_bb = solve(eqns7_b(2,1), g)
You can now back-substitute the four different branches -- each f has two branches and each of those leads to two different g.
After you get all the way back to a, b, c, d, e, f, g coefficients, you might want to try to prove that all of the outputs are real-valued. That might be a bit tricky, especially without knowing the signs of x y z w u v s cte1 cet2 .
You could possibly cut several steps off of the process by solving eqns([1 2 end-2:end]) for [a b c d e] in one step and then go after f and g.
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!