(X3 / 3) - 如何使用氮化硅系列= X计算三角函数的比例! +(X5 / 5)I - (X7 / 7)! +在一个C程序 [英] how to Calculate trigonometric ratio using series sinx = x - (x3/3)! + (x5/5)i - (x7/7)! + a in c program
本文介绍了(X3 / 3) - 如何使用氮化硅系列= X计算三角函数的比例! +(X5 / 5)I - (X7 / 7)! +在一个C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一系列计算在C三角函数比率
i want to calculate trigonometric ratio in c using series
sinx = x - x3/3! + x5/5! - x7/7! + a
和想比较我的标准数学LIB函数的结果。
其中a =常数
and want to compare my result with standard math lib function. where a = constant
任何暗示
推荐答案
如果该问题是如何总结系列,你可以只通过一个更新术语之一:
If the question is how to sum up the series, you could just update the term one by one:
double sum_the_series(double x, size_t number_of_terms)
{
const double x2 = x * x;
double term = x;
double result = term;
for (size_t i = 1; i < number_of_terms; ++i)
{
term = term * x2 / (double(2*i) * double(2*i+1));
if (i % 2 == 0) result += t;
else result -= t;
}
return result;
}
这篇关于(X3 / 3) - 如何使用氮化硅系列= X计算三角函数的比例! +(X5 / 5)I - (X7 / 7)! +在一个C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文