Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2794 > unrolled thread
| Started by | Ralph Dratman <ralph.dratman@gmail.com> |
|---|---|
| First post | 2011-05-30 10:35 +0000 |
| Last post | 2011-05-31 11:45 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Can Mathematica construct a set of equations? Ralph Dratman <ralph.dratman@gmail.com> - 2011-05-30 10:35 +0000
Re: Can Mathematica construct a set of equations? "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-05-31 11:45 +0000
| From | Ralph Dratman <ralph.dratman@gmail.com> |
|---|---|
| Date | 2011-05-30 10:35 +0000 |
| Subject | Can Mathematica construct a set of equations? |
| Message-ID | <irvrtb$8jo$1@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
[toc] | [next] | [standalone]
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Date | 2011-05-31 11:45 +0000 |
| Message-ID | <is2kcq$qlm$1@smc.vnet.net> |
| In reply to | #2794 |
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@gmail.com> schrieb im Newsbeitrag
news:irvrtb$8jo$1@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
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web