C acosh () - C Standardbibliotek

Funktionen acosh () returnerar bågens hyperboliska cosinus (invers hyperbolisk cosinus) för ett tal i radianer.

Den acosh()funktionen tar ett enda argument (x ≧ 1), och returnerar arcus hyperbolisk cosinus i radianer.

Den acosh()funktionen finns i header-fil.

acosh () Prototyp

 dubbel acosh (dubbel x);

För att hitta båghyperbolisk cosinus av typen int, floateller long double, kan du uttryckligen konvertera typen till att doubleanvända cast-operator.

int x = 0; dubbelt resultat; resultat = acosh (dubbel (x));

Också, två funktioner acoshf () och acoshl () infördes i C99 till arbetet specifikt med typen floatoch long doublerespektive.

float acoshf (float x); lång dubbel acoshl (lång dubbel x);

acosh () Parameter och returvärde

Den acosh()funktionen tar ett enda argument som är större än eller lika med 1.

Parameter Beskrivning
dubbelt värde Nödvändig. Ett dubbelt värde större än eller lika med 1 (x ≧ 1).

acosh () Returvärde

De acosh()funktioner returnerar ett tal större än eller lika med 0 i radianer. Om det skickade argumentet är mindre än 1 (x <1) returnerar funktionen NaN (inte ett tal).

Parameter (x) Returvärde
x ≧ 1 ett tal större än eller lika med 0 (i radianer)
x <1 NaN (inte ett nummer)

Exempel 1: acosh () -funktion med olika parametrar

 #include #include int main() ( // constant PI is defined const double PI = 3.1415926; double x, result; x = 5.9; result = acosh(x); printf("acosh(%.2f) = %.2lf in radians", x, result); // converting radians to degree result = acosh(x)*180/PI; printf("acosh(%.2f) = %.2lf in degrees", x, result); // parameter not in range x = 0.5; result = acosh(x); printf("acosh(%.2f) = %.2lf", x, result); return 0; )

Produktion

 acosh (5,90) = 2,46 i radianer acosh (5,90) = 141,00 i grader acosh (0,50) = nan 

Exempel 2: acosh () för INFINITY och DBL_MAX

 #include #include #include int main() ( double x, result; // maximum representable finite floating-point number x = DBL_MAX; result = acosh(x); printf("Maximum value of acosh() in radians = %.3lf", result); // Infinity x = INFINITY; result = acosh(x); printf("When infinity is passed to acosh(), result = %.3lf", result); return 0; ) 

Möjlig utgång

 Maximalt värde på acosh () i radianer = 710.476 När oändligheten överförs till acosh (), result = inf 

Här DBL_MAXdefinieras i float.hrubrikfilen det maximala representerbara ändliga flytpunkten. Och INFINITYdefinierat i math.här ett konstant uttryck som representerar positiv oändlighet.

Exempel 3: funktionen acoshf () och acoshl ()

 #include #include int main() ( float fx, facosx; long double lx, ldacosx; // arc hyperbolic cosine of type float fx = 5.5054; facosx = acoshf(fx); // arc hyperbolic cosine of type long double lx = 5.50540593; ldacosx = acoshl(lx); printf("acoshf(x) = %f in radians", facosx); printf("acoshl(x) = %Lf in radians", ldacosx); return 0; ) 

Produktion

 acoshf (x) = 2.390524 i radianer acoshl (x) = 2.390525 i radianer 

Intressanta artiklar...