Chebyshev approximation calculator
Dev tools
code generator
SHOW HN2024
278points
51comments
#239of 3,515 in 2024
Top 7%of 2024 by points
How HN took it
DebatedReal support and real criticism
3 positive, 4 neutral or asking, 0 mixed, 4 critical, out of 11 comments about the project. Thread score -0.04.
Execution: 1 for, 4 againstIdea: 2 for, 0 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Nicely done and useful; compact generated code makes Chebyshev methods accessible.
From 3 comments
This is really nicely done! Great work. I fell in love with just how efficient these can be and it explained a lot about why many of the trig and other mathematical functions…
jaymzcampbell on HNExcellent work. I wanted to do this recently, but it was surprisingly hard to find code to calculate an approximation. I've bookmarked it for when I next need a quick…
xioxox on HNThis is really nice. Wish I had it back in university, it would have made learning the Chebyshev expansions a lot more interesting than they were.
ArmedSandwich on HN
Objections
Fails on functions with singularities or undefined points, such as sinc at zero or 1/x.
From 3 comments
Math.sin(x)/x (the sinc function) for 7 terms over [-3,3] gives coefficients c0...c6 that are all NaNs. Is this a bug? To work around it, I handled the x near zero case by just…
Fredkin on HNRather nice that. I like it. Doesn't handle divide by zero very well though i.e. f(x)=1/x. Should probably consider that as undefined rather than a bad expression.
hggigg on HN> Math.sin(x)/x (the sinc function) for 7 terms over [-3,3] gives coefficients c0...c6 that are all NaNs. Is this a bug? That wouldn't exactly be a bug. The code is undoubtedly…
Majromax on HN
Requests
Support for rational function approximations.
From 1 comment
Great work, looks useful! Any chance you can add a rational function version?
roger_ on HN
Import of tabular sensor data.
From 2 comments
Nice! I'd like to generate a Chebyshev approximation for a set of X, Y sensor values. Any hints on how to modify your code to do that?
Zeetah on HNYou could look into using the ChebyshevExpansion class directly. It takes as one of its arguments a callback that returns f(x) for a given x. In your case, f(x) would be your…
stuffmatic on HN
Questions
Why not use Horner or Estrin evaluation methods.
From 1 comment
why not evaluate polynomials using horner or estrin methods
mgaunard on HN
Alternatives named
Chebfun
From 2 comments
Obligatory callout to Nick Trefethen (et. al.)'s Chebfun[1] which extends this stuff in just about every direction you can think of. 'Chebfuns' are to functions as floats are to…
Rayhem on HNhm, why not Chebfun? Result is a rational polynomial so we have to divide, but that seems fine/fast on servers.
janwas on HN
Sollya
From 2 comments
I've had good results in the past with sollya: https://www.sollya.org/. Note: results. The software itself is a bit of a pain to use.
orlp on HNSollya is probably the best modern tool for doing this. Under the hood, it does a Remez approximation followed by LLL to quantize to floating point. No use of Chebyshev directly.
pclmulqdq on HN