Re: Can Mathematica construct a set of equations?
- To: mathgroup at smc.vnet.net
- Subject: [mg119330] Re: Can Mathematica construct a set of equations?
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Tue, 31 May 2011 07:45:12 -0400 (EDT)
- References: <BANLkTimOrU4wUBXU7p-8G_GeUZGV+0L5Fg@mail.gmail.com> <irvrtb$8jo$1@smc.vnet.net>
Yes, it can. Let us first define the distance between vectors as dif[x_?VectorQ, y_?VectorQ] := Sqrt[Dot[(x - y),(x - y)]] The equations (inequalities) can then be easily created at once thus eqs[n_] := And @@ (Flatten[ Table[eq[i, k] = dif[p[i], p[k]] <= d, {i, 1, n - 1}, {k, i + 1, n}]]) Finally let the variables, i.e. the components of the vectors, be defined as (this is the case of two dimensions x and y) p[1]={px[1],py[1]}, p[2]={px[2],py[2]}, ... We can make the assigment using Table[p[i] = {px[i], py[i]}, {i, 1, n}]; Now choosing n (for instance = 3) we can "solve" the equations for the variables n=3 sol = Solve[eqs[n], Flatten[Table[p[i], {i, 1, n}]]] If the equations contain inequalities we should use Reduce instead of Solve. PS: the generalization to more than two dimensions, say k, can be made using a numbering scheme replacing and extending x and y: p[i] = {p[i,1],p[i,2],...,p[i,k]} PPS: I guess it needs a very fast computer to actually carry out the solving procedure for n in the range of 10. Hope this helps, Wolfgang "Ralph Dratman" <ralph.dratman at gmail.com> schrieb im Newsbeitrag news:irvrtb$8jo$1 at smc.vnet.net... > Given a set of N points Pn in the real plane, all within a distance d > of each other, > > In vector notation, > > || Pj - Pk || <= d, 1 <= j,k <= N > > or written out, say for N=3, > > || P1 - P2 || <= d, > || P2 - P3 || <= d, > || P3 - P1 || <= d. > > That is fine for 3 points, but suppose I have 10. Then the long > version is Choose[10,2] = 45 equations, and I don't particularly want > to write them out by hand. Can Mathematica do that for me, and give > me > the equations in a notebook? > > I'm not even sure how to represent the position vectors so I can > refer > to xj or yk later on. How do I set up vector-sub-j and its components > x-sub-j and y-sub-j ? Would that be a list of N lists of length 2? > Or is there a more specific vector notation? > > Sorry to be so clueless. Thank you. > > Ralph >