0
|
14934 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# How to treat Rule as an equality/equation

Posted 11 years ago
 Hi guys,I am trying to solve a set of equations which have matrices (The code for that is at the bottom). Solutions are of this form{{k[1][2] -> 1 - k[1][1], k[2][2] -> 1 - k[2][1]}}{{k[1][2] -> -3 + k[1][1], k[2][2] -> 3 + k[2][1]}}Is there any way I can re-use these solutions to convert them in the form of equations as k[1][2]= 1 - k[1][1], as I intend to use these linear equation further for solving under constraints using Reduce:Reduce[{Sol1[[1, 1]] && Sol1[[1, 2]] && Sol2[[1, 1]] && Sol2[[1, 2]] && 0.9 <= m11 <= 1.1 && 0.9 <= m22 <= 1.1}, {k[1][1], k[1][2],  k[2][1], k[2][2]}] but as:  {{k[1][2] -> 1 - k[1][1], k[2][2] -> 1 - k[2][1]}} or {{k[1][2] -> -3 + k[1][1], k[2][2] -> 3 + k[2][1]}}   these are rules not equations, therefore I am unable to solve them automatically by excessing in this way "Sol1[[1, 1]]". Is there any way I can treat these rules -> as equations so that I can further use it for Reduce procedure?(you can copy paste the bellow code to execute).ThanksUsman ClearAll; K=Table[k[i][i],{i,1,2},{j,1,2}]; M=Table[m[i][i],{i,1,2},{j,1,2}]; Psi=Table[psi[i][i],{i,1,2}]; m[1][2]=0; m[2][1]=0; M//MatrixForm; Psi//MatrixForm; Sol1=Solve[K.Psi==(W^2*M).Psi/.{W->Sqrt[1],psi[1]->1,psi[2]->1,m[1][1]->1,m[2][2]->1},{k[1][1],k[1][2],k[2][1],k[2][2]}]Sol2=Solve[K.Psi==(W^2*M).Psi/.{W->Sqrt[3],psi[1]->1,psi[2]->-1,m[1][1]->1,m[2][2]->1},{k[1][1],k[1][2],k[2][1],k[2][2]}]
5 Replies
Sort By:
Posted 11 years ago
 You can try replacing Rule->Equal a -> 1 /. Rule -> Equal a==1
Posted 11 years ago
 Hey,After doing some operation I have a list (named as "final") which have solutions. Some solutions are less then -1*10^(-10) just like below k[1][4] < -1*10^-10.k[1][1]==24166.7,    k[1][2]==-755.208 ,        k[1][3]==12083.3 ,       k[1][4]==-1.52454*10^-10  ,    k[2][1]==-755.208I am trying to assign zero "0" to those elements of list which are below a certain values but I am unable to do so using:For[i = 1, i <= 16,   i++, {If[final[] <  -1*10^-10, final[]==0]}];I have also tried using /. rule operation but it is not working. Is there any way I can do it ?k[1][4] is part of the list "final" so when I say final ==0 it gives me : (k[1][4] == -1.52454*10^-10) == 0which is correct but I need to access the part (K[1][4]) of the list final which is final[[4]] and I need to assign it zero if it is below a certain value. I hope it is clear what i need ?
Posted 11 years ago
 In[1]:= rules = {a -> b, {c -> d, e -> f}};        Equal @@@ Flatten[rules]Out[1]= {a == b, c == d, e == f}
Posted 11 years ago
 Awsome, thats good. Do it has any upper bound ? or I can convert hundreds or rules into equations using this structure?
Posted 11 years ago
 how does @@@ it works ? If i put @@ it simply equates the 2 roots of the same list of solutions if I put @ it returns me TRUE, what is the logic and semantic behind using it in three different ways.