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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Approximating the Sine Function with Quadratics

12 点作者 squeakynick将近 6 年前

1 comment

olliej将近 6 年前
Nit: modern computers don’t have efficient trig functions anymore - my understanding is that the complexity is so high that the overhead of instruction dispatch isn’t significant (which is a big part of the cost for things like sqrt).<p>It is true that chips do have them: x87 hardware is still present on x86 hardware, even in 64 bit. But x87 is essentially considered completely legacy (Windows-64bit doesn’t use it for long double) - no meaningful perf changes in a decade or more (beyond clock improvements I assume)<p>Then loading the values takes a while as you have to load them onto the x87 stack, which requires conversion to the x87 ieee formats (it is ieee just different bit sizes), which isn’t cheap.<p>And that gets you all the way to being able to use: fcos, fsin, fsincos, ftan, fatan, fexp, fexpm1, and a few other transcendental functions (there’s also fprem and fprem1, two slightly different floating point partial remainder functions)<p>After you’ve run those instructions, you then have to copy them off the x87 stack, which is also only through memory.<p>What do you have at that point? Incorrect values. Why? Because the algorithms used in the x87 unit weren’t as accurate as they were thought to be, but by that point intel realized that continuing to invest in x87 was no in anyone’s interest - using SSE directly was already faster, and accuracy could be corrected without changing hardware.