Skip to content
DeepForgeby svx
All problems
EasyCalculusca-337

Tanh Second Derivative Vector

Problem

The hyperbolic tangent has derivative 1 - tanh(z)^2 and second derivative -2 * tanh(z) * (1 - tanh(z)^2).

Given the values z, return the second derivative list.

Hint

Differentiate t' = 1 - t^2 and use the chain rule with t' again.

Test cases

case 1
in: [[0,1,-1]]
expected: [0,-0.6397000084492246,0.6397000084492246]
case 2
in: [[2,-2]]
expected: [-0.13621868742711296,0.13621868742711296]
case 3
in: [[0.5,3]]
expected: [-0.7268619813835873,-0.019634494363042477]
Starter codePython
def tanh_second_derivative(values):
    # Your code here
    pass

3 test cases · run your code against them in the editor