在 C 中实现泰勒级数的函数返回参数的值

问题描述

我在 C 中试验了 tan(x) 的泰勒级数展开式。我创建了一个超级简单的函数,其目的是返回展开式的答案(见下面的代码)。问题是,当调用它时,答案是切线的参数,即如果您将函数切线称为 tangent(0.7853981634),即 pi/4 btw,您会得到相同的数字 0.7853981634。

#include <stdio.h>

float power(float x,int pow);
float tangent(float x);

void main(){
    float ans;
    ans = tangent(0.7853981634);

    printf("La tangente da %f \n",ans);
}

float tangent(float x){
    return x + 1/3 * (x * x * x) + 2/15 * (x * x * x * x * x);
}

注意:我知道有很多地方需要改进,只是我不知道为什么这段代码不能正常工作。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...