Solve non-linear equations system parametrically, Why are the answers empty?

clear all;
clc;
syms X1 X2 X3 X4 X5 X6 X7 X8 X9 h k1 Lz1 k21 Lz2 k32 Lz3 a1 a2 a3 b1 b2 b3 w1 w2 w3 r1 r2 r3;
e0 = X1-1 == 0;
e1 = h*X1-k1*X7*X4==0;
e2 = X1*cos(X7*Lz1)+X4*sin(X7*Lz1)-X2==0;
e3 = -X1*X6*sin(X7*Lz1)+X4*X6*cos(X7*Lz1)-X8*X5*k21==0;
e4 = X2*cos(X8*Lz2)+X5*sin(X8*Lz2)-X3==0;
e5 = -X2*X8*sin(X8*Lz2)+X5*X8*cos(X8*Lz2)-X9*X6*k32==0;
e6 = X3*cos(X9*Lz3)+X6*sin(X9*Lz3)==0;
e7 = (a1/a2)*(b1^2+r1^2+X7^2+w1^2)-b2^2-r2^2-w2^2-X8^2 ==0;
e8 = (a1/a3)*(b1^2+r1^2+X7^2+w1^2)-b3^2-r3^2-w3^2-X9^2 ==0;
sol = solve([e0,e1,e2,e3,e4,e5,e6,e7,e8],[X1 X2 X3 X4 X5 X6 X7 X8 X9]);
Why are the answers empty?
X1: [0×1 sym]
X2: [0×1 sym]
X3: [0×1 sym]
X4: [0×1 sym]
X5: [0×1 sym]
X6: [0×1 sym]
X7: [0×1 sym]
X8: [0×1 sym]
X9: [0×1 sym]

2 Comments

What constraints can we put? Are any of variables guaranteed to be real? Non-negative?
No, there are no conditions or restrictions
Only X1 = 1 is assumed

Sign in to comment.

Answers (3)

You didn't assign values to these variables
% h k1 Lz1 k21 Lz2 k32 Lz3 a1 a2 a3 b1 b2 b3 w1 w2 w3 r1 r2 r3;

5 Comments

I want to assign some value to these variables and get the answers based on these variables
For example:
X2 = cos(k Lz2) - h*k21.....
How do I do this?
I think it's impossible. It's too complicated for symbolical solution
It is possible, I saw and solved similar examples, but I do not know why it does not work.
Anyway, thank you for the answer

Sign in to comment.

