Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica: Solving system of three equations

  1. Mar 18, 2013 #1
    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]*)
    ]
    ]
     
  2. jcsd
  3. Mar 18, 2013 #2
    Here is the attachment
     

    Attached Files:

  4. Mar 18, 2013 #3
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica: Solving system of three equations
Loading...