# Is my system too complicated for Solve?

I am trying to solve a system of three nonlinear equations using Mathematica. Solve takes forever to run and never solves my system of equations. Is my system too complicated?

I have looked through the suggestions on using Solve in the Mathematica help, but none of these seem to work. I am wondering if I am going about solving the problem the wrong way.

Any help would be greatly appreciated! I have attached my code below.

### Solving the Tensegrity Model

Defining reference conditions

l0 = Sqrt[0.375];
s0 = 0.5 ;
k = 1;


Using prestress to define

ξ = 1 - lR/l0;

lR[ξval_] := l0 (1 - ξval);

lRvalues = Table[lR[ξrange], {ξrange, {0.0, 0.1, 0.5, 0.9, 1.0}}];


Defining cable lengths

Clear[sx, sy, sz]
l1[sx_] := 0.5 Sqrt[sx^2 + sy^2 - 2 sy + 2];
l2 := 0.5 Sqrt[sy^2 + sz^2 - 2 sz + 2];
l3[sx_] := 0.5 Sqrt[sz^2 + sx^2 - 2 sx + 2];

F1[lR_] = k (l1[sx] - lR);
F2[lR_] = k (l2 - lR);
F3[lR_] = k (l3[sx] - lR);

F1values = Table[F1[lr], {lr, lRvalues}];
F2values = Table[F2[lr], {lr, lRvalues}];
F3values = Table[F3[lr], {lr, lRvalues}];
F1values[[1]] /. sx -> 0.5
(*-0.612372 + 0.5 Sqrt[2.25 - 2 sy + sy^2]*)

sxval = Range[0.5, 2, 0.5];
For[j = 1, j < Length[sxval] + 1, j++,
For[i = 1, i < Length[F1values] + 1, i++,
Solve[{(F1values[[i]] /. sx -> sxval[[j]]) (1 - sy)/l1[sxval[[j]]] ==
F2values[[i]] sy/l2,
F2values[[i]] (1 - sz)/l2 == (F3values[[i]] /. sx -> sxval[[j]]) sz/
l3[sxval[[j]]],
T == 2 ((F1values[[i]] /. sx -> sxval[[j]]) sxval[[j]]/
l1[sxval[[j]]] + (F3values[[i]] /. sx -> sxval[[j]]) (
sxval[[j]] - 1)/l3[sxval[[j]]])}, {T, sy, sz}]
(*sy1 = NSolve[(F1values[[i]] /. sx -> sxval[[j]]) (1 - sy)/l1[sxval[[j]]] ==
F2values[[i]] sy/l2, sy, Reals] // FullSimplify;*)
(*Print[sy1]*)
]
]

• You haven't replaced all values of sx in your expression inside the loop. Is this correct? If you do this and also change solve to FindRoot (starting with sensible values) it solves it very quickly. Commented Mar 19, 2013 at 3:10
• All the values of sx should be gone in the solve function (I recently edited the post so that's the case at least)...
– AlC
Commented Mar 19, 2013 at 3:35
• sx still appears in the function as far as I can tell, both in the first and second elements of the list. Commented Mar 19, 2013 at 3:48
• I changed the definitions of F2values and F3 values (updated in the above post), and I think that removed all of the sx values from the solve function. I did FullSimplify of the individual terms and all sx terms were gone.
– AlC
Commented Mar 19, 2013 at 4:19

Instead of Solve, I recommend FindRoot:

FindRoot[{
(F1values[[i]] /. sx -> sxval[[j]]) (1 - sy)/l1[sxval[[j]]] == F2values[[i]] sy/l2,
F2values[[i]] (1 - sz)/l2 == (F3values[[i]] /. sx -> sxval[[j]]) sz/l3[sxval[[j]]],
T == 2 ((F1values[[i]] /. sx -> sxval[[j]]) sxval[[j]]/l1[sxval[[j]]] + (F3values[[i]] /.
sx -> sxval[[j]]) (sxval[[j]] - 1)/l3[sxval[[j]]])
},
{{T, 0}, {sy, 0}, {sz, 0}}]


That should work. In the current loop, it won't print anything, so you will have to include a Print` statement or similar to see what is actually happening.

• Thanks Jonathan! I used FindRoot like you suggested and that worked much better. I really appreciate your help :)
– AlC
Commented Mar 19, 2013 at 4:36
• Be careful that there is only a single solution as Findroot will, in general find the solution close to the starting values that you set. If you are looking at a system with multiple solutions then you will miss some with this method. Commented Mar 19, 2013 at 4:39
• Sounds good! I have some graphs to compare my results too so I will look into that...
– AlC
Commented Mar 19, 2013 at 6:37
• @AlC what kind of tensegrity problem are you trying to solve? Commented Nov 21, 2018 at 9:57