I would like to distribute N particles on a line (symmetric
boundaries) by a function, say f(x)=sin(x), so that a small
value gives a small spatial distances while a large value
gives a big spatial distance. In example if f(x)= constant,
the spatial distance between all particles is the same. So
f(x) acts as a potential and the particles repell each other.
In article <fo6o84$mcu$1@fred.mathworks.com>,
matias nordin <matias.nordin@gmail.com> wrote:
>I would like to distribute N particles on a line (symmetric
>boundaries) by a function, say f(x)=sin(x), so that a small
>value gives a small spatial distances while a large value
>gives a big spatial distance. In example if f(x)= constant,
>the spatial distance between all particles is the same. So
>f(x) acts as a potential and the particles repell each other.
Hmmm, so let f(x) = 0. That's a constant. But 0 would seem
to be a small value, so that would imply small spacial distances
rather than the possibly-large spatial distances you would get
if you had a small number of particles equidistant in the interval
("the spatial distance between all particles is the same").
Or let f(x) be -1. That's a constant too. But since f(x) acts
as a repelling potential, a negative value would imply attraction,
which would imply clumping rather than equidistance.
Recall that you said "say f(x) = sin(x)" and recall that sin(x)
can be negative.
Sooo.. your problem does not yet appear to me to be well-defined.
(The plausibility of the half-formed solutions that I have in mind
will depend upon how you refine the problem.)
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
"matias nordin" <matias.nordin@gmail.com> wrote in message <fo6o84
$mcu$1@fred.mathworks.com>...
> Hi everyone!
>
> I would like to distribute N particles on a line (symmetric
> boundaries) by a function, say f(x)=sin(x), so that a small
> value gives a small spatial distances while a large value
> gives a big spatial distance. In example if f(x)= constant,
> the spatial distance between all particles is the same. So
> f(x) acts as a potential and the particles repell each other.
>
> How to do?
>
> Thanks for reading and helping!
>
> Matias
-----------
Perhaps you are saying something like this - that the density of the particles
is to be inversely proportional to the given function, f(x). Or in other words,
that the integral of the reciprocal of the function is to be proportional to the
accumulated particle count. Would that be an accurate statement?
If so, that would precisely define the problem, but, depending on the
function, it might not be easily solved. For the sin(x) function you mentioned,
it can be solved. Assume that a and b are the left and right boundaries of
your line and that 0 < a < b < pi. If we also assume there is to be a particle
at each boundary, you would want the x-value, xp, of the p-th particle to
satisfy:
where "int('csc(t)','t',a,b)" means the integral of the cosecant of t (which is the
reciprocal of sin(t)) with respect to t from a to b. Note that for xp = a this
would give 0 on both sides, so p would be 1. If xp = b, then p would be N.
If I remember my calculus correctly, the two sides of the equation evaluate
to
On Feb 4, 5:09=A0am, "matias nordin" <matias.nor...@gmail.com> wrote:
> Hi everyone!
>
> I would like to distribute N particles on a line (symmetric
> boundaries) by a function, say f(x)=3Dsin(x), so that a small
> value gives a small spatial distances while a large value
> gives a big spatial distance. In example if f(x)=3D constant,
> the spatial distance between all particles is the same. So
> f(x) acts as a potential and the particles repell each other.
>
> How to do?
>
> Thanks for reading and helping!
>
> =A0 Matias
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
Of course there's an infinite number of functions that can do that.
One other key question I wondered about is: do you want the points to
be uniformly spaced, or have some noise in the spacing?
Regards,
ImageAnalyst
> Hmmm, so let f(x) = 0. That's a constant. But 0 would seem
> to be a small value, so that would imply small spacial
distances
> rather than the possibly-large spatial distances you would get
> if you had a small number of particles equidistant in the
interval
> ("the spatial distance between all particles is the same").
>
> Or let f(x) be -1. That's a constant too. But since f(x) acts
> as a repelling potential, a negative value would imply
attraction,
> which would imply clumping rather than equidistance.
>
> Recall that you said "say f(x) = sin(x)" and recall that
sin(x)
> can be negative.
>
> Sooo.. your problem does not yet appear to me to be
well-defined.
> (The plausibility of the half-formed solutions that I have
in mind
> will depend upon how you refine the problem.)
> --
> "Any sufficiently advanced bug is indistinguishable
from a feature."
> -- Rich Kulawiec
Sorry, what I mean is the following.
Assume you have N particles.
Spread the particles equally on a line (with symmetrical
boundaries).
Then apply a function (some well defined function) that
distorts the distance between the particles. The function is
scaled so that particles don't come too close or too far
apart. So you can choose that "in that area the particles
are at this distance from each other". So I want this:
equally spread on [1 25] as [1 5 10 15 20]
apply a function --->
not equally spread on [1 25] as for example [1 2 3 15 20].
In article <fohsjn$4pu$1@fred.mathworks.com>,
matias nordin <matias.nordin@gmail.com> wrote:
>Assume you have N particles.
>Spread the particles equally on a line (with symmetrical
>boundaries).
>equally spread on [1 25] as [1 5 10 15 20]
That is not equally spread on [1 25] with symmetrical boundaries.
The distance from 20 to 1 is not the same as the distance from
5 to 10, and the distance from 1 to 5 is not the same as the
distance from 5 to 10. Try [1 6 11 16 21]
--
So you found your solution
What will be your last contribution?
-- Supertramp (Fool's Overture)
In article <fohsjn$4pu$1@fred.mathworks.com>,
matias nordin <matias.nordin@gmail.com> wrote:
>Assume you have N particles.
>Spread the particles equally on a line (with symmetrical
>boundaries).
>Then apply a function (some well defined function) that
>distorts the distance between the particles. The function is
>scaled so that particles don't come too close or too far
>apart. So you can choose that "in that area the particles
>are at this distance from each other". So I want this:
>equally spread on [1 25] as [1 5 10 15 20]
>apply a function --->
>not equally spread on [1 25] as for example [1 2 3 15 20].
I still don't see how you are going to define this in terms
of a function that could be positive or negative, such as
in your example f(x) = sin(x) .
If you restrict your function to non-negative values, and you
ignore the boundaries for a moment, you could set the element
positions at
X1 + (X1-X0) * Int(f(t),t=X0 to x) / Int(f(t),t=X0 to X1)
"matias nordin" <matias.nordin@gmail.com> wrote in message <fohsjn$4pu
$1@fred.mathworks.com>...
>
> Sorry, what I mean is the following.
>
> Assume you have N particles.
> Spread the particles equally on a line (with symmetrical
> boundaries).
>
> Then apply a function (some well defined function) that
> distorts the distance between the particles. The function is
> scaled so that particles don't come too close or too far
> apart. So you can choose that "in that area the particles
> are at this distance from each other". So I want this:
>
> equally spread on [1 25] as [1 5 10 15 20]
>
> apply a function --->
>
> not equally spread on [1 25] as for example [1 2 3 15 20].
>
> Matias
---------
Matias, you haven't yet told us precisely in what way your f(x) relates to the
condition that "a small value gives a small spatial distances while a large
value gives a big spatial distance". In my previous article in this thread I
speculated that in a sense the density of spacing of the particles is to be
inversely proportional to f(x). This leads to a problem that can be solved in a
case such as your f(x) = sin(x). The question is, was that a reasonable
assumption?
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <foi3vv$ai6$1@fred.mathworks.com>...
> "matias nordin" <matias.nordin@gmail.com> wrote in message
<fohsjn$4pu
> $1@fred.mathworks.com>...
> >
> > Sorry, what I mean is the following.
> >
> > Assume you have N particles.
> > Spread the particles equally on a line (with symmetrical
> > boundaries).
> >
> > Then apply a function (some well defined function) that
> > distorts the distance between the particles. The function is
> > scaled so that particles don't come too close or too far
> > apart. So you can choose that "in that area the particles
> > are at this distance from each other". So I want this:
> >
> > equally spread on [1 25] as [1 5 10 15 20]
> >
> > apply a function --->
> >
> > not equally spread on [1 25] as for example [1 2 3 15 20].
> >
> > Matias
> ---------
> Matias, you haven't yet told us precisely in what way
your f(x) relates to the
> condition that "a small value gives a small spatial
distances while a large
> value gives a big spatial distance". In my previous
article in this thread I
> speculated that in a sense the density of spacing of the
particles is to be
> inversely proportional to f(x). This leads to a problem
that can be solved in a
> case such as your f(x) = sin(x). The question is, was
that a reasonable
> assumption?
>
> Roger Stafford
>
>
yes Roger that assumption was what I was thinking of, that
the density of spacing is inversely proportional to f(x).
The function f(x) is also scaled so that it only takes
positive values. So functions that takes negative values are
simply lifted by a constant, in example for sin(x):
f(x)=-sin(x)+constant.
As a physicist I would like to treat the problem as follows:
The particles are connected by springs all with the equal
spring force so that in absence of f(x), they are equally
distributed. And f(x) is introduced as a external potential
distorting the equal spacing. The dynamics is not of
importance, only to find equilibrium. However as the number
of particles can be altered I have a feeling that it would
be cumbersome to do such a program (since the number of
equations will change). So that stopped me from that idea.
And now I am thinking of some easier way, as just
multiplying the distance by 1/f(x)) and scale it until it
fits within the boundaries. As you see the problem is not
well defined yet, as I want to have an easy solution. Ideas
would be of great interest.
In article <fopbv1$7p$1@fred.mathworks.com>,
matias nordin <matias.nordin@gmail.com> wrote:
>As a physicist I would like to treat the problem as follows:
>The particles are connected by springs all with the equal
>spring force so that in absence of f(x), they are equally
>distributed. And f(x) is introduced as a external potential
> distorting the equal spacing. The dynamics is not of
>importance, only to find equilibrium.
Is the potential associated with the position (i.e., a field),
or is the potential associated with the particle (e.g.,
by varying the spring forces) ?
Should we read that "springs" as implying that (in the
absence of the external force) the dynamic potential between
any two adjacent particles is proportional to the square of the
distance between them?
If the density is inversely proportional to the function,
then adjusting the function by a constant (to avoid negative
numbers) introduces non-linear distortions and the value of
the constant would become crucial in determining the distribution.
--
"I was very young in those days, but I was also rather dim."
-- Christopher Priest
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <foqbqr$h35$1@canopus.cc.umanitoba.ca>...
> In article <fopbv1$7p$1@fred.mathworks.com>,
> matias nordin <matias.nordin@gmail.com> wrote:
>
> >As a physicist I would like to treat the problem as follows:
>
> >The particles are connected by springs all with the equal
> >spring force so that in absence of f(x), they are equally
> >distributed. And f(x) is introduced as a external potential
> > distorting the equal spacing. The dynamics is not of
> >importance, only to find equilibrium.
>
> Is the potential associated with the position (i.e., a field),
> or is the potential associated with the particle (e.g.,
> by varying the spring forces) ?
>
> Should we read that "springs" as implying that (in the
> absence of the external force) the dynamic potential between
> any two adjacent particles is proportional to the square
of the
> distance between them?
>
> If the density is inversely proportional to the function,
> then adjusting the function by a constant (to avoid negative
> numbers) introduces non-linear distortions and the value of
> the constant would become crucial in determining the
distribution.
> --
> "I was very young in those days, but I was also rather
dim."
> -- Christopher Priest
Thanks for the attention Walter!
Yes, the potential is an external field. So we do not change
the internal forces of the springs.
And yes, the potential rising from the springs is
proportional to the square of distance between them.
Total potential from the springs:
U_s=Sum_i( (X_i-X_(i+1))^2 )
note: the last particle is connected to the first, so we
adjust the summation for that chriteria.
external potential:
U_e=g(X)
..gives the total potential
U_tot(X_1,X_2,...,X_N)=Us_+U_e
for what choordinates, X_1...X_N, is U_tot minimized?
How is this treated in MATLAB?
In article <fornaa$e3h$1@fred.mathworks.com>,
matias nordin <matias.nordin@gmail.com> wrote:
>Yes, the potential is an external field. So we do not change
>the internal forces of the springs.
>And yes, the potential rising from the springs is
>proportional to the square of distance between them.
>Total potential from the springs:
>U_s=Sum_i( (X_i-X_(i+1))^2 )
As a side note: you could vectorize that. If you calculate
xs = X.^2 then the squares portion would be
xs(1) + xs(end) + 2*sum(xs(2:end-1))
from which you would subtract 2*sum(X(2:end)*X(1:end-1))
to get U_s .
>external potential:
>U_e=g(X)
>..gives the total potential
>U_tot(X_1,X_2,...,X_N)=Us_+U_e
However, if g(X) is constant, then the positions the particles
would adopt would be the same as if g(X) were everywhere 0; does
it make sense in that case to say that the total energy of the
system is higher than if there were no external field? Perhaps
it does, in that the field itself has energy, but in that case,
it should be the integral of g(X) that you add rather than
g(X) itself. The main competing alternative would be
to calculate U_s and subtract from that the U_s that would occur
if there was no field: the different between the two would be the
total work that the field was exerting on the system.
--
"Tired minds don't plan well. Sleep first, plan later."
-- Walter Reisch
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.