Skip to content

[Docs] [AutoDiff] Fix typos in differentiable programming manifesto. #28739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/DifferentiableProgramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -1696,48 +1696,49 @@ public protocol ElementaryFunctions {
...
}

public extension ElementaryFunctions where Self: Differentiable, Self == Self.TangentVector {
public extension ElementaryFunctions
where Self: Differentiable & FloatingPoint, Self == Self.TangentVector {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the FloatingPoint requirement here is unfortunate - it's necessary for operations like * and /.
No general protocol defines these operations yet.

@inlinable
@derivative(of: sqrt)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
(sqrt(x), { dx in (1 / 2) * (1 / sqrt(x)) * dx })
}

@inlinable
@derivative(of: cos)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
(cos(x), { dx in -sin(x) * dx })
}

@inlinable
@derivative(of: asinh)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
(asinh(x), { dx in 1 / (1 + x * x) * dx })
}

@inlinable
@derivative(of: exp)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
let ret = exp(x)
return (ret, { dx in ret * dx })
}

@inlinable
@derivative(of: exp10)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
let ret = exp10(x)
return (ret, { dx in exp(10) * ret * dx })
}

@inlinable
@derivative(of: log)
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) { dx in
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) { dx in
(log(x), { 1 / x * dx })
}

@inlinable
@derivative(of: pow)
func _(_ x: Self, _ y: Self) -> (value: Self, differential: @differential(linear) (Self, Self) -> Self) {
static func _(_ x: Self, _ y: Self) -> (value: Self, differential: @differentiable(linear) (Self, Self) -> Self) {
(pow(x, y), { (dx, dy) in
let l = y * pow(x, y-1) * dx
let r = pow(x, y) * log(x) * dy
Expand Down