Mathematica Mathematica: Solving system of three equations

Click For Summary
Alicia is encountering difficulties using Mathematica's Solve and NSolve functions to resolve a system of three equations, particularly getting stuck in a loop within her code. She has defined reference conditions and cable lengths, and is calculating forces based on these parameters. The code includes nested loops for iterating through values of sx and corresponding force values. Suggestions include changing the definitions of F1, F2, and F3 from assignment to function definitions to potentially improve performance. Additionally, it is recommended to explore cross-multiplying square roots in the denominators to reduce complexity and speed up computations. Despite these adjustments, the complexity of the equations suggests that a different approach may be necessary to effectively solve the system.
ll235
Messages
2
Reaction score
0
Hello,

I am new to mathematica, and I am having trouble using the solve/nsolve to solve my system of three equations.

Attached is my code so far. Any help would be greatly appreciated. It gets stuck in the loop section of the code. I have also pasted the code below.

Thanks!
Alicia

Defining reference conditions

In[3]:= l0 = Sqrt[0.375];
s0 = 0.5 ;
k = 1;


Using prestress to define

In[6]:= \[Xi] = 1 - lR/l0;

In[7]:=
lR[\[Xi]val_] := l0 (1 - \[Xi]val);

In[10]:=
lRvalues = Table[lR[\[Xi]range], {\[Xi]range, {0.0, 0.1, 0.5, 0.9, 1.0}}];



Defining cable lengths

In[11]:= 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];

In[15]:=
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[F1[lr], {lr, lRvalues}];
F3values = Table[F1[lr], {lr, lRvalues}];

In[59]:= F1values[[1]] /. sx -> 0.5

Out[59]= -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[] /. sx -> sxval[[j]]) (1 - sy)/l1[sxval[[j]]] ==
F2values[] sy/l2,
F2values[] (1 - sz)/l2 == (F3values[] /. sx -> sxval[[j]]) sz/
l3[sxval[[j]]],
T == 2 ((F1values[] /. sx -> sxval[[j]]) sxval[[j]]/
l1[sxval[[j]]] + (F3values[] /. sx -> sxval[[j]]) (
sxval[[j]] - 1)/l3[sxval[[j]]])}, {T, sy, sz}]
(*sy1=NSolve[(F1values[]/.sx ->sxval[[j]]) (1-sy)/l1[sxval[[j]]]==
F2values[] sy/l2,sy,Reals]//FullSimplify;*)
(*Print[sy1]*)
]
]
 
Physics news on Phys.org
Here is the attachment
 

Attachments

I would change these
F1[lR_] = k (l1[sx] - lR);
F2[lR_] = k (l2 - lR);
F3[lR_] = k (l3[sx] - lR);
to these
F1[lR_] := k (l1[sx] - lR);
F2[lR_] := k (l2 - lR);
F3[lR_] := k (l3[sx] - lR);

If you can justify that your square roots of quadratics that appear in all of your denominators can be cross multiplied to get rid of those denominators then this might give Mathematica fewer possible zero denominators to worry about and possibly speed things up.

But even with that, with trying rationals instead of decimals, trying Simplify and FullSimplify, you still have a forest of products of square roots of multivariate quadratics and I suspect there needs to be a different approach.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
7K