0
|
14344 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 - k, k -> 1 - k}}{{k -> -3 + k, k -> 3 + k}}Is there any way I can re-use these solutions to convert them in the form of equations as k= 1 - k, 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, k,  k, k}] but as:  {{k -> 1 - k, k -> 1 - k}} or {{k -> -3 + k, k -> 3 + k}}   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=0; m=0; M//MatrixForm; Psi//MatrixForm; Sol1=Solve[K.Psi==(W^2*M).Psi/.{W->Sqrt,psi->1,psi->1,m->1,m->1},{k,k,k,k}]Sol2=Solve[K.Psi==(W^2*M).Psi/.{W->Sqrt,psi->1,psi->-1,m->1,m->1},{k,k,k,k}]
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*10^-10.k==24166.7,    k==-755.208 ,        k==12083.3 ,       k==-1.52454*10^-10  ,    k==-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 is part of the list "final" so when I say final ==0 it gives me : (k == -1.52454*10^-10) == 0which is correct but I need to access the part (K) of the list final which is final[] 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:= rules = {a -> b, {c -> d, e -> f}};        Equal @@@ Flatten[rules]Out= {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.