Function from a list of points

SparksMaths shared this question 1 week ago

I feel like I'm missing something here, but I can't seem to find a nice way to do this.

I'd like to create a *function* (with associated properties, i.e. it will accept an input from its domain and return an output from its co-domain etc) from a list of (x,y) points, so that it joins the points with straight lines.

Exactly like the polyline command does, except that does not return a *function* (it returns a 'polyline' which appears to be a number equal to the length of the lines created).

I can create a *freehand* function using the pen tool... but not a more simple linear piecewise one like this?

Am I missing a command?

Comments (8)


To my knowledge, this command does not exist.

You can use the command:

y(Intersect(PerpendicularLine((<Xvalue>, 0), xAxis), <polyline>))

I think (not tested) it's possible to create a custom-tool with the command above.


Check also the commands Fit... for example FitPoly( <List of Points>, <Degree of Polynomial> )

and also the command Spline( <List of Points>, <Order ≥ 3>, <Weight Function> ) (not for functions)


For equally-spaced points:

Function({x(A), x(D), y(A), y(B), y(C), y(D)})

For general points

l1=Sort({A, B, C, D})
DataFunction(x(l1), y(l1))

although DataFunction() isn't designed for dynamic update so you need a bit of script trickery :)


Ah yes. I knew I'd seen a command that does something like I wanted - datafunction was it. Thanks to you all for the suggestions though!

I wonder if there's a scope for a function to do this automatically (and dynamically) - (i.e. sorts points, creates datafunction, and updates it if points move), since adding the script to every point is a little painful if we have lots of points...


create a list of points and add the script only to list


I have a solution with a function (ConvListetoFunc(<List of points>) which convert a freehand into a function.

The function may vary when then freehand is Moving !


I've created a file that turns a polyline into a dynamic function. The idea can be transferred from the points A, B, C, D to elements of a sorted point list.



Please consider a new point E with the same x value as one of the existing point (eg. C) : E=(x(C),p(x(C)))

I think your intervals should include the boundary points on one side : eg. use >= instead of >

like the changes in attached file.

© 2019 International GeoGebra Institute