Solving a system of nonlinear equations
Show older comments
Im working on solving for the static equilibrium of 3 connected hanging masses. This is shown in the diagram.

The masses and lengths of string are known. I end up with a system of nonlinear equations. I have 8 unknowns to solve for, which are 4 angles (t1, t2, t3, t4) and 4 tensions (T1, T2, T3, T4).
So far i have written the following code:
clear
m=[1 1 1]; %arbitrary values for mass
l=[5 5 5 5]; %arbitrary values for rope length
g=9.81;
D=20; %length of bar
syms t1 t2 t3 t4 T1 T2 T3 T4
x= [ sin(t1) sin(t2) sin(t3) sin(t4) cos(t1) cos(t2) cos(t3) cos(t4) T1 T2 T3 T4]';
%the following are the 12 equations that can be obtained from the system
f1= l(1).*x(5) + l(2).*x(6)+l(3).*x(7)+l(4).*x(8)-20;
f2= l(1).*x(1) + l(2).*x(2) - l(3).*x(3) - l(4).*x(4);
f3= -x(9).*x(5) + x(10).*x(6);
f4= m(1).*g + x(10).*x(2) - x(9).*x(1);
f5= x(11).*x(7) - x(10).*x(6);
f6= m(2).*g -x(10).*x(2)-x(11).*x(3);
f7= x(12).*x(8) -x(11).*x(7);
f8= m(3).*g + x(11).*x(3) - x(12).*x(4);
f9= (x(1)).^(2) + (x(5)).^(2) -1;
f10= (x(2)).^(2) + (x(6)).^(2) -1;
f11= (x(3)).^(2) + (x(7)).^(2) -1;
f12= (x(4)).^(2) + (x(8)).^(2) -1;
f = [f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12];
-------------------------------------------------
now i understand that fsolve cannot be used for symbolic variables, so how do i go about solving f?
7 Comments
Zayan Ahsan Ali
on 28 Oct 2018
Edited: Walter Roberson
on 28 Oct 2018
Walter Roberson
on 28 Oct 2018
You can add a third parameter to vpasolve() which is a numeric array with two columns, with one row for each variable (in the same order being solved for.) The first column is lower bounds; the second column is upper bounds. Use nan in both columns for entries that should not be bounded.
Caution: vpasolve() uses a Newton-raphson type solver, which overshoots by necessity. If an overshoot on a solution near (but within) a boundary goes out of bounds, vpasolve() will stop solving there rather than moving the value to inside the boundary.
Walter Roberson
on 28 Oct 2018
Note:
You have x = [....]' which is conjugate transpose. You do not make use of the fact that x is a column vector, and you appear to be wanting to work with real values, suggesting that you meant non-conjugate transpose at most. If you remove the conjugate part or declare the symbols to be real valued, then the last four entries of f vanish to 0. Your f is 12 long, of which 8 are non-zero, so you should probably get rid of those last 4.
Walter Roberson
on 28 Oct 2018
Odd, testing in a different software package, I find it claiming that there are a series of 480 closed form complex-valued solutions based upon roots of polynomials, the main one of which is degree 20. And every single value involved in those 480 solutions is complex valued: not even one real-valued solutions.
The numeric values you get with normal vpasolve() for T1, T2, T3, T4 are sort of large magnitude; if you subs() the solutions back into f, you will see that some of the results are not zero, partly due to round off error acting combining with large numeric values. But the problems persist even if you move to digits(100): f(4) and f(8) are particular problems.
Walter Roberson
on 28 Oct 2018
As I go for higher precision such as 250 digits, the error is not vanishing for f(4) and f(8), and can even be the opposite sign from before.
It should probably be assumed that vpasolve() is returning false roots.
John D'Errico
on 28 Oct 2018
Edited: John D'Errico
on 28 Oct 2018
Hmm. I thought clouds were really light? They float, don't they? ;-)
Seriously, it seems interesting in that these problems are usually formulated as a truss, with pinned joints, but bars that can vary in length. So just a force balance computation, basic finite elements. What you might see in a first course in FEM. It allows you to solve the problem using a purely linear system of equations, in terms of the coordinates of the three pinned joints.
Here, you are assuming bars of fixed lengths, so essentially infinite stiffness, an infinite Young's modulus. I have a funny feeling that you could formulate the problem in the form of a classical truss where the bars have a finite Young's modulus, and then just obtain the desired solution as the limit as E-->inf. The two methodologies should yield the same result in the end, but the scheme I described will not require you to solve a nonlinear system of equations.
Of course at the end, once you have the final set of displacements, you can back out the tensile stresses in each bar, so only the displacements for each node are necessary to describe the state of the system.
Alex Sha
on 11 Nov 2023
An approximate solution:
x1: -0.000386859711469918
x2: -0.000128952090745106
x3: -0.000128955577238622
x4: -0.000386863220600714
x5: 0.999999947230989
x6: 1.00000012310153
x7: 0.999999962070972
x8: 0.999999952070866
x9: -38036.8719191646
x10: -38036.865229583
x11: -38036.8713547058
x12: -38036.8717350701
Fevl:
-7.76282149672625E-8
3.49781215599771E-8
1.71785359270871E-8
8.78310757457257E-10
-2.49274307861924E-8
1.35815358959235E-9
8.46193870529532E-9
8.91805740366181E-10
4.41224170533161E-8
2.6283171705721E-7
-5.92285137601678E-8
5.38048858800266E-8
Accepted Answer
More Answers (0)
Categories
Find more on Number games 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!