# Why is the strange type signature of sqrt so long?

**URL:** <https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541>\
**Category:** New to Julia\
**Created:** [December 21, 2019, 8:09am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541 "2019-12-21T08:09:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuxi.liu](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yuxi.liu](https://discourse.julialang.org/u/yuxi.liu)\
**Post date:** [December 21, 2019, 8:09am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/1 "2019-12-21T08:09:28Z")

</div>

I typed `methods(√)` and got, among other entries, this:

> sqrt(A:: **Union{DenseArray{#s627,2}, Base.ReinterpretArray{#s627,2,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{#s627,2,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, SubArray{#s627,2,A,I,L} where L where I\<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627\<:Complex** ) in LinearAlgebra at [D:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\dense.jl:747](file://D:/buildbot/worker/package\_win64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/dense.jl)

How could this possibly have been written?

---

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [December 21, 2019, 8:15am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/2 "2019-12-21T08:15:32Z")

</div>

Which Julia version do you have? On my v1.3, `sqrt` and `√` both look fine:

```julia
julia> methods(sqrt)
# 19 methods for generic function "sqrt":
[1] sqrt(a::Float16) in Base.Math at math.jl:1085
[2] sqrt(a::Complex{Float16}) in Base.Math at math.jl:1086
[3] sqrt(::Missing) in Base.Math at math.jl:1138
[4] sqrt(x::BigFloat) in Base.MPFR at mpfr.jl:580
[5] sqrt(x::BigInt) in Base.MPFR at mpfr.jl:587
[6] sqrt(z::Complex{#s66} where #s66<:AbstractFloat) in Base at complex.jl:478
[7] sqrt(z::Complex) in Base at complex.jl:502
[8] sqrt(x::Union{Float32, Float64}) in Base.Math at math.jl:492
[9] sqrt(x::Real) in Base.Math at math.jl:518
[10] sqrt(A::Union{DenseArray{#s627,2}, Base.ReinterpretArray{#s627,2,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{#s627,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{#s627,2,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627<:Real) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/dense.jl:734
[11] sqrt(A::Union{DenseArray{#s627,2}, Base.ReinterpretArray{#s627,2,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{#s627,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{#s627,2,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627<:Complex) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/dense.jl:747
[12] sqrt(A::UpperTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2457
[13] sqrt(A::UpperTriangular{T,S} where S<:AbstractArray{T,2}, ::Val{realmatrix}) where {T, realmatrix} in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2471
[14] sqrt(A::UnitUpperTriangular{T,S} where S<:AbstractArray{T,2}) where T in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2489
[15] sqrt(A::LowerTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2506
[16] sqrt(A::UnitLowerTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2507
[17] sqrt(A::Hermitian{#s626,S} where S<:(AbstractArray{#s627,2} where #s627<:#s626) where #s626<:Complex) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/symmetric.jl:883
[18] sqrt(A::Union{Hermitian{#s627,S}, Symmetric{#s627,S}} where S where #s627<:Real) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/symmetric.jl:873
[19] sqrt(D::Diagonal) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/diagonal.jl:555

julia> methods(√)
# 19 methods for generic function "sqrt":
[1] sqrt(a::Float16) in Base.Math at math.jl:1085
[2] sqrt(a::Complex{Float16}) in Base.Math at math.jl:1086
[3] sqrt(::Missing) in Base.Math at math.jl:1138
[4] sqrt(x::BigFloat) in Base.MPFR at mpfr.jl:580
[5] sqrt(x::BigInt) in Base.MPFR at mpfr.jl:587
[6] sqrt(z::Complex{#s66} where #s66<:AbstractFloat) in Base at complex.jl:478
[7] sqrt(z::Complex) in Base at complex.jl:502
[8] sqrt(x::Union{Float32, Float64}) in Base.Math at math.jl:492
[9] sqrt(x::Real) in Base.Math at math.jl:518
[10] sqrt(A::Union{DenseArray{#s627,2}, Base.ReinterpretArray{#s627,2,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{#s627,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{#s627,2,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627<:Real) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/dense.jl:734
[11] sqrt(A::Union{DenseArray{#s627,2}, Base.ReinterpretArray{#s627,2,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{#s627,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{#s627,2,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627<:Complex) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/dense.jl:747
[12] sqrt(A::UpperTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2457
[13] sqrt(A::UpperTriangular{T,S} where S<:AbstractArray{T,2}, ::Val{realmatrix}) where {T, realmatrix} in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2471
[14] sqrt(A::UnitUpperTriangular{T,S} where S<:AbstractArray{T,2}) where T in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2489
[15] sqrt(A::LowerTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2506
[16] sqrt(A::UnitLowerTriangular) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:2507
[17] sqrt(A::Hermitian{#s626,S} where S<:(AbstractArray{#s627,2} where #s627<:#s626) where #s626<:Complex) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/symmetric.jl:883
[18] sqrt(A::Union{Hermitian{#s627,S}, Symmetric{#s627,S}} where S where #s627<:Real) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/symmetric.jl:873
[19] sqrt(D::Diagonal) in LinearAlgebra at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/diagonal.jl:555

```

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [December 21, 2019, 8:22am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/3 "2019-12-21T08:22:35Z")

</div>

Your methods `10` and `11` are just as long! Judging from that line, seems it stems from LinearAlgebra and the truly humongous number of `where` classifieres suggests this is just an expanded chain of type definitions.

---

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [December 21, 2019, 8:31am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/4 "2019-12-21T08:31:35Z")

</div>

True, haha. That does not seem to be a bother, though.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 21, 2019, 9:00am UTC](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/5 "2019-12-21T09:00:51Z")

</div>

It is because of `StridedArray` being a union of a large number of complicated types.
