You have 4 equations, but effectively 9 unknowns.
syms R_1 positive
syms L_1 positive
syms C_1 positive
syms R_2 positive
syms L_2 positive
syms C_2 positive
syms a_1 positive
syms a_2 positive
syms b_1 positive
eqns(1) = -1/(C_2*L_2) == -a_2/(C_1*L_1*a_1);
eqns(2) = -R_2/L_2 == -R_1/L_1;
eqns(3) = 1/(C_2*L_2) == a_2/(C_1*L_1*b_1);
eqns(4) = 1 == a_1/a_2;
That you claim a_1 and a_2 not to be variables, you still have an equation that relates their values. Just because you don't really care what values they take on, does not make them any less of an unknown.
Should you simplify the problem by removing a_2 from the problem, since as you say, they must always be equal to each other? Yes. That is never a bad thing. Making a symbolic system more complicated than it needs to be is usually a bad idea. At some point you could get an unpleasant surprise.
Next, you effectively have a LINEAR problem in the unknowns, with 9 unknowns and 4 equations. It is linear, in the sense that IF you took the log of each equation, you would be left with a linear system of equations. In fact, it would be a homogeneous linear system in that logged form if all 9 variables were treated as unknowns, so the constant term in every equation would be zero.
Such a linear system, since it is under-determined (thus more variables than equations) has infinitely many solutions. There is no unique solution. Yet you are asking solve to find "the" solution. One of those solutions has each variable equal to 0 (in the logged form), therefore each variable in your original system would be unity. But solve does not know which solution you wish to find. So it returns no solution.
Suppose instead, you asked solve to find the set of solutions, picking some intelligent subset of exactly 4 those unknowns? Solve could now do so in theory. Let me try and sneak up on it:
sol = solve(eqns(4),[a_1])
sol =
a_2
So solve has no problem here.
sol = solve(eqns(2:4),[a_1,L_1,R_1])
sol =
struct with fields:
a_1: [1×1 sym]
L_1: [1×1 sym]
R_1: [1×1 sym]
That worked - solving a set of 3 equations in three unknowns. In fact, if we logged those equations, 6 of the 9 unknowns could now be thought of as part of the right hand side, thus not really unknowns, but simply parameters with unknown values. As such, the problem is no longer even a homogeneous one.
>> sol.a_1
ans =
a_2
>> sol.L_1
ans =
(C_2*L_2*a_2)/(C_1*b_1)
>> sol.R_1
ans =
(C_2*R_2*a_2)/(C_1*b_1)
As I said, each of those other parameters are just unknown coefficients in the problem, so homogeneity is no longer an issue.
Of course, I cannot simply try to solve all 4 equations in three unknowns. Doing so will cause solve to give up with no solution found. Now, the problem is over-determined, so we get a null solution.
solve(eqns(1:4),[a_1,L_1,R_1])
ans =
struct with fields:
a_1: [0×1 sym]
L_1: [0×1 sym]
R_1: [0×1 sym]
If I add EXACTLY one more carefully chosen unknown into the problem, solve will succeed, as you should now expect. Which variable may I choose? There is one additional equation. Substitute the 3x3 solution into eqns(1), we see:
subs(eqns(1),sol)
ans =
-1/(C_2*L_2) == -b_1/(C_2*L_2*a_2)
I can now choose one of the parameters there as my 4th unknown. In fact, I can even choose a_2 as an unknown and get a valid solution here. I'll be more sensible though and choose b_1 as my 4th unknown.
sol = solve(eqns(1:4),[a_1,L_1,R_1,b_1])
sol =
struct with fields:
a_1: [1×1 sym]
L_1: [1×1 sym]
R_1: [1×1 sym]
b_1: [1×1 sym]
>> sol.a_1
ans =
a_2
>> sol.L_1
ans =
(C_2*L_2)/C_1
>> sol.R_1
ans =
(C_2*R_2)/C_1
>> sol.b_1
ans =
a_2
It is a valid solution:
simplify(subs(eqns,sol))
ans =
[ TRUE, TRUE, TRUE, TRUE]
The point of all this is IF you understand how to use solve, AND if you understand the theory of linear systems of equations (linear algebra), then this becomes easy to solve as long as you use your knowledge to know the limits of what you can do. Were the problem truly nonlinear things get a bit nastier, but the ideas are still much the same. But this really is implicitly a linear system. As such, you could solve it using a form of Gaussian elimination, wherein you would multiply each equation by another, perhaps raising them to a power as needed. Since all variables are strictly positive, there is no problem in any of this.
Just for kicks, what happens if I had chosen both a_1 and a_2 as unknowns?
sol = solve(eqns(1:4),[a_1,L_1,R_1,a_2])
sol =
struct with fields:
a_1: [1×1 sym]
L_1: [1×1 sym]
R_1: [1×1 sym]
a_2: [1×1 sym]
>> sol.a_2
ans =
b_1
>> sol.a_1
ans =
b_1
So, as I said, we get a valid solution, where both a_1 and a_2 have some value. It turns out they have the same value, as they must since the 4th equation must hold true. All four equations are satisfied.
simplify(subs(eqns,sol))
ans =
[ TRUE, TRUE, TRUE, TRUE]
Best Answer