COHERENT manpages
This page displays the COHERENT manpage for cosh() [Calculate hyperbolic cosine].
List of available manpages
Index
cosh() -- Mathematics Function (libm) Calculate hyperbolic cosine #include <math.h> double cosh(radian) double radian; cosh() calculates the hyperbolic cosine of radian, which is in radian measure. Example The following example uses cosh() to compute the height and time to impact of a falling object. Assume that an object is acted on both by gravity and by air resistance propotional to v2, where v is its velocity. When p is the proptionality constant for the resistance of air, the object's height after t seconds is given by the formula y = y0 -1/p*ln(cosh(t*sqrt(p*g))) and its time to reach the ground is given by the formula: t = 1/sqrt(p*g)*log(exp(p*y0)+sqrt(exp(2*p*y0)-1)) Assuming that g = 32 ft/s2 the example computes an object's height after t seconds and the total time in seconds that it will take to reach the ground. It was written by Sanjay Lal (sanjayl@tor.comm.mot.com): #include <stdio.h> #include <math.h> #include <stdlib.h> main () { float height, init_height, resistance, time_to_hit, g; int i; char buffer[50]; g = 32.0; printf("Enter initial height, in feet: "); fflush(stdout); init_height = atof(gets(buffer)); resistance = 0.0; while (resistance > 0.005 || resistance < 0.001) { printf("Enter air resistance (0.001 to 0.005): "); fflush(stdout); resistance = atof(gets(buffer)); } time_to_hit = 1.0/sqrt(resistance*g) * log(exp(resistance*init_height) + sqrt(exp(2*resistance*init_height)-1)); printf("Initial height: %1.0f\n", init_height); printf("Air resistance: %1.3f\n", resistance); printf("Time for object to hit the ground: %1.3f seconds\n", time_to_hit); /* countdown to impact */ for (i = 2; ; i++) { height = init_height - (1.0/resistance*log(cosh(sqrt(resistance*g)*(double)i))); if (height < 0) { printf("BOOM!\n"); exit(EXIT_SUCCESS); } else printf("Height after %i seconds: %1.3f feet\n", i, height ); } } See Also libm, cos() ANSI Standard, §7.5.3.1 POSIX Standard, §8.1 Diagnostics When overflow occurs, cosh() returns a huge value that has the same sign as the actual result.