Spline(pts, order, Weight Function)

Creates a spline with given order through all points. The weight function says what should be the difference of t values for point $P_i$ and $P_{(i+1)}$ given their difference $P_{(i+1)} - P_i = (x, y)$. To get the spline you expect from "function" algorithm you should use abs(x) + 0*y, to get the GeoGebra's default spline you can use sqrt(x^2+y^2).

Its implementation may be here.

Is there a corresponding function in Mathematica? I checked the documentation of the Interpolation and BSplineFunction,
I don't know how to set the weight function to reproduce the result. Let's say I have points pts like this, I generated the corresponding curve in Geogebra, which I converted into Mathematica code.






enter image description here

  • 1
    $\begingroup$ If you find out what kind of boundary constraints Geogebra uses, then you could try to use the weighting scheme shown in the answer below with the CubicSplineInterpolation resource function. See also Understanding Interpolation with Cubic Splines. $\endgroup$
    – MarcoB
    Commented May 25, 2022 at 12:04
  • 1
    $\begingroup$ @Marco's idea is a good one. I don't have time to write something detailed, but: pts = {{0, 0}, {1, 1}, {2, -1}, {3, 2}, {4, 1}}; tp = N[ResourceFunction["LeeInterpolatingNodes"][pts, 1]]; ResourceFunction["InterpolatingFunctionToPiecewise"][ResourceFunction["CubicSplineInterpolation"][Transpose[{tp, #}], "Natural"], t] & /@ Transpose[pts] // Expand and compare with what Geogebra does. $\endgroup$ Commented May 25, 2022 at 16:41

1 Answer 1


Your link documents the default weight function but it doesn't say which kind of boundary constraints are used to obtain a unique spline.

pts = {{0, 0}, {1, 1}, {2, -1}, {3, 2}, {4, 1}};

(* Geogebra default weight *)
ts = Prepend[Accumulate[N[Normalize[Norm /@ Differences[pts], Total]]], 0]
(* {0, 0.17190381, 0.44370759, 0.82809619, 1.} *)

To get a spline with these parameter values for the points you can use Interpolation, but the result still differs because the boundary is handled differently:

ParametricPlot[Interpolation[Thread[{ts, pts}], Method -> "Spline"][x] // Evaluate, {x, 0, 1}, AspectRatio -> 1]

  • $\begingroup$ What is called the "default weight" here is more properly known as "chord-length parametrization". The parametrizeCurve[] function from here with the second argument set to 1 will do this. $\endgroup$ Commented May 25, 2022 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.