Skip to content
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

MethodError: binomial(::Num, ::Int64) is ambiguous. #955

Open
nsajko opened this issue Aug 16, 2023 · 1 comment
Open

MethodError: binomial(::Num, ::Int64) is ambiguous. #955

nsajko opened this issue Aug 16, 2023 · 1 comment

Comments

@nsajko
Copy link
Contributor

nsajko commented Aug 16, 2023

julia> using Symbolics

julia> @variables x
1-element Vector{Num}:
 x

julia> invoke(binomial, Tuple{Number, Integer}, x, 3)  # this is what I would expect from `binomial(x, 3)`
(1//6)*x*(x - 1)*(x - 2)

julia> binomial(x, 3)  # instead there's a `MethodError`
ERROR: MethodError: binomial(::Num, ::Int64) is ambiguous.

Candidates:
  binomial(arg1::Num, arg2::Real)
    @ Symbolics ~/.julia/packages/Symbolics/BQlmn/src/register.jl:55
  binomial(x::Number, k::Integer)
    @ Base intfuncs.jl:1145

Possible fix, define
  binomial(::Num, ::Integer)

Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

(@v1.11) pkg> st Symbolics
Status `~/.julia/environments/v1.11/Project.toml`
  [0c5d862f] Symbolics v5.5.1

As first noted by stevengj on Discourse.

@nsajko
Copy link
Contributor Author

nsajko commented Nov 20, 2023

The behavior of binomial(x, 3) changed recently, I guess because of #985:

julia> using Symbolics

julia> @variables x
1-element Vector{Num}:
 x

julia> invoke(binomial, Tuple{Number, Integer}, x, 3)
(1//6)*(-2 + x)*(-1 + x)*x

julia> binomial(x, 3)
binomial(x, 3)

(@v1.11) pkg> st Symbolics
Status `~/.julia/environments/v1.11/Project.toml`
  [0c5d862f] Symbolics v5.10.0

So the error is gone, but I don't see how the result is useful. @YingboMa how to get the result as expected (a polynomial, as in the invoke) from the result of a call like binomial(x, 3)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant