{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/17474","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/17474/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17474/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/17474/events","html_url":"https://github.com/JuliaLang/julia/issues/17474","id":166008810,"number":17474,"title":"for most functions if f(::Int64)::Float64 then f(::BigInt)::BigFloat","user":{"login":"oxinabox","id":5127634,"avatar_url":"https://avatars.githubusercontent.com/u/5127634?v=3","gravatar_id":"","url":"https://api.github.com/users/oxinabox","html_url":"https://github.com/oxinabox","followers_url":"https://api.github.com/users/oxinabox/followers","following_url":"https://api.github.com/users/oxinabox/following{/other_user}","gists_url":"https://api.github.com/users/oxinabox/gists{/gist_id}","starred_url":"https://api.github.com/users/oxinabox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxinabox/subscriptions","organizations_url":"https://api.github.com/users/oxinabox/orgs","repos_url":"https://api.github.com/users/oxinabox/repos","events_url":"https://api.github.com/users/oxinabox/events{/privacy}","received_events_url":"https://api.github.com/users/oxinabox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-18T02:10:55Z","updated_at":"2016-07-19T20:14:50Z","closed_at":null,"body":"As I learnt when doing https://github.com/JuliaLang/julia/pull/17447#discussion_r71065529\r\nthe expectation is that, for a function `f` (eg gamma, exp2)\r\n\r\n **if** `f(::Int64)::Float64` **then** `f(::BigInt)::BigFloat`\r\n\r\nAnd for the most part this is true (indeed I added in the PR test cases to ensure it).\r\n\r\nI have found 3 exceptions to it, all functions from a part of math the I've not really dealt with much. `zeta`, `digamma`, and `trigamma`\r\n\r\n### digamma\r\n\r\n```\r\njulia> digamma(big\"1\")\r\n-0.5772156649015315\r\n\r\njulia> digamma(big\"1.0\")\r\n-5.772156649015328606065120900824024310421593359399235988057672348848677267776685e-01\r\n```\r\n\r\nThis is the simple case.\r\nThe fallback definition for BigInt, is falling down to `digamma(z::Number) at special/gamma.jl:368`\r\nand so never ends up calling  `digamma(x::BigFloat) at mpfr.jl:450`, which is the natural call back\r\n\r\n\r\n\r\n### zeta\r\n\r\n```\r\njulia> zeta(0)\r\n-0.5\r\n\r\njulia> zeta(big\"0\")\r\n-0.5\r\n\r\njulia> zeta(big\"0.0\")\r\n-5.000000000000000000000000000000000000000000000000000000000000000000000000000000e-01\r\n\r\njulia> zeta(big\"1.0\")\r\ninf #this has type BigFloat\r\n\r\njulia> zeta(big\"1\")\r\nNaN #this has type Float64\r\n\r\njulia> julia> zeta(1.0)\r\nNaN\r\n\r\njulia> zeta(1)\r\nNaN\r\n\r\njulia> zeta(complex(big\"1\",big\"0\"))\r\nnan + 0.000000000000000000000000000000000000000000000000000000000000000000000000000000im\r\n```\r\n\r\nSo it is working fine for complex numbers, which is what most people care about (From the little I know of the Riemann zeta function).\r\n\r\nFor `BigInt` it is hitting `zeta(x::Integer) at special/gamma.jl:462`\r\nWhich is similar to the issue for `digamma`\r\n\r\nhowever we also see that `zeta(big\"1.0\") != zeta(big(\"1\"))` (ignoring type).\r\n`NaN !=inf`.  which is more concerning.\r\nDivining what the correct answer for `zeta(1)` should be, I leave to better informed minds than my own.\r\nWolframAlpha says it is \"Complex Infinity\"\r\n\r\n\r\n### Trigamma\r\n\r\n```\r\njulia> trigamma(big\"1\")\r\n1.6449340668482262\r\n\r\njulia> trigamma(big\"1.0\")\r\n1.6449340668482262\r\n```\r\n\r\ntrigamma is not defined for BigFloat, or BigInt, so perhaps it doesn't belong here, but just pointing it out since i spotted it."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/233751888","html_url":"https://github.com/JuliaLang/julia/issues/17474#issuecomment-233751888","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/17474","id":233751888,"user":{"login":"simonbyrne","id":1692009,"avatar_url":"https://avatars.githubusercontent.com/u/1692009?v=3","gravatar_id":"","url":"https://api.github.com/users/simonbyrne","html_url":"https://github.com/simonbyrne","followers_url":"https://api.github.com/users/simonbyrne/followers","following_url":"https://api.github.com/users/simonbyrne/following{/other_user}","gists_url":"https://api.github.com/users/simonbyrne/gists{/gist_id}","starred_url":"https://api.github.com/users/simonbyrne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonbyrne/subscriptions","organizations_url":"https://api.github.com/users/simonbyrne/orgs","repos_url":"https://api.github.com/users/simonbyrne/repos","events_url":"https://api.github.com/users/simonbyrne/events{/privacy}","received_events_url":"https://api.github.com/users/simonbyrne/received_events","type":"User","site_admin":false},"created_at":"2016-07-19T20:14:50Z","updated_at":"2016-07-19T20:14:50Z","body":"Instead of\r\n```julia\r\nfoo{T<:Union{Integer,Rational}}(x::Union{T,Complex{T}}) = foo(float(x))\r\n```\r\nwhat's wrong with\r\n```julia\r\nfoo(x::Number) = foo(float(x))\r\n```\r\n(which also works for `Irrational`s as well)"}}
{"actor":{"display_login":"simonbyrne"}}