# cordicsinhcosh

CORDIC-based approximation of hyperbolic sine and cosine

Since R2023b

## Syntax

``[S,C] = cordicsinhcosh(X)``
``[S,C] = cordicsinhcosh(X,N)``

## Description

example

````[S,C] = cordicsinhcosh(X)` returns the hyperbolic sine (sinh) `S` and hyperbolic cosine (cosh) `C` of the elements in `X` using a CORDIC-based approximation. The `cordicsinhcosh` function operates element-wise on arrays. All angles are in radians. The function uses the maximum number of CORDIC iterations for the numeric type of `X`.```

example

````[S,C] = cordicsinhcosh(X,N)` additionally specifies the maximum shift value `N` in the CORDIC iterations. For fixed-point input `X`, the maximum shift value is limited by the word length minus one.```

## Examples

collapse all

```theta = fi(pi/4); [s,c] = cordicsinhcosh(theta)```
```s = 0.8688 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 14 ```
```c = 1.3248 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 14 ```

Compute the hyperbolic cosine of a double using a CORDIC-based approximation and specify the number of iterations the CORDIC kernel should perform. Plot the CORDIC approximation of the hyperbolic cosine with varying numbers of iterations.

```x = -1:0.01:1; for n = 5:5:20 [s,c] = cordicsinhcosh(x,n); plot(x,c); hold on; end legend('n = 5','n = 10','n = 15','n = 20')```

## Input Arguments

collapse all

Input angles in radians, specified as a scalar, vector, matrix, or multidimensional array. `X` must be a `double`, `single`, fixed-point `fi`, or scaled-double `fi`. If `X` is a fixed-point `fi` or scaled-double `fi`, then `X` must be signed and binary-point scaled.

If `X` is `double` or `single`, then `S` and `C` are `double` or `single`, respectively.

Data Types: `single` | `double` | `fi`

Maximum shift value in CORDIC iterations, specified as a real integer-valued scalar.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `fi`

## Output Arguments

collapse all

Hyperbolic sine (sinh), returned as a scalar, vector, matrix, or multidimensional array.

If `X` is `double` or `single`, then `S` and `C` are `double` or `single`, respectively.

If `X` is a fixed-point `fi` or scaled-double `fi`, then `S` and `C` have the same word length as `X` and fraction length equal to two less than the word length.

Hyperbolic cosine (cosh), returned as a scalar, vector, matrix, or multidimensional array.

If `X` is `double` or `single`, then `S` and `C` are `double` or `single`, respectively.

If `X` is a fixed-point `fi` or scaled-double `fi`, then `S` and `C` have the same word length as `X` and fraction length equal to two less than the word length.

## Limitations

• The `cordicsinhcosh` function returns an error if `X` is outside the domain of convergence for the CORDIC hyperbolic sine and cosine kernel. The domain of convergence is a function of the numeric type of `X` and the maximum CORDIC shift value `n`. The domain of convergence converges to around `[-1.1182, +1.1182]`. You can use the `fixed.cordic.hyperbolic.domainOfConvergence` function to compute the domain of convergence for a particular `X` and `n`.

collapse all

### CORDIC

CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see References). The CORDIC algorithm eliminates the need for explicit multipliers. Using CORDIC, you can calculate various functions such as sine, cosine, arcsine, arccosine, arctangent, and vector magnitude. You can also use this algorithm for divide, square root, hyperbolic, and logarithmic functions.

Increasing the number of CORDIC iterations can produce more accurate results but also increases the expense of the computation and adds latency.

## References

[1] Volder, Jack E. “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers. EC-8, no. 3 (Sept. 1959): 330–334.

[2] Andraka, Ray. “A Survey of CORDIC Algorithm for FPGA Based Computers.” In Proceedings of the 1998 ACM/SIGDA Sixth International Symposium on Field Programmable Gate Arrays, 191–200. https://dl.acm.org/doi/10.1145/275107.275139.

[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” In Proceedings of the May 18–20, 1971 Spring Joint Computer Conference, 379–386. https://dl.acm.org/doi/10.1145/1478786.1478840.

[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly, no. 5 (May 1983): 317–325. https://doi.org/10.2307/2975781.

## Version History

Introduced in R2023b