# How do I equidistantly discretize a continuous function?

Let's say I have a piecewise function that's continuous in an interval [1,7]:

$f(x) = \left\{ \begin{array}{lr} -5x + 6 & : x \in [1,2)\\ -4x + 14 & : x \in [2,3)\\ -0.25x + 2.75 & : x \in [3,7] \end{array} \right.$

1. How would I get a discretization of that function that consists of 10 equidistant points? [I'm interested in method(s), not calculations for that example.]

2. More generally, how would I discretize functions with any number of parameters to get n equidistant points (e.g., to represent the surface of a sphere with 100 equidistant points)?

-
Could you rephrase? First, interval refers to $\mathbb{R}$ and not $\mathbb{R}^2$. Second, it seems your question has nothing to do with functions. Third, the inclusion of an image in your post is unwise if the image carries no information. Fourth, since $\mathbb{R}^n$ is unbounded, to choose a finite number of points in this space could need some further explanations. –  Did Mar 25 '11 at 8:19
Sorry, I tried to be more clear. About the image: it's there to support the example - images usually shouldn't hold information that's not already part of the question. –  user8696 Mar 25 '11 at 9:51
Thanks for the clarification. It seems the usual discretization of an interval $[a,b]$ by the $n+1$ equidistant points $a+(b-a)(k/n)$ is not what you are after, why? Do you intend to keep track of the points used to define piecewisely your function, in your example $2$ and $3$? (About the image: if you ask me, in this case it carries no useful information whatsoever and could be omitted.) –  Did Mar 25 '11 at 10:01
I'm sorry, I lost my cookie and can't add a comment above. I also cannot request a user merge on Meta because I only got 1 rep point. I'm also not allowed to chat, so I'm forced to make this an answer: @DidierPiau: I'll just write what I'm looking for instead of what I think I need to do: In the example above I'm looking for a set of points $\{(x_i, y_i)\}$ for $i = 1, ..., 10$ with $f(x_i) = y_i$, so that the (Eucledian) distance between $(x_j, y_j)$ and $(x_{j+1}, y_{j+1})$ is some $\delta$ (given that $x_j < x_{j+1}$ for $j = 1,...,9$). –  user8696 Mar 25 '11 at 11:59
I see. Looks kind of weird. Any motivation? –  Did Mar 25 '11 at 13:42

You can just guess what the stepsize will be and "swing a compass" from the starting point to find the next, "swing the compass" again, and see whether you end at the end. It is a one-dimensional root find to get the distance. If any of your segments are too vertical, there may be more than one point of intersection, which you will have to deal with. The function $(\text{end }x)=f($step size$)$ may be discontinuous as the points move across the corners in your input function, so it may not work, but I would try bisection.

-

In one dimension, you could try to parametrize the curve $C(t)=\{x(t),y(t)\}$ in such a way that the "velocity" is constant, and then quantize the paramenter $t$ - that is feasible, but that would lead you to equidistant points along the curve, and that's not apparently what you are after.

Elsewhere, the problems seems awkard, only tractable by some iterative algorithm.

In more dimensions, it's worse, it even becomes bad defined: what would "n equidistant points" mean?

There are many iterative algorithms, some related to vector quantization or clustering, some inspired by physical systems. For example, you could throw N random initial points over your domain, and move them according to some "energy" function, that increases at short distances: in that way, the points would try to go as far as the others as they can, and that "low energy" configuraton would correspond -more or less, conceptually- to the "equidistant points" you are envisioning.

If you, additionally, want to impose some organization/ordering/topology to the points (for example, in 2D you could want them to conform some distorted mesh, with each points having four -north-east-south-west 'neighbours') then you should take a look at Self Organizing Maps (Kohonen).

-