简体   繁体   English

C GSL贝塞尔函数示例

[英]C GSL Bessel function example

I tried the following code: 我尝试了以下代码:

# include <stdio.h> 
# include <gsl/gsl_sf_bessel.h> 
int main (void)
{
double x = 5.0; 
double y = gsl_sf_bessel_j0 (x); 
printf ("JO(%g) =  %.18e\n", x , y);
return(0);
}

the result I get is: 我得到的结果是:

JO(5) =  -1.917848549326277019e-01

The result given in the GSL manual is GSL手册中给出的结果是

-1.775967713143382920e-01 

Any idea what is wrong? 知道有什么问题吗?

It's indeed looks like a bug to me. 在我看来确实像是个虫子。 I seems that it has not been fixed yet according to the changelist . 我似乎根据更改列表尚未修复它。 However, there are two possible reasons: 但是,有两个可能的原因:

  • A typo in the documentation. 文档中的错字。 Instead of gsl_sf_bessel_j0 you should use gsl_sf_bessel_J0 (very strange naming). 而不是gsl_sf_bessel_j0,您应该使用gsl_sf_bessel_J0(非常奇怪的命名)。 That gives you JO(5) = -1.775967713143382642e-01 which is close enough to the desired answer (I'm not sure about the precision though). 这给了你JO(5) = -1.775967713143382642e-01 ,它足够接近所需的答案了(尽管我不确定精度)。
  • The documentation is correct, we need to fix the function itself. 该文档是正确的,我们需要修复功能本身。

Anyway, since it's not been reported I've submitted a bug report. 无论如何,由于尚未报告,因此我已提交了错误报告。 I do plan to update this answer as soon as I get any information related to this problem. 我确实计划在收到与此问题有关的任何信息后立即更新此答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM