<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, "Exact" cubic Hermite spline</title>
    <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 06:50:03 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 06:50:03 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, "Exact" cubic Hermite spline</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline</link>
    </image>
    <item>
      <title>I think that's great, Alec.</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment120149</link>
      <itunes:summary>&lt;p&gt;I think that's great, Alec.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>120149</guid>
      <pubDate>Sat, 21 May 2011 12:23:56 Z</pubDate>
      <itunes:author>longrob</itunes:author>
      <author>longrob</author>
    </item>
    <item>
      <title>This is good</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment120166</link>
      <itunes:summary>&lt;p&gt;This is good Alec.&amp;nbsp; Thanks!&amp;nbsp; I wonder if we could tweak out that&amp;nbsp;hiccup between pts 9 and 10?&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>120166</guid>
      <pubDate>Sat, 21 May 2011 22:40:17 Z</pubDate>
      <itunes:author>Christopher2222</itunes:author>
      <author>Christopher2222</author>
    </item>
    <item>
      <title>Perhaps</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment120167</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline#comment120166"&gt;@Christopher2222&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Perhaps, at least manually, by changing the values of derivatives at points 9 and 10, given by df.&lt;/p&gt;
&lt;p&gt;There might be a better way of calculating the suggested derivatives than I did in df.&lt;/p&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>120167</guid>
      <pubDate>Sat, 21 May 2011 22:56:04 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>I agree</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment120168</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline#comment120149"&gt;@longrob&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I agree.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>120168</guid>
      <pubDate>Sat, 21 May 2011 23:01:47 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>Some comments</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment122754</link>
      <itunes:summary>&lt;p&gt;p(x0,p0,m0,x1,p1,m1,x) is a function f of x (an expression actually which can be a number if x is numeric) such that f(x0)=p0, f(x1)=p1, f'(x0)=m0, f'(x1)=m1.&lt;/p&gt;
&lt;p&gt;pb and pe are similar - just pb doesn't input the derivative at x0 and pe doesn't input the derivative at x1 - they are used at the beginning and at the end of the plot. Also, they are quadratic functions of x while p is cubic.&lt;/p&gt;
&lt;p&gt;df(L) with L being a 2-dimensional Array of 3 or more points, supposedly ordered by their first coordinates, calculates suggested derivatives for the "exact" interpolation, so that the derivatives at local maximums and minimums are 0, and other derivatives are calculated as the slopes of the lines connecting closest neighbors from the rhs and from the lhs of a point. The values at the beginning and at the end are set to 0, which doesn't matter if pb and pe are used at the beginning and at the end.&lt;/p&gt;
&lt;p&gt;Chris(L,X) , with L being a 2-dimensional Array of 3 or more points, sorted in ascending order of their first coordinates, produces a piecewise function f of X (or its value if X is numeric) such that f(L[k,1])=L[k,2], with derivatives at the k-th point given by df(L). This function is a combination of pb on the first interval, pe at the end, and p on the other intervals (between the first one and the last one).&lt;/p&gt;
&lt;p&gt;The df could be calculated differently, perhaps. One possible way is to calculate the suggested derivatives being the average values between the slopes of 2 lines connecting the point with its rhs and lhs neighbors - I didn't try that.&lt;/p&gt;
&lt;p&gt;The number of points in L (which should be at least 3) is not checked - one has to add such checks to df and to Chris procedures, with producing a straight line for 2 points, and, perhaps, a constant for 1 point, and, maybe, a constant 0 for 0 points, if one would want to save them for future usage.&lt;/p&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>122754</guid>
      <pubDate>Wed, 15 Jun 2011 22:38:16 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>minimizing absolute curvature</title>
      <link>http://www.mapleprimes.com/posts/120138-Exact-Cubic-Hermite-Spline?ref=Feed:MaplePrimes:"Exact" cubic Hermite spline:Comments#comment122757</link>
      <itunes:summary>&lt;p&gt;The posted code makes it easy to adjust the slopes at the knots. Thanks, Alec.&lt;/p&gt;
&lt;p&gt;Let's recall that cubic spline interpolation, in a commonly used sense, minimizes curvature while producing a curve which is twice continuously differentiable. I guess people like this, if they hope to model smooth phenomena. There are lots of variants which can use piecewise cubics to produce something which may only be once continuously differentiable.&lt;/p&gt;
&lt;p&gt;Christopher asked for the extra constraint that the slope be zero at certain points. Alec cleverly interpreted this to mean zero only at knots which are locally extreme (w.r.t the discrete adjacent knot values). This is a nice refinement on an instance of a Cardinal spline with parameter c=1, and also more sophisticated that what's called a&lt;span class="mw-headline"&gt; Catmull&amp;ndash;Rom (c=0) variant of the cubic Hermite spline.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;Alec, I believe that your code does in fact use the average of the secants on either side, ie. the average of the slopes of the two line segments from knot i-1 to i and from knot i to i+1. (Your code gets this because the x-differences are all equal, I think... I tried to alter this to be true also for irregularly spaced knots, by using a scaled version of the so-called "finite difference" variant, see attached.)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;But there's still a lot of leeway as to what tweaks one can make to the slope values at the knots. I'm attaching a worksheet in which the finite difference variant is applied to all internal knots which are not locally extreme. I keep Alec's twist to satisfy Chris, that slopes be zero at knots whose immediate neighbours are either both greater or lower in value. I scale each of the nonzero internal knots by parameter `c`. And then (unless I computed it wrongly) I find the `c` value which minimizes the total absolute curvature.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;Here's a worksheet. The two animations should each produce the curve Alec showed above when c=1 (if I did it all right). Except that I changed the value at x=9 to be 7, instead of 6, so as to accentuate the hiccup that Christopher asked about in his comment above.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;&lt;a href="/view.aspx?sf=122757/387888/alec_modified_hermit.mw"&gt;alec_modified_hermit.mw&lt;/a&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;Lots more variations are possible. One could use a set of c[i] and optimize all of them at once w.r.t the total absolute curvatue (each c[i] affects a pair of segments, just as the slopes themselves do). That might reduce hiccups and inflexions even more. One can think of even more interesting variants -- more than just those which have fancy sounding names.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;I forgot to scale the slopes at the two end-knots by `c`, but changing the code is easy.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;I didn't put any thought into how to compute the curvature more quickly (given that I know it's a piecewise, and I know the formula, etc). Corrections and comments are always welcome. The Optimization took about 10sec, and the plot a bit longer. There must be a fast way, but I didn't really try.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mw-headline"&gt;Alec's code layout is simple and easy to modify. I'm not sure whether the easier path to efficiency is to implement it using linear algebra, or to edit the procs to be Compilable.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, "Exact" cubic Hermite spline</description>
      <guid>122757</guid>
      <pubDate>Wed, 15 Jun 2011 23:59:28 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>