Mathematica: Solving system of three equations

  • Context: Mathematica 
  • Thread starter Thread starter ll235
  • Start date Start date
  • Tags Tags
    Mathematica System
Click For Summary
SUMMARY

This discussion focuses on solving a system of three equations using Mathematica, specifically addressing issues with the Solve and NSolve functions. The user, Alicia, encounters a looping problem in her code, which involves defining reference conditions and cable lengths. Key suggestions include changing function definitions from F1[lR_] = to F1[lR_] := and considering the simplification of square roots in the denominators to enhance computational efficiency.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of mathematical functions and equations
  • Knowledge of numerical methods for solving equations
  • Experience with algebraic simplification techniques
NEXT STEPS
  • Explore Mathematica's documentation on the Solve and NSolve functions
  • Learn about function definitions and their implications in Mathematica
  • Research techniques for simplifying multivariate quadratics in Mathematica
  • Investigate alternative numerical methods for solving complex systems of equations
USEFUL FOR

Mathematica users, mathematicians, engineers, and anyone involved in solving complex systems of equations using computational tools.

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 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K