How to use the cosh() function to get the hyperbolic cosine of a number in Rust

1 Answer

0 votes
fn main() {
    println!("cosh(-1) = {}", f64::cosh(-1.0));
    println!("cosh(1) = {}", f64::cosh(1.0));
    println!("cosh(0) = {}", f64::cosh(0.0));
    println!("cosh(-0) = {}", f64::cosh(-0.0));
    println!("cosh(0.9) = {}", f64::cosh(0.9));
    println!("cosh(PI) = {}", f64::cosh(std::f64::consts::PI));
    println!("cosh(PI * 2) = {}", f64::cosh(std::f64::consts::PI * 2.0));
    println!("cosh(PI / 2) = {}", f64::cosh(std::f64::consts::PI / 2.0));
    println!("cosh(PI / 3) = {}", f64::cosh(std::f64::consts::PI / 3.0));
}

    
    
/*
run:
 
cosh(-1) = 1.5430806348152437
cosh(1) = 1.5430806348152437
cosh(0) = 1
cosh(-0) = 1
cosh(0.9) = 1.4330863854487745
cosh(PI) = 11.591953275521519
cosh(PI * 2) = 267.7467614837482
cosh(PI / 2) = 2.5091784786580567
cosh(PI / 3) = 1.600286857702386
 
*/

 



answered Aug 11, 2024 by avibootz
...