beta(),betaf()和betal()是C++ STL中的內置函數,用于計算兩個正實數值的beta函數。該函數將兩個變量x和y作為輸入,并返回x和y的beta函數。 x和y的Beta函數(也稱為第一類Euler積分)可以定義為:
用法
double beta(double x, double y)or long double betal(long double x, long double y)or float betaf(float x, float y)
參數:該函數接受兩個強制性參數x和y,它們指定浮點或整數類型的值。參數可以是double,double或float,float或long double,long double數據類型。
返回值:該函數返回x和y的beta函數的值。返回類型取決于傳遞的參數。與參數相同。
注意:該函數在C++ 17(7.1)及更高版本中運行。
以下示例程序旨在說明beta(),betaf()和betal()函數:
// C++ program to illustrate the three functions // Being a special function, beta is only guaranteed // to be in cmath if the user defines //? __STDCPP_WANT_MATH_SPEC_FUNCS__ before including // any standard library headers. #define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 #include <bits/stdc++.h> using namespace std; ??int main() { ????// Computes the beta function of 5 and 4 and print it ????// If provided arguments are not of type double ????// they are implicitly type-casted to the higher type. ??????// first example of beta() ????cout << beta(5, 4) << "\n"; ??????// second example of betaf() ????cout << betaf(10.0, 4.0) << "\n"; ??????// third example of betal() ????cout << betal(10.0, 6.7) << "\n"; ????return 0; }
輸出:
0.003571430.000349651.65804e-005
Beta函數的應用:用于計算二項式系數。以beta函數表示的二項式系數可以表示為:
以上關系可用于計算二項式系數。圖示如下:
// C++ program to print the pascal triangle // Being a special function, beta is only guaranteed // to be in cmath if the user defines //? __STDCPP_WANT_MATH_SPEC_FUNCS__ before including // any standard library headers. #define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 #include <bits/stdc++.h> #include <cmath> using namespace std; ??// Function to return the value of binomial Coefficient double binomialCoefficient(int n, int k) { ????// Calculate the value of nCr using above formula. ????double ans = 1 / ((n + 1) * beta(n - k + 1, k + 1)); ????return ans; } // Driver Code int main() { ????// Print the binomial Coefficient nCr where n=5 and r=2 ????cout << binomialCoefficient(5, 2) << "\n"; ??????return 0; }
輸出:
10
本文由 貴州做網站公司 整理發布,部分圖文來源于互聯網,如有侵權,請聯系我們刪除,謝謝!
網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...
在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...
在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...
蘋果手機下載了91手機娛樂門戶怎么用?91wii論壇怎樣注冊???從91單機網下了個游戲,結果把我的主頁改了,怎么改回來啊,剛才只要一打開360瀏覽器,就會提示有病毒?這是個毒藥站。360報毒已久。以下是解決步驟。打開360衛士-網盾-瀏覽器修復或直接點擊系統修復。順便說一句,我要再罵那垃圾了。我也受了他的苦...
蘋果手機反復出現Exit Safe Mode再怎么解決?EXITSAFEMODE(退出安全模式啟動)是由于軟件啊錯誤的什么原因造成,在iphone4s電腦屏幕正上方的在中間那個地方出現EXITSAFEMODE黃色字體??梢越鉀Q的快速方法:①找到智能手機上的sileo這個軟件(點擊進去)②進去然后能找到管理管理(右下方倒數第二個“管理管理”)③可以找到iokit(再點擊“軟件是包”再找到“cores...
阿迪達斯麥迪籃球鞋一共有幾代?阿迪達斯麥迪已經五代了。麥迪5最突出的特點就是極具視覺沖擊力的阿迪達斯ForMotion?技術。這項技術讓玩家擁有非凡的控制力,可以自發地適應地面條件;在運動鞋的內大底上,也有五個ForMotion?技術單位,以確保最大限度地接觸地面。不管你跑得多快或轉彎多猛,對運動來說?能讓玩家安心。阿迪達斯麥迪籃球鞋一共有幾代?麥迪籃球鞋有6代簽名鞋:第一代2002年,阿迪達斯發...