Solving a set of 8 non-linear equations using symbolic toolbox results in empty sym 0 by 1

6 visualizzazioni (ultimi 30 giorni)
Hi all,
I have got a set of 8 equations that are non-linear as below. There are 8 knowns and 8 unknowns, thus the system can be solved.
I have tried to solve with the Matlab function solve, but this results in an empty sym 0 by 1
Is there a function implemented in Matlab that can handle solving a system of non linear equations using for example a loop with substitution or other techniques for such a system?
% 8 knowns that are real
syms Lx Ly Mx My Nx Ny Ox Oy
assume ([Lx Ly Mx My Nx Ny Ox Oy], 'Real')
% 8 unknowns that are real
syms k11 k12 k13 k14 k21 k22 k23 k24
assume([k11 k12 k13 k14 k21 k22 k23 k24], 'Real')
% 1 constant that is real
syms cte
assume(cte, 'Real')
% definition of the system of equation
equations = [Lx == k21 * k11 - k12 * k23,...
Mx == - ( k22 * k12 ) / cte,...
Ny == k21 * k13 + k23 * k14,...
Ly == ( k21 * k12 ) / cte,...
My == k11 * k22 + k12 * k24,...
Nx == ( k21 * k14 ) / cte,...
Ox == k24 * k14 - k22 * k13...
Oy == ( k22 * k14 ) / cte...
];
equations'
ans = 
% solving the equations
[k11 k12 k13 k14 k21 k22 k23 k24] = solve(equations,[k11 k12 k13 k14 k21 k22 k23 k24])
k11 = Empty sym: 0-by-1 k12 = Empty sym: 0-by-1 k13 = Empty sym: 0-by-1 k14 = Empty sym: 0-by-1 k21 = Empty sym: 0-by-1 k22 = Empty sym: 0-by-1 k23 = Empty sym: 0-by-1 k24 = Empty sym: 0-by-1
Many thanks,
KE/

Risposta accettata

Walter Roberson
Walter Roberson il 31 Mar 2023
% 8 knowns that are real
syms Lx Ly Mx My Nx Ny Ox Oy
assume ([Lx Ly Mx My Nx Ny Ox Oy], 'Real')
% 8 unknowns that are real
syms k11 k12 k13 k14 k21 k22 k23 k24
assume([k11 k12 k13 k14 k21 k22 k23 k24], 'Real')
% 1 constant that is real
syms cte
assume(cte, 'Real')
% definition of the system of equation
equations = [Lx == k21 * k11 - k12 * k23,...
Mx == - ( k22 * k12 ) / cte,...
Ny == k21 * k13 + k23 * k14,...
Ly == ( k21 * k12 ) / cte,...
My == k11 * k22 + k12 * k24,...
Nx == ( k21 * k14 ) / cte,...
Ox == k24 * k14 - k22 * k13...
Oy == ( k22 * k14 ) / cte...
];
equations.'
ans = 
% solving the equations
sol1_6 = solve(equations(1:6), [k11 k12 k13 k21 k22 k23])
sol1_6 = struct with fields:
k11: -(k14*(- k14*k24*Ly^2 + My*Nx*Ly))/(Mx*Nx^2*cte) k12: (Ly*k14)/Nx k13: (k14*(Lx*Mx*Nx + Ly*Mx*Ny + Ly*My*Nx - Ly^2*k14*k24))/(Ly*Mx*Nx*cte) k21: (Nx*cte)/k14 k22: -(Mx*Nx*cte)/(Ly*k14) k23: -(- k14*k24*Ly^2 + My*Nx*Ly + Lx*Mx*Nx)/(Ly*Mx*k14)
eqn2 = expand(subs(equations(7:end), sol1_6))
eqn2 = 
Notice that eqn2 does not contain any remaining k* variables.
Your equations are not full rank in k* variables.
  3 Commenti
