Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
python
numpy
communitycreator

# What is the numpy.cosh() function in Python? Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

### Overview

The numpy.cosh() function in Python is used to compute, element-wise, the hyperbolic cosine of an input array x.

Mathematically:

Cosh(x) = $\frac{(e^x) + (1/e^x)}{2}$

### Syntax

numpy.cosh(x, /, out=None, *, where=True)


### Parameter values

The numpy.cosh() function takes the following parameter values:

• x: This represents the input array. It is required for the function to work.
• out: This represents a location where the result is stored. It is an optional parameter value.
• where (optional): This is the condition over which the input is broadcast. At a given location where this condition is True, the resulting array will be set to the ufunc result. Otherwise, the resulting array will retain its original value. This is an optional parameter value.
• **kwargs: This represents other keyword arguments. This is also an optional parameter value.

### Return type

The numpy.cosh() function returns the corresponding hyperbolic cosine values of each element in a given array.

### Code example

import numpy as np

# creating an array
x = np.array([30, 45, 60, 90, 180])

# taking the hyperbolic cosine
myarray = np.cosh(x)

print(myarray)
Implementing the numpy.cosh() function

### Code explanation

• Line 1: We import the numpy module.
• Line 4: We create an array x, using the array() method.
• Line 7: We implement the np.cosh() function on the array. Then, we assign the result to a variable called myarray.
• Line 9: We print the variable myarray to the console.

RELATED TAGS

function
python
numpy
communitycreator

CONTRIBUTOR Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Learn in-demand tech skills in half the time 