Skip to content

StackOverflowError with complex sqrt #324

Open
@fmeirinhos

Description

@fmeirinhos

When differentiating over a complex sqrt

x0 = 5
ForwardDiff.derivative(x -> sqrt(1im * x), x0)

a StackOverflowError is encountered.

StackOverflowError:
Stacktrace:
[1] sqrt(::Complex{ForwardDiff.Dual{ForwardDiff.Tag{##20#21,Int64},Float16,1}}) at ./complex.jl:416 (repeats 80000 times)

The stacktrace points to the following declaration
sqrt(z::Complex) = sqrt(float(z))

I have found similar issues #111 #196 #239, but I don't see how I can fix this problem.

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