Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 需要帮助进行自然对数(ln)的数学计算吗_C_Math - Fatal编程技术网

C 需要帮助进行自然对数(ln)的数学计算吗

C 需要帮助进行自然对数(ln)的数学计算吗,c,math,C,Math,如何用C语言编写此函数 y=20磅(x+3) 如何编写ln函数?\include #include <math.h> double fun(double x) { return 20 * log( x + 3 ); //base-e logarithm! } //usage double y = fun(30); 双倍乐趣(双倍x) { 返回20*log(x+3);//以e为底的对数! } //用法 双y=乐趣(30); 对于以10为底的对数,使用log10()

如何用C语言编写此函数

y=20磅(x+3)

如何编写ln函数?

\include
#include <math.h> 

double fun(double x)
{
    return 20 * log( x + 3 );  //base-e logarithm!
}

//usage
double y = fun(30);
双倍乐趣(双倍x) { 返回20*log(x+3);//以e为底的对数! } //用法 双y=乐趣(30);
对于以10为底的对数,使用
log10()

?

你称之为:

double y = myfunction(yourX);

c库中的log函数执行自然对数('ln')。有关更多详细信息,请参见:

#包括
双功能(双x)
{
双y=20*log(x+3.0);
返回y;
}

<>代码>尽管PQ是问题的C++,提问者还是要求C实现:

#include <math.h>

double myFunction(double x) {
    return 20.0 * log(x + 3.0);
}
#包括
双myFunction(双x){
返回20.0*log(x+3.0);
}

< /代码>这是C++;该问题要求C。删除
标准::
和无用的temp变量。将其更改为C。我保留该变量以使其与OPs问题相关。不要忘记
#包括
,并在必要时链接数学库。您是否打算使用对数的多项式表达式,即ln(x)=(x-1)-(x-1)^2)/2+((x-1)^3)/3-((x-1)^4)/4。。。如果不是的话,我相信你已经得到了很多答案。你有没有试过在谷歌上搜索“C自然对数”?
#include <math.h>
double function(double x)
{
     double y = 20 * log(x + 3.0);
     return y;
}
#include <math.h>

double myFunction(double x) {
    return 20.0 * log(x + 3.0);
}