TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Polynomial interpolation

97 点作者 atan2超过 2 年前

11 条评论

foooobaba超过 2 年前
Related: Fast Fourier Transform (FFT) can be used for polynomial interpolation in O(nlogn) time (if you get to choose the points, and use “complex roots of unity”), where n is the degree of the polynomial, and is used as a step in multiplication of polynomials in O(nlogn) as well.<p>This video covers it well: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;h7apO7q16V0" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;h7apO7q16V0</a><p>Also, chapter 30 of CLRS: <a href="https:&#x2F;&#x2F;elec3004.uqcloud.net&#x2F;ebooks&#x2F;CLRS%20(2nd%20Ed)%20-%20Chapter%2030.FFT.pdf" rel="nofollow">https:&#x2F;&#x2F;elec3004.uqcloud.net&#x2F;ebooks&#x2F;CLRS%20(2nd%20Ed)%20-%20...</a>
评论 #34714407 未加载
评论 #34716682 未加载
评论 #34714626 未加载
评论 #34715404 未加载
sritchie超过 2 年前
Here&#x27;s some Clojure code I wrote for the Emmy computer algebra system that implements polynomial interpolation with a few different algorithms described in Numerical Recipes:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mentat-collective&#x2F;emmy&#x2F;blob&#x2F;main&#x2F;src&#x2F;emmy&#x2F;polynomial&#x2F;interpolate.cljc">https:&#x2F;&#x2F;github.com&#x2F;mentat-collective&#x2F;emmy&#x2F;blob&#x2F;main&#x2F;src&#x2F;emmy...</a><p>I discovered while writing this that I could express each of these algorithms as folds that consumed a stream of points, accumulating a progressively higher order polynomial.<p>Here&#x27;s the same sort of thing but for rational function interpolation: <a href="https:&#x2F;&#x2F;github.com&#x2F;mentat-collective&#x2F;emmy&#x2F;blob&#x2F;main&#x2F;src&#x2F;emmy&#x2F;rational_function&#x2F;interpolate.cljc">https:&#x2F;&#x2F;github.com&#x2F;mentat-collective&#x2F;emmy&#x2F;blob&#x2F;main&#x2F;src&#x2F;emmy...</a>
评论 #34718541 未加载
alleycat5000超过 2 年前
Check out <a href="https:&#x2F;&#x2F;www.chebfun.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.chebfun.org&#x2F;</a> if you want to see some crazy stuff you can do with polynomials!<p>Also the book Approximation Theory and Approximation Practice<p><a href="https:&#x2F;&#x2F;epubs.siam.org&#x2F;doi&#x2F;book&#x2F;10.1137&#x2F;1.9781611975949" rel="nofollow">https:&#x2F;&#x2F;epubs.siam.org&#x2F;doi&#x2F;book&#x2F;10.1137&#x2F;1.9781611975949</a><p>is really great, by the author of Chebfun.
评论 #34716276 未加载
rerdavies超过 2 年前
See Lagrange interpolators for the general form of the interpolator used in this article. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Lagrange_polynomial" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Lagrange_polynomial</a><p>There&#x27;s a neater general formula for generating Lagrange interpolator polynomials of any order that avoids having to perform matrix inversion.<p>Interpolated values can be calculated in O(N) time, so Lagrange interpolation is always faster than FFT interpolation. Calculate the left Product(0..i-1) of each term in left-to-right order. If you carry the value from term to term, you only need one multiplication per term. and the Product(i+1..N-1) of each term in right-to-left order.<p>Lagrange interpolators with degrees that are close to Pi<i>N tend to be smoother, with less aliasing, when processing audio signals. (N=3, 6, 9, 13, &amp;c). Truncating the Langrange polynomial is akin to windowing in FFT. Having an order that&#x27;s roughly Pi</i>N ensures that the analogous window of the Langrange polynomial has smaller tail values.
评论 #34720462 未加载
kazinator超过 2 年前
I made a joke posting to the comp.lang.c Usenet newsgroup on this topic. Looks like it was in 2014.<p><a href="https:&#x2F;&#x2F;groups.google.com&#x2F;g&#x2F;comp.lang.c&#x2F;c&#x2F;s7yeYGuMs8s&#x2F;m&#x2F;juwf9wkVMnsJ" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;g&#x2F;comp.lang.c&#x2F;c&#x2F;s7yeYGuMs8s&#x2F;m&#x2F;juwf...</a><p>Google Groups no longer allows &quot;View Original&quot;. Let&#x27;s reformat the code. Actually, nope; I found the file from 2014 easily.<p>Seventh degree polynomial for Fibonacci, with Easter egg:<p><pre><code> #include &lt;math.h&gt; #include &lt;stdio.h&gt; int fib(int n) { double out = 0.002579370; out *= n; out -= 0.065277776; out *= n; out += 0.659722220; out *= n; out -= 3.381944442; out *= n; out += 9.230555548; out *= n; out -= 12.552777774; out *= n; out += 7.107142857; out *= n; return floor(out + 0.5); } int main(void) { int i; for (i = 0; i &lt; 9; i++) { printf(&quot;fib(%d) = %d\n&quot;, i, fib(i)); switch (i) { case 7: puts(&quot;^ So, is this calculation fib or not?&quot;); break; case 8: puts(&quot;^ Answer to life, universe &amp; everything responds negatively!&quot;); } } return 0; } </code></pre> Execution:<p><pre><code> $ .&#x2F;fib2 fib(0) = 0 fib(1) = 1 fib(2) = 1 fib(3) = 2 fib(4) = 3 fib(5) = 5 fib(6) = 8 fib(7) = 13 ^ So, is this calculation fib or not? fib(8) = 42 ^ Answer to life, universe &amp; everything responds negatively</code></pre>
thomasahle超过 2 年前
It&#x27;s just<p><pre><code> ax1^3 + bx1^2 + cx1 + d = y1 ax2^3 + bx2^2 + cx2 + d = y2 ax3^3 + bx3^2 + cx3 + d = y3 ax4^3 + bx4^2 + cx4 + d = y4 </code></pre> As a matrix:<p><pre><code> [x1^3 + x1^2 + x1 + 1] [a] = [y1] [x2^3 + x2^2 + x2 + 1] [b] = [y2] [x3^3 + x3^2 + x3 + 1] [c] = [y3] [x4^3 + x4^2 + x4 + 1] [d] = [y4] </code></pre> If the matrix is M, we just want to find M^(-1)y.<p>I think hackers should know enough linear algebra to do that, without &quot;having to go asking the maths gods&quot;.
评论 #34719194 未加载
评论 #34721005 未加载
评论 #34717756 未加载
lugao超过 2 年前
I will probably get down voted here, but in my perspective the author bitterness towards mathematics ends up doing the opposite of his supposed objective of &quot;demystifying&quot; the subject. It pushes &quot;hackers&quot; and &quot;maths&quot; even further apart.
wbl超过 2 年前
Polynomial coefficients of an interpolating polynomial are poorly conditioned. Instead you should evaluate in the barycentric form directly or use alternate forms of the polynomial.
the__alchemist超过 2 年前
Great article, and I&#x27;ve been applying this recently in a few unrelated projects. Of note, research on the internet produces some surprising red herrings that make this seem more complicated than it is. This article&#x27;s approach, by contrast, is nice and apt. Spline? Lagrange polynomials? Newton polynomials? etc. This gets especially messy when looking for interpolation in 2 and 3D.<p>I came to the same conclusion as the article: The answer is to solve a system of linear equations with 4 unknowns.
nigamanth超过 2 年前
Interesting take on y = a + x(b + x(c + x(d))) which is the factorized form of any cubic function. You&#x27;re right, you don&#x27;t have to be the god of math to do this.
amelius超过 2 年前
How do you prevent overfitting?
评论 #34716397 未加载