Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C++

ฟังก์ชัน beta(), betaf() และ betal() ใน C++ STL


ฟังก์ชัน beta(), betaf() และ betal() เป็นฟังก์ชันในตัวในไลบรารีเทมเพลตมาตรฐานของ C++ ฟังก์ชันเหล่านี้ใช้ในการคำนวณฟังก์ชันเบต้าของจำนวนจริงบวกสองจำนวน

ฟังก์ชันเบต้า() , betaf() และ betal() เป็นฟังก์ชันในตัวในไลบรารีเทมเพลตมาตรฐานของ C++ ฟังก์ชันเหล่านี้ใช้ในการคำนวณฟังก์ชันเบต้าของจำนวนจริงบวกสองจำนวน

$B(x,y)=\int_{0}^{1}t^{(x-1)}(1-t)^{(y-1)}dt$

เบต้า()

ฟังก์ชัน beta() ใช้เพื่อจัดการกับค่าของ data type double เช่น ยอมรับพารามิเตอร์ของ double type และ return เป็น double value

ไวยากรณ์

double beta(double x, double y)

พารามิเตอร์

x is a double value that gives the value of x in the beta function.
y is a double value that gives the value of y in the beta function.

ส่งกลับค่าสองเท่าซึ่งเป็นผลลัพธ์ของฟังก์ชันเบต้า

ตัวอย่าง

#include <bits/stdc++.h>
using namespace std;
int main(){
   double x = 4.93;
   double y = 5.01;
   double result = beta(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

ผลลัพธ์

B(4.93 , 5.01) = 0.00166054

betaf()

ฟังก์ชัน betaf() ใช้เพื่อจัดการกับค่าของประเภทข้อมูล float เช่น ยอมรับพารามิเตอร์ของประเภท float และผลตอบแทนเป็นค่า float

ไวยากรณ์

float beta(float x, float y

พารามิเตอร์

x is a float value that gives the value of x in the beta function.
y is a float value that gives the value of y in the beta function.

คืนสินค้า ค่าทศนิยมซึ่งเป็นผลลัพธ์ของฟังก์ชันเบต้า

ตัวอย่าง

#include <bits/stdc++.h>
using namespace std;
int main(){
   float x = 0.31;
   float y = 3.99;
   float result = betaf(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

ผลลัพธ์

B(0.31 , 3.99) = 1.93395

betal()

ฟังก์ชัน betal() ใช้เพื่อจัดการกับค่าของประเภทข้อมูล long double เช่น ยอมรับพารามิเตอร์ของประเภท long double และส่งกลับค่า long double

ไวยากรณ์

เบต้าคู่แบบยาว (long double x, long double y)

พารามิเตอร์

x is a long double value that gives the value of x in the beta function.
y is a long double value that gives the value of y in the beta function.

คืนสินค้า ค่ายาวสองเท่าซึ่งเป็นผลลัพธ์ของฟังก์ชันเบต้า

ตัวอย่าง

#include <bits/stdc++.h>
using namespace std;
int main(){
   long double x = 3453.35451;
   long double y = 9862.89651;
   long double result = betaf(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

ผลลัพธ์

B(3453.35 , 9862.9) = 4.39947e-3312