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

logic error in ncbeta, (so in ncF too) #237

Closed
JeffreySarnoff opened this issue Sep 9, 2020 · 4 comments
Closed

logic error in ncbeta, (so in ncF too) #237

JeffreySarnoff opened this issue Sep 9, 2020 · 4 comments
Labels

Comments

@JeffreySarnoff
Copy link
Member

julia> ncbeta(0.5, 0.25, 0.125, 0.875 )
ERROR: UndefVarError: ans not defined
Stacktrace:
 [1] beta_integrand(a::Float64, b::Float64, x::Float64, y::Float64, mu::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\beta_inc.jl:159
 [2] beta_integrand
   @ ~\.julia\packages\SpecialFunctions\LC8dm\src\beta_inc.jl:95 [inlined]
 [3] ncbeta_tail(a::Float64, b::Float64, lambda::Float64, x::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\betanc.jl:29
 [4] ncbeta(a::Float64, b::Float64, lambda::Float64, x::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\betanc.jl:162
 [5] top-level scope
   @ REPL[74]:1

julia> ncF(0.5, 0.25, 0.125, 0.875 )
ERROR: UndefVarError: ans not defined
Stacktrace:
 [1] beta_integrand(a::Float64, b::Float64, x::Float64, y::Float64, mu::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\beta_inc.jl:159
 [2] beta_integrand
   @ ~\.julia\packages\SpecialFunctions\LC8dm\src\beta_inc.jl:95 [inlined]
 [3] ncbeta_tail(a::Float64, b::Float64, lambda::Float64, x::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\betanc.jl:29
 [4] ncbeta
   @ ~\.julia\packages\SpecialFunctions\LC8dm\src\betanc.jl:162 [inlined]
 [5] ncF(x::Float64, v1::Float64, v2::Float64, lambda::Float64)
   @ SpecialFunctions ~\.julia\packages\SpecialFunctions\LC8dm\src\betanc.jl:180
 [6] top-level scope
   @ REPL[75]:1
julia> versioninfo()
Julia Version 1.6.0-DEV.771
Commit 0336f672db (2020-08-30 01:07 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) E-2176M  CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8
@stevengj stevengj added the bug label Sep 9, 2020
@stevengj
Copy link
Member

stevengj commented Sep 9, 2020

Seems to have been introduced in #165. @Sumegh-git, do you have a fix?

@awadell1
Copy link

Looks like I've hit a similar error (Version [276daf66] SpecialFunctions v1.3.0)

julia> beta_inc(0.04401630888685953, 0.026187091737271025, 0.707)
ERROR: UndefVarError: ans not defined
Stacktrace:
 [1] beta_integrand(a::Float64, b::Float64, x::Float64, y::Float64, mu::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/mFAQ4/src/beta_inc.jl:162
 [2] beta_inc_diff(a::Float64, b::Float64, x::Float64, y::Float64, n::Int64, epps::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/mFAQ4/src/beta_inc.jl:619
 [3] beta_inc(a::Float64, b::Float64, x::Float64, y::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/mFAQ4/src/beta_inc.jl:853
 [4] beta_inc(a::Float64, b::Float64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/mFAQ4/src/beta_inc.jl:863
 [5] top-level scope
   @ REPL[89]:1

Version Info

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)

Is anyone working this or can I take a crack?

@giordano
Copy link
Member

Is anyone working this

I don't think anyone claimed it

or can I take a crack?

That'd be great! It looks like ans is defined in some ifs, but not in all branches, so depending on the condition ans may not be defined. It's always a bit weird to name a variable ans in Julia

@devmotion
Copy link
Member

All examples above work correctly with SpecialFunctions 1.4.1. The bug was fixed by @andreasnoack in #316, the diff shows the fixes in beta_integrand (https://github.com/JuliaMath/SpecialFunctions.jl/pull/316/files#diff-7b91342b259418c7f2d359de126c34ee2f21d4c47bcd0384461696d90f1569a0).

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

No branches or pull requests

6 participants