pig tutorial - apache pig tutorial - Apache Pig - COSH() - pig latin - apache pig - pig hadoop



What is cosh() function?

  • The inverse hyperbolic functions are the area hyperbolic sine "arsinh" (also denoted "sinh−1", "asinh" or sometimes "arcsinh") and so on.
  • Just as the points (cos t, sin t) form a circle with a unit radius, the points (cosh t, sinh t) form the right half of the equilateral hyperbola.
 cosh function in apache

Learn apache pig - apache pig tutorial - cosh function in apache - apache pig examples - apache pig programs

COSH() function in Apache Pic

  • The COSH() function of Pig Latin is used to compute the hyperbolic cosine of a specified expression.

Syntax:

grunt> COSH(expression)

Example:

  • Ensure that we have a file named wikitechy_math.txt in the HDFS directory /pig_data/.
  • This file contains integer and floating point values as shown below.

Wikitechy_math.txt

5 
16 
9 
2.5 
5.9 
3.1	
  • You have loaded this file nito Pig with a relation named math_data as given below.
grunt> math_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_math.txt' USING PigStorage(',')
   as (data:float);
  • You compute the hyperbolic cosine values of the contents of the wikitechy_math.txt file using COSH() function as shown below.
grunt> cosh_data = foreach math_data generate (data), COSH(data);
  • Above statement stores the result in the relation named cosh_data.

Verification:

Now you can the contents of the relation using the Dump operator as given below.

grunt> Dump cosh_data; 

Output:

The output shows that the result in the file>cosh_data.

(5.0,74.20994852478785) 
(16.0,4443055.260253992) 
(9.0,4051.5420254925943) 
(2.5,6.132289479663686) 
(5.9,182.52012106128686) 
(3.1,11.121499185584959)

Related Searches to Apache Pig - COSH()