ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Hyperbolic tangent derivative

The derivative of tanh(x) is 1−tanh²(x). It is largest at zero and approaches zero in the saturated tails. Reusing the forward output in the backward pass avoids an additional tanh evaluation.

Implementation mathematicsSource recovered; runtime not executed
Learn with the Atlas

Understand the update

Build intuition for derivatives, direction, and learning steps.

Open guided lesson
gh-eq-c672857b7c3842cbsource-comment-equation
Tanh:z=tanh(x),dz/dx=1−tanh2(x)Tanh: z = tanh(x), dz/dx = 1 - tanh^2(x)

Read the equation

The derivative of tanh(x) is 1−tanh²(x). It is largest at zero and approaches zero in the saturated tails. Reusing the forward output in the backward pass avoids an additional tanh evaluation.

Terms & definitions

TermMeaning in this source
x

Activation input

z

tanh output

How it works

Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.

Assumptions & limits

Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.

Original context

Read the surrounding source passage
    z->backward_fn = [x, y, z]() {
        x->grad += z->grad / y->value;
        y->grad -= z->grad * x->value / (y->value * y->value);
    };
    return tape.record(z);
}

// Tanh: z = tanh(x), dz/dx = 1 - tanh^2(x)
inline GradNodePtr tanh_op(GradNodePtr x, TapeRecorder& tape) {
    double t = std::tanh(x->value);
    auto z = std::make_shared<GradNode>(t);
    z->inputs = {x};
    z->backward_fn = [x, z, t]() {
        x->grad += z->grad * (1.0 - t * t);
    };
    return tape.record(z);
}
Exact original notation
Tanh: z = tanh(x), dz/dx = 1 - tanh^2(x)

Related builds

Sources & provenance

Search equations, builds, manuscript text, and recovered sources.