how can solve the nonlinear system of 6 equations with 6 unknown variables?

83 views (last 30 days)
eq1 = a1+d1*d10+l*l10-p-b1;
eq2 = a2+d2*d20+l*l20-p-b2;
eq3 = a3+d3*d30+l*l30-p-b3;
eq4 = py+b*cos(psi)*sin(phi);
eq5 = -cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi)-cos(psi)*sin(phi);
eq6 = (b/2)*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi)-cos(psi)*cos(phi))-px;
% Solve the Equations
sol = solve(eq1,eq2,eq3,eq4,eq5,eq6);
sol.px
sol.py
sol.pz
sol.theta
sol.phi
sol.psi

Accepted Answer

Walter Roberson
Walter Roberson on 13 Nov 2015
No, you are trying to solve for a variable pz that does not occur in your equations.
Meanwhile, you indicate that you have 6 equations in 6 unknowns and you list 6 explicit unknowns, px, py, pz, theta, phi, psi, all of which occur only in the last 3 of your equations. We have to conclude that none of the names listed in the first 3 equations are symbolic because if they were there would be more than 6 unknowns available to be solved for. The first 3 equations must therefore be purely numeric, in which case you are asking solve() to solve for three numeric variables being equal to 0 and have all the symbolic information in the remaining 3 equations.
We notice the p in the first three equations and wonder whether it is related to px, py, pz. One possibility is that p = [px, py, pz]. But if that were the case then the first three equations would be vectors rather than single values and you would have 12 equations in 6 unknowns.
Perhaps your first three equations intended to reference one of px, py, pz each instead of p ?
  3 Comments
Walter Roberson
Walter Roberson on 14 Nov 2015
With p = [px, py, pz] then
eq1 = a1+d1*d10+l*l10-p-b1;
is the same as
eq1 = a1+d1*d10+l*l10-[px, py, pz]-b1;
which is a vector with three values. When you pass a vector to solve() then it means that all of the values in the vector must be satisfied as being true for solve() to succeed. As there are no logical comparisons in the vector, the implicit comparison is "== 0", so your eq1 is the same as if you had put in
eq1 = [a1+d1*d10+l*l10-px-b1==0, a1+d1*d10+l*l10-py-b1==0, a1+d1*d10+l*l10-pz-b1==0];
That contributes three equations. Your eq2 and eq3 also refer to the vector p, so they are contributing three equations each as well. Your eq4, eq5, and eq6 contribute one equation each. You therefore have 3+3+3+1+1+1 = 12 equations, but you only have 6 variables. You are not going to be able to find a solution.
MJTHDSN
MJTHDSN on 12 Apr 2018
Dear Walter,
I have a similar question. Let`s assume the equations as below:
SN = rnd(5,1); a = SN(1); b = SN(2); c = SN(3); d = SN(4); e = SN(5); f = SN(6);
eq1 = a*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(1)^2)*(x(4)^2)-2*x(1)*(x(4)^2)+(x(4)^2)-(2*x(1)*x(4)*x(5))+(x(4)*x(5))+(x(5)^2)) == 0;
eq2 = b*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(1)^2)*(x(4)^2)+(2*x(1)*x(4)*x(5))+(x(5)^2)) == 0;
eq3 = c*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(4)^2)+(2*x(4)*x(5))+(x(5)^2)) == 0;
eq4 = d*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(1)^2)*(x(4)^2)-2*x(1)*(x(4)^2)+ (x(4)^2)-(2*x(1)*x(4)*x(5))-(x(4)*x(5))+(x(5)^2)) == 0;
eq5 = e*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(1)^2)*(x(4)^2)-(2*x(1)*x(4)*x(5))+(x(5)^2)) == 0;
eq6 = f*((x(1)^2)*(x(2)^2)+(x(1)^2)*(x(3)^2)-2*x(1)*(x(2)^2)+(x(2)^2))-((x(4)^2)-(2*x(4)*x(5))+(x(5)^2)) == 0;
here, a,b,c,d,e,f are numbers (0.43 for example). For now I consider them as SN(i):
I want to find x(1),...,x(5) values.
I have tried many ways but no solution was found.
Can you help me with my problem.
Best

Sign in to comment.

More Answers (1)

Sai Sabarish M
Sai Sabarish M on 27 Feb 2019
Try Newton Raphson Method of solving a Non Linear Equation.
Use this code to solve:

Categories

Find more on Symbolic Math Toolbox 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!