Avatar
Avatar
ProfFan
@swift-main -enable-experimental-forward-mode-differentiation import _Differentiation @differentiable(reverse) func x_2(_ x: Double) -> Double { return x * x } let x: Double = 1.0 let grad_x = gradient(of: { (x: Double) in x_2(x) })(x) print(grad_x)
swiftNightly BOT 10/23/2023 7:48 PM
2.0