如何使用 Assembly MIPS {提供的公式}计算 sin(x)?
I'm just stuck with how to compute sin(x) in Assembly MIPS using the following formula
https://i.sstatic.net/YmxL4.jpg
plz if you have any idea write it down..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此文章来自 Matthew Stanton
此代码来自
this one is from Matthew Stanton
This code is from
要计算 X*3,需要 3 次乘法。要计算 X*5,还需要进行 2 次乘法运算。为了获得合理的精度,需要进行大量的乘法运算。然后是方程的阶乘部分 - 为了获得合理的精度,它也需要进行大量的加法。
你不能用查找表来解决性能问题;因为查找表比拥有“sin”查找表的成本更高。
基本上,您需要找到适合计算机的不同公式。
我很想从 CORDIC 开始: http://en.wikipedia.org/wiki/CORDIC
To calculate X*3 it will take 3 multiplications. To calculate X*5 it'll cost 2 more multiplications. To get reasonable precision, it's going to add up to a lot of multiplications. Then there's the factorial part of the equation - for reasonable precision, it's a lot of addition too.
You can't solve the performance problems with lookup tables; as the lookup tables would cost more than having a lookup table for "sin" instead.
Basically, you need to find a different formula that's suitable for computers.
I'd be tempted to start with CORDIC: http://en.wikipedia.org/wiki/CORDIC