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

3 views (last 30 days)

Show older comments

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'

% solving the equations

[k11 k12 k13 k14 k21 k22 k23 k24] = solve(equations,[k11 k12 k13 k14 k21 k22 k23 k24])

Many thanks,

KE/

##### 0 Comments

### Accepted Answer

Walter Roberson
on 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.'

% solving the equations

sol1_6 = solve(equations(1:6), [k11 k12 k13 k21 k22 k23])

eqn2 = expand(subs(equations(7:end), sol1_6))

Notice that eqn2 does not contain any remaining k* variables.

Your equations are not full rank in k* variables.

##### 3 Comments

Walter Roberson
on 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.'

% solving the equations

constraint_equations = [k11 * k14 + k12 * k13 == 1; k12 * k24 + k22 * k23 == 1]

sol1_6 = solve(equations(1:6), [k11 k12 k13 k21 k22 k23])

sol4 = solve(constraint_equations, [k14 k24])

[k14; k24] == simplify(subs([k14;k24], subs(sol4, sol1_6)))

eqn2 = expand(subs(equations(7:end), sol1_6))

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.

### More Answers (1)

John D'Errico
on 31 Mar 2023

Edited: John D'Errico
on 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 Comments

Walter Roberson
on 31 Mar 2023

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!