Skip to content

jvp returns incorrect tangent for 2-arg normalize #93

@sethaxen

Description

@sethaxen

For y=norm(x[, p]), if p is not provided, jvp produces the correct tangent vector (with the same shape as y), but if p is provided, it returns a scalar.

julia> x, Δx = [1.0, 2.0, 3.0], [0.3, 0.2, 0.1];

julia> p, Δp = 2.0, 0.5;

julia> normalize(x)
3-element Array{Float64,1}:
 0.2672612419124244
 0.5345224838248488
 0.8017837257372732

julia> jvp(central_fdm(5, 1), normalize, (x, Δx)) # 1-arg looks good
3-element Array{Float64,1}:
  0.061088283865706784
  0.015272070966444149
 -0.0305441419328158

julia> normalize(x, p)
3-element Array{Float64,1}:
 0.2672612419124244
 0.5345224838248488
 0.8017837257372732

julia> jvp(central_fdm(5, 1), normalize, (x, Δx), (p, Δp)) # um, what?
0.08883239652055

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions