在数学中,微分方程,
null
尤其重要。方程的解是参数的函数 .对于
,解特别有趣,被称为圆柱形贝塞尔函数,以德国著名数学家弗里德里希·威廉·贝塞尔的名字命名。要求
积分或半积分在下面给出的解释中是清楚的。
由于这是一个二阶微分方程,必须有两个线性独立的解,称为第一类和第二类。因此,可以使用 弗罗贝尼乌斯法 .第一类贝塞尔函数,用于复杂参数 ,称为第一类修正贝塞尔函数,用
.该方法的应用产生了一个包含下列项的无穷级数:
和
,由,
由于表达式包含伽马函数,该函数只能计算整数值和半整数值,因此 必须是整数或半整数。
C++17(GCC 7.1)标准库 cmath
给出了计算第一类圆柱贝塞尔函数值的函数 (std::cyl_bessel_j)
(这里没有讨论,但与我们讨论的非常相似)和正则修正贝塞尔函数的值 (std::cyl_bessel_i)
。两者都具有相当高的精度,可用于各种工程应用。
例如:
输入: x=2.798465,v=0 输出: 4.152234090041574
输入: x=3.04513,v=0.5 输出: 4.792979684692604
注: 以下源代码只能在C++17及更高版本上运行。可以检查给定代码的运行示例 在这里 。要运行其他输入,请访问链接并单击右下角的“编辑”。
// C++17 code for bessel function #include <bits/stdc++.h> using namespace std; // Compute the answer from the formulae for first 10 terms long double answer( long double x, long double v) { long double ans_by_expansion = 0; long double fact = 1; for ( int k = 0; k < 10; fact = fact * (++k)) { ans_by_expansion += pow ((x / 2), (2 * k)) / pow (fact, 2); cout << "ans_by_expansion till term k = " ; cout << k << " is " << ans_by_expansion << "" ; } return ans_by_expansion; } // Driver code int main() { long double x = 2.798465; long double v = 0; // Compute the Regular Modified Bessel Function // for v = 0, x = 2.798465 long double ans_by_function = cyl_bessel_i(v, x); cout << setprecision(15) << fixed; cout << "The answer by function for " << "Regular_Modified_Bessel_Function" << endl << "(" << v << ", " << x << ") = " << ans_by_function << "" ; // calculate answer by expansion long double ans_by_expansion = answer(x, v); cout << "Absolute Error in answer by both the methods is = " ; cout << abs (ans_by_expansion - ans_by_function) << "" ; return 0; } |
输出:
The answer by function for Regular_Modified_Bessel_Function (0.000000000000000, 2.798465000000000) = 4.152234090041574 ans_by_expansion till term k = 0 is 1.000000000000000 ans_by_expansion till term k = 1 is 2.957851589056250 ans_by_expansion till term k = 2 is 3.916147300248771 ans_by_expansion till term k = 3 is 4.124614053687001 ans_by_expansion till term k = 4 is 4.150123238967278 ans_by_expansion till term k = 5 is 4.152120966924739 ans_by_expansion till term k = 6 is 4.152229612892962 ans_by_expansion till term k = 7 is 4.152233953968095 ans_by_expansion till term k = 8 is 4.152234086767796 ans_by_expansion till term k = 9 is 4.152234089977698 Absolute Error in answer by both the methods is = 0.000000000063876
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END