Main Content


CORDIC-based approximation of sigmoid activation

Since R2023b



Y = cordicsigmoid(X) computes the sigmoid activation of the numeric input X by applying the sigmoid transfer function. All values in Y are between 0 and 1.

To optimize the numerics for fixed-point input, the cordicsigmoid function implements the sigmoid activation using a CORDIC-based approximation of hyperbolic tangent, without computing the exponential.



Y = cordicsigmoid(X,N) additionally specifies the maximum shift value N in the CORDIC iterations. For fixed-point input X, the maximum shift value N is limited by the word length minus one.


collapse all

x = fi(linspace(-10,10,100));
y = cordicsigmoid(x);

Plot of output of cordicsigmoid function.

x = -10:0.2:10;
for n = 5:5:20
    y = cordicsigmoid(x,n);
    hold on;
legend('N = 5','N = 10','N = 15','N = 20')

Plot of output of cordicsigmoid function for specified maximum shift value in CORDIC iterations.

Input Arguments

collapse all

Input data, specified as a scalar, vector, matrix, or multidimensional array.

When X is fixed point, then it must use binary-point scaling.

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

Sigmoid activations, returned as a vector. All values in Y are between 0 and 1.

When the input X is a floating-point data type, then the output Y has the same data type as the input X. When the input X is a fixed-point data type, then the output Y has a signed, fixed-point data type with the same word length as X and fraction length equal to two less than the word length.

More About

collapse all


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.


[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.

[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” In Proceedings of the May 18-20, 1971 Spring Joint Computer Conference, 379–386.

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

Extended Capabilities

Version History

Introduced in R2023b

See Also

| (Deep Learning Toolbox)