Activation Function Calculator
Compute outputs and derivatives for neural network activation functions.
Function Parameters
Note: Derivatives are useful for backpropagation during training.
Output f(0.5)
0.622459
Range: (0, 1)
Function Details
f(x) = 1 / (1 + e^(-x))
Smooth, differentiable function that squashes values between 0 and 1
What the Activation Function Calculator Does
The activation function calculator evaluates a single neuron's nonlinearity for any input value x and instantly returns both the function output f(x) and its derivative f'(x). Activation functions are the heart of every neural network: they introduce the nonlinearity that lets deep learning models approximate complex, non-linear relationships. Without them, stacking many linear layers would collapse into a single linear transformation, no matter how deep the network was.
This calculator supports the eight activation functions used most often in modern deep learning: sigmoid, tanh, ReLU, Leaky ReLU, ELU, softplus, Swish (SiLU), and GELU. For each one you supply an input value x, and for the parameterized functions (Leaky ReLU and ELU) you also supply an alpha that controls the negative-region slope. The tool reports the output, the derivative, the closed-form formula, and the valid output range.
Why does the derivative matter? Because training a neural network with backpropagation requires the gradient of every activation. During the backward pass, the chain rule multiplies the derivative of each activation by the incoming gradient. If those derivatives are tiny across many layers, gradients shrink toward zero and learning stalls โ the classic vanishing gradient problem. Sigmoid and tanh saturate at their extremes, producing near-zero derivatives, which is exactly why ReLU and its relatives became the default in deep networks. Use this activation function calculator to build intuition for where each function saturates and where it carries a healthy gradient.
Activation Function Formulas and Derivatives
Each activation maps a real-valued input to an output, and each has a corresponding derivative used during backpropagation. The table below lists every function this calculator supports, its forward formula, its derivative, and its output range. These are the exact formulas the calculator evaluates in JavaScript.
| Function | Output f(x) | Range |
|---|---|---|
| Sigmoid | 1 / (1 + e^(-x)) | (0, 1) |
| Tanh | tanh(x) | (-1, 1) |
| ReLU | max(0, x) | [0, +inf) |
| Leaky ReLU | x if x > 0, else αx | (-inf, +inf) |
| ELU | x if x > 0, else α(e^x - 1) | (-α, +inf) |
| Softplus | ln(1 + e^x) | (0, +inf) |
| Swish (SiLU) | x · sigmoid(x) | (-inf, +inf) |
| GELU | 0.5x(1 + tanh(√(2/π)(x + 0.044715x³))) | (-inf, +inf) |
Notice that sigmoid and tanh both saturate: as x grows large in magnitude, the curve flattens and the derivative approaches zero. The sigmoid derivative peaks at just 0.25 (at x = 0), so gradients are attenuated even in the best case. ReLU, by contrast, has a derivative of exactly 1 for all positive inputs and 0 for negative inputs, which preserves gradient magnitude on the positive side but can cause "dying ReLU" units that never activate again. Leaky ReLU and ELU address this by keeping a small nonzero slope (governed by alpha) on the negative side. Swish and GELU are smooth, non-monotonic functions that have become standard in transformer architectures because they tend to train more stably than ReLU at scale.
Sigmoid Activation and Its Derivative
Where:
- x= The input value (the pre-activation, often a weighted sum z = wยทx + b)
- f(x)= The activation output, squashed into the open interval (0, 1)
- f'(x)= The derivative used in backpropagation; peaks at 0.25 when x = 0
- e= Euler's number, approximately 2.71828
How to Choose an Activation Function
Selecting the right activation function is one of the most consequential architectural decisions in deep learning, and this activation function calculator helps you compare candidates side by side. The choice depends on the layer type, the network depth, and the training stability you observe.
Hidden layers in deep networks: ReLU remains a strong default because it is cheap to compute and avoids vanishing gradients on the positive side. If you see many dead units (neurons stuck outputting zero), switch to Leaky ReLU with a small alpha such as 0.01, or to ELU, which produces smooth negative outputs and tends to push mean activations closer to zero.
Transformers and large language models: GELU and Swish/SiLU dominate. GELU is used in BERT and the GPT family; it weights each input by the probability that it is greater than a standard normal sample, which behaves like a smooth, probabilistic gate. Swish, discovered through automated search, often matches or beats GELU and is used in EfficientNet and many vision models.
Output layers: Use sigmoid to produce a probability for binary classification, or for the final gate in recurrent units like LSTMs. Use tanh when you want a zero-centered output between -1 and 1, common in recurrent networks and some generative models. For multi-class probabilities you would instead use softmax, which this calculator does not cover because it acts over a vector rather than a scalar.
A practical workflow: start with ReLU or GELU in hidden layers, monitor the gradient flow and dead-unit fraction, and only swap activations if you see saturation or instability. Plug representative pre-activation values into this tool to confirm that your chosen function keeps a useful derivative across the range your network actually produces. Because the derivative directly scales the gradient, an activation that saturates over your typical input range will slow learning regardless of how well-tuned the rest of the model is.
Saturation and the Vanishing Gradient Problem
The vanishing gradient problem is the single biggest reason the field moved away from sigmoid and tanh in deep hidden layers, and it is easy to see why using this activation function calculator. When you evaluate sigmoid at a large input such as x = 8, the output is essentially 1 and the derivative is roughly 0.0003. Multiply a handful of such tiny derivatives together through the chain rule, and the gradient reaching the earliest layers becomes negligible. Those layers stop learning.
The sigmoid derivative is bounded above by 0.25, and the tanh derivative is bounded above by 1.0 but only exactly at the origin. Both functions saturate symmetrically as inputs move away from zero. ReLU sidesteps this by keeping a derivative of exactly 1 for every positive input, so gradients pass through unattenuated on the active side. The trade-off is that ReLU's derivative is exactly 0 for negative inputs, which is what gives rise to dying ReLU units.
This is precisely the motivation for the smoother modern activations. Softplus is a smooth approximation of ReLU whose derivative is the sigmoid function, so it never has a hard zero region. ELU and Leaky ReLU retain a nonzero negative slope. Swish and GELU are smooth and non-monotonic, dipping slightly below zero for moderate negative inputs before flattening, which empirically improves optimization in very deep networks. Use the calculator to probe inputs like x = -3, x = 0, and x = 3 for each function and watch how the derivative behaves; that hands-on comparison is the fastest way to understand which activations preserve gradient signal and which ones throttle it.
How to Use This Calculator
Using the activation function calculator takes three quick steps. First, enter the input value (x) โ this is the pre-activation, typically the weighted sum of inputs plus a bias that a neuron receives before the nonlinearity is applied. Second, select an activation function from the dropdown: sigmoid, tanh, ReLU, Leaky ReLU, ELU, softplus, Swish, or GELU. Third, if you chose Leaky ReLU or ELU, set the alpha parameter that controls the negative-region slope (a common default is 0.01 for Leaky ReLU and 1.0 for ELU).
The calculator then displays four things: the output f(x) shown to six decimal places, the derivative f'(x) used in backpropagation, the closed-form formula for the chosen function, and its valid output range. Because results update instantly, you can sweep x across positive and negative values to visualize the shape of the curve and the behavior of its gradient.
This makes the tool useful for several audiences. Students learning deep learning can verify hand-computed activations and derivatives. Practitioners debugging a model can check whether a layer's typical pre-activation values land in a saturated region. Interviewers and candidates can confirm textbook values for ReLU, sigmoid, and GELU. Whatever your goal, the activation function calculator gives you exact, reproducible numbers that match the formulas used inside real neural network frameworks.
Worked Examples
Sigmoid at x = 0.5
Problem:
Compute the sigmoid output and derivative for an input of x = 0.5.
Solution Steps:
- 1Apply the forward formula: f(0.5) = 1 / (1 + e^(-0.5)).
- 2Evaluate e^(-0.5) = 0.606531, so the denominator is 1.606531 and f(0.5) = 1 / 1.606531 = 0.622459.
- 3Apply the derivative formula f'(x) = f(x)(1 - f(x)) = 0.622459 ร (1 - 0.622459) = 0.622459 ร 0.377541.
Result:
f(0.5) = 0.622459 and f'(0.5) = 0.235004. The output sits between 0 and 1 as expected for sigmoid.
Tanh at x = 1
Problem:
Find the tanh output and its derivative for x = 1.
Solution Steps:
- 1Apply the forward formula: f(1) = tanh(1) = 0.761594.
- 2The tanh derivative is f'(x) = 1 - tanh(x)^2 = 1 - (0.761594)^2.
- 3Compute (0.761594)^2 = 0.580026, so f'(1) = 1 - 0.580026 = 0.419974.
Result:
f(1) = 0.761594 and f'(1) = 0.419974. Tanh is zero-centered and its derivative is already well below the maximum of 1.0 it reaches at x = 0.
Leaky ReLU at x = -2 with alpha = 0.01
Problem:
Evaluate Leaky ReLU and its derivative for a negative input x = -2 with negative slope alpha = 0.01.
Solution Steps:
- 1Since x = -2 is not greater than 0, use the negative branch: f(x) = alpha ร x = 0.01 ร (-2).
- 2Compute f(-2) = -0.02.
- 3The derivative on the negative side is simply alpha, so f'(-2) = 0.01.
Result:
f(-2) = -0.02 and f'(-2) = 0.01. The small nonzero slope keeps a usable gradient, preventing the dying ReLU problem.
ELU at x = -1 with alpha = 1.0
Problem:
Compute ELU and its derivative for x = -1 with alpha = 1.0.
Solution Steps:
- 1Since x = -1 is not greater than 0, use the negative branch: f(x) = alpha ร (e^x - 1) = 1.0 ร (e^(-1) - 1).
- 2Evaluate e^(-1) = 0.367879, so f(-1) = 1.0 ร (0.367879 - 1) = -0.632121.
- 3The negative-side derivative is f'(x) = alpha ร e^x = 1.0 ร 0.367879 = 0.367879.
Result:
f(-1) = -0.632121 and f'(-1) = 0.367879. ELU produces a smooth negative output that saturates toward -alpha as x decreases.
Tips & Best Practices
- โUse ReLU or GELU as your default hidden-layer activation, then change only if you observe saturation or dead units.
- โRemember the sigmoid derivative maxes out at just 0.25, which limits gradient flow even at its best.
- โSet Leaky ReLU alpha around 0.01 to keep a small gradient for negative inputs and avoid dying units.
- โChoose tanh over sigmoid in hidden layers when you want zero-centered outputs and stronger gradients.
- โUse sigmoid in the output layer for binary classification probabilities, not in deep hidden layers.
- โProbe inputs like x = -3, 0, and 3 in this calculator to see exactly where each function saturates.
- โPrefer GELU or Swish for transformer and large language model architectures.
- โMatch your network's typical pre-activation range to a function that keeps a healthy nonzero derivative there.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Activation Function Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various