Calculate cosine of a complex value.
Calculate cosine of a double value.
complex cos( complex z )
double cos( double x )
The cosine
The cos function returns the cosine of x.
EX1
void cos_ex1() { complex cc(0.5, 0.8); out_complex("cos = ", cos(cc)); //Result is "cos = 1.173710-0.425781i" }
EX2
//This program computes and displays the cosine of x. void cos_ex2() { double vv; vv = cos(-3*PI); out_double("cos(-3*PI)=", vv); //output should be cos(-3*PI)=-1 ASSERT( is_equal(vv, -1) ); vv = cos(0); out_double("cos(0)=", vv); //output should be cos(0)=1 ASSERT( is_equal(vv, 1) ); vv = cos(15.5); out_double("cos(15.5)=", vv); //cos(15.5)=-0.97845 ASSERT( is_equal(round(vv,5), -0.97845) ); }
acos
origin.h