Re: Can Mathematica construct a set of equations?
- To: mathgroup at smc.vnet.net
- Subject: [mg119335] Re: Can Mathematica construct a set of equations?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Tue, 31 May 2011 07:46:06 -0400 (EDT)
On 5/30/11 at 6:35 AM, ralph.dratman at gmail.com (Ralph Dratman) wrote:
>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?
Yes. Here is one way using 3 points that will work for a list of
n points.
In[1]:= points = {p1, p2, p3};
In[2]:= Norm[#] <= d & /@ (Subtract @@@ Subsets[points, {2}])
Out[2]= {Norm[p1 - p2] <= d, Norm[p1 - p3] <= d, Norm[p2 - p3]
<= d}