Hàm cosh() trả về hyperbolic cosine (cosin hyperbolic) của góc cho bằng radian. Hàm có sẵn trong C++ STL.
Cú pháp:
cosh(var)
Tham số var kiểu float, double, long double. Trả về hyperbolic cosine.
Ví dụ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 5, ans;
ans = cosh(d);
cout << "cosh(" << d << ") = " << ans << endl;
return 0;
}
Kết quả
cosh(5) = 74.2099
Khởi tạo, tính cosh(), in kết quả.
double d = 5, ans;
ans = cosh(d);
cout << "cosh(" << d << ") = " << ans << endl;
Nhập độ, chuyển radian
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double degree = 60, ans;
degree = degree * 3.14159 / 180;
ans = cosh(degree);
cout << "cosh(" << degree << ") = " << ans << endl;
return 0;
}
Kết quả
cosh(1.0472) = 1.60029
Chuyển độ sang radian: nhân π/180. Sau đó tính cosh().
double degree = 60, ans;
degree = degree * 3.14159 / 180;
ans = cosh(degree);
cout << "cosh(" << degree << ") = " << ans << endl;