Walter Roberson
Walter Roberson il 31 Mar 2023
Strictly speaking, "full rank" does only apply to linear systems, but it can also be used informally in discussions of whether some of the equations are linearly dependant on the other equations.
Walter Roberson
Walter Roberson il 31 Mar 2023
% 8 knowns that are real
syms Lx Ly Mx My Nx Ny Ox Oy
assume ([Lx Ly Mx My Nx Ny Ox Oy], 'Real')
% 8 unknowns that are real
syms k11 k12 k13 k14 k21 k22 k23 k24
assume([k11 k12 k13 k14 k21 k22 k23 k24], 'Real')
% 1 constant that is real
syms cte
assume(cte, 'Real')
% definition of the system of equation
equations = [Lx == k21 * k11 - k12 * k23,...
Mx == - ( k22 * k12 ) / cte,...
Ny == k21 * k13 + k23 * k14,...
Ly == ( k21 * k12 ) / cte,...
My == k11 * k22 + k12 * k24,...
Nx == ( k21 * k14 ) / cte,...
Ox == k24 * k14 - k22 * k13...
Oy == ( k22 * k14 ) / cte...
];
equations.'
ans = 
% solving the equations
constraint_equations = [k11 * k14 + k12 * k13 == 1; k12 * k24 + k22 * k23 == 1]
constraint_equations = 
sol1_6 = solve(equations(1:6), [k11 k12 k13 k21 k22 k23])
sol1_6 = struct with fields:
k11: -(k14*(- k14*k24*Ly^2 + My*Nx*Ly))/(Mx*Nx^2*cte) k12: (Ly*k14)/Nx k13: (k14*(Lx*Mx*Nx + Ly*Mx*Ny + Ly*My*Nx - Ly^2*k14*k24))/(Ly*Mx*Nx*cte) k21: (Nx*cte)/k14 k22: -(Mx*Nx*cte)/(Ly*k14) k23: -(- k14*k24*Ly^2 + My*Nx*Ly + Lx*Mx*Nx)/(Ly*Mx*k14)
sol4 = solve(constraint_equations, [k14 k24])
sol4 = struct with fields:
k14: -(k12*k13 - 1)/k11 k24: -(k22*k23 - 1)/k12
[k14; k24] == simplify(subs([k14;k24], subs(sol4, sol1_6)))
ans = 
eqn2 = expand(subs(equations(7:end), sol1_6))
eqn2 = 
So you can use the constraints to give values to all of the k variables -- but you still end up with the situation of having two extra equations that need to happen to be statisfied in order for the system to be consistent.

Accedi per commentare.

Più risposte (1)

John D'Errico
John D'Errico il 31 Mar 2023
Modificato: John D'Errico il 31 Mar 2023
NO. The equation POSSIBLY has a solution. In theory, it MIGHT have a solution. But having a theoretical solution does not mean it is possible to find it. And for some nonlinear equations, just because something MIGHT have a solution does not mean a solution exists.
For a trivial example with one equation and one unknown, what is the real solution of
x^2 +1 == 0
I'm still waiting. Again, just that a nonlinear equation has the same number of unknowns as equations does not insure a solution.
That you have 8 equations in 8 unknowns only tells you there is some possibility of a solution. Not that there must always exist a solution. You may be thinking of what applies when you have a linear system. Is your system linear? NO.
And, because you have a parameter in there, numerical tools like vpasolve cannot apply.
Effectively, by replacing one unknown in the other equations, the result ends up being a higher order polynomial. Do that 7 times, and you get a rather highdegree polynomial, one higher than 4 in the end. And what does that tell you? Abel-Ruffini told us long ago that such a problem has no general solution in an algebraic form, IF the degree is higher than 4.
If the parameter cte were known as a numerical constant, then you could use a solver, like fsolve. But cte is not known.
So what does this mean? Sorry. No solution will be found.
  3 Commenti
John D'Errico
John D'Errico il 31 Mar 2023
But, remember that IF your system is rank deficient, then you still have problems. That means there will generally be infinitely many solutions. And the solution you do find will depend on the starting values. It is not unlike solving the problem (using a tool like fsolve)
x^2 + y^2 == 1
Anywhere you start a numerical solver, it will find a solution. But the solution you do find will vary. You cannot control it, except by your choice of start point.
Walter Roberson
Walter Roberson il 31 Mar 2023
As I showed, some of your k* variables depend upon cte, some do not. But your equations as posted are only valid of Ox and Oy just happen to have a specific relation to some of the other variables (relationships that do not depend upon cte)

Accedi per commentare.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by