There are four solution sets, that look something like
[X1 == 1,
X2 == (cos(Lz1*h*sin(RootOf(Lz1^2*cos(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z1^2*a3*b3^2*h^2*k1^2+Lz1^2*a3*h^2*k1^2*r3^2+Lz1^2*a3*h^2*k1^2*w3^2-RootOf(Lz1^2*cos(Z)^2*h^2+cos(Z)^2*Z^2*k1^2-Lz1^2*h^2)^2*a1*h^2*k1^2)/cos(RootOf(Lz1^2*cos(Z)^2*h^2+cos(Z)^2*Z^2*k1^2-Lz1^2*h^2))/k1]
Here, RootOf() an expression in Z indicates the set of values for Z such that the expression becomes 0 -- the roots of the equation.
However, the RootOf are nested here and it gets confusing as to which Z refers to which level.
These RootOf are of nonlinear equations, such as RootOf(Lz1^2*cos(Z)^2*h^2 + cos(Z)^2*Z^2*k1^2 - Lz1^2*h^2), which contains a constant*Z^2*cos(Z) sub-expression. You are not likely to find closed-form expressions for them.
In my tests in Maple, the first seven expressions could be solved for the first 7 variables, giving a family of four solutions. You could then do substitutions of family members one at a time into the remaining two equations, solve, and back-substitute to complete the family member. You probably cannot do the same thing in MATLAB, as MATLAB tends to just give up if it discovers it needs to take the root of a nonlinear expression.
I am trying to solve exactly the same problem and I faced similar difficulties. I galad to have your contanct info for more exchanges.

4 Comments

There are no closed form solutions, so the solutions can at best be expressed in terms of roots of non-linear expressions such as Lz1^2*cos(Z)^2*h^2 + cos(Z)^2*Z^2*k1^2 - Lz1^2*h^2 in Z . However, MATLAB is weak on constructing placeholders such as RootOf(Lz1^2*cos(Z)^2*h^2 + cos(Z)^2*Z^2*k1^2 - Lz1^2*h^2,Z) and will normally give up before that point.
Given particular numeric values for the variables intended to be parameters, you can find numeric approximations for the roots, and so can hope to find numeric solutions (though you might have difficulty finding all of them.)
I do appreciate for your valuable notes. Could you please explain how do you understand that there are no closed form solutions? Is there an approach for recognizing when closed form solutions are not available?
I solved the equations in Maple.
In my tests in Maple, the first seven expressions could be solved for the first 7 variables, giving a family of four solutions. You could then do substitutions of family members one at a time into the remaining two equations, solve, and back-substitute to complete the family member. You probably cannot do the same thing in MATLAB, as MATLAB tends to just give up if it discovers it needs to take the root of a nonlinear expression.
syms X1 X2 X3 X4 X5 X6 X7 X8 X9 a1 a2 a3 b1 b2 b3 h k1 k21 k32 Lz1 Lz2 Lz3 w1 w2 w3 r1 r2 r3;
e0 = X1-1 == 0;
e1 = h*X1-k1*X7*X4==0;
e2 = X1*cos(X7*Lz1)+X4*sin(X7*Lz1)-X2==0;
e3 = -X1*X6*sin(X7*Lz1)+X4*X6*cos(X7*Lz1)-X8*X5*k21==0;
e4 = X2*cos(X8*Lz2)+X5*sin(X8*Lz2)-X3==0;
e5 = -X2*X8*sin(X8*Lz2)+X5*X8*cos(X8*Lz2)-X9*X6*k32==0;
e6 = X3*cos(X9*Lz3)+X6*sin(X9*Lz3)==0;
e7 = (a1/a2)*(b1^2+r1^2+X7^2+w1^2)-b2^2-r2^2-w2^2-X8^2 ==0;
e8 = (a1/a3)*(b1^2+r1^2+X7^2+w1^2)-b3^2-r3^2-w3^2-X9^2 ==0;
sol027 = solve([e0, e2, e7], [X1, X7, X8])
sol027 = struct with fields:
X1: [4×1 sym] X7: [4×1 sym] X8: [4×1 sym]
sol027.X1
ans = 
sol027.X7
ans = 
sol027.X8
ans = 
eqn2a = (subs([e1; e3; e4; e5; e6; e8], [X1, X7, X8], [sol027.X1(1), sol027.X7(1), sol027.X8(1)]))
eqn2a = 
sol027a1 = solve(eqn2a(1:4),[X2,X3,X5,X9],'returnconditions', true)
sol027a1 = struct with fields:
X2: [1×1 sym] X3: [1×1 sym] X5: [1×1 sym] X9: [1×1 sym] parameters: [1×0 sym] conditions: [1×1 sym]
sol027a1.X2
ans = 
sol027a1.X5
ans = 
sol027a1.X9
ans = 
simplify(sol027a1.conditions)
ans = 
eqn3a = subs(eqn2a(5:end), [X2, X5, X9], [sol027a1.X2, sol027a1.X5, sol027a1.X9])
eqn3a = 
sol3a_4 = solve(eqn3a(1), X4)
Warning: Unable to find explicit solution. For options, see help.
sol3a_4 = Empty sym: 0-by-1
sol3a_6 = solve(eqn3a(1), X6)
Warning: Unable to find explicit solution. For options, see help.
sol3a_6 = Empty sym: 0-by-1
You can play around with the order to see if you can get one more variable solved for, but you are unlikely to get all variables solved for.
Also, in the step forming eqn2a you could choose 2nd, 3rd, or 4th solutions to the previous equations, as that could certainly make a difference in whether you can solve.

Sign in to comment.

Categories

Asked:

on 26 Feb 2021

Commented:

on 28 Feb 2021

Community Treasure Hunt

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

Start Hunting!