-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
document that inv(x) is not just for matrices #22610
Conversation
base/number.jl
Outdated
some types `inv(x)` may be slightly more efficient. | ||
|
||
# Examples | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no blank line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! :)
base/number.jl
Outdated
inv(x) | ||
|
||
Return the multiplicative inverse of `x`, such that `x*inv(x)` or `inv(x)*x` | ||
yields [`one(x)`](@ref) (the multiplicative identity). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @MikaelSlevinsky mentioned this isn't true. i.e. x*inv(x)
or inv(x)*x
does not yield one(x)
julia> x=49.0
julia> inv(x)*x
0.9999999999999999
julia> one(x)
1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure on the best way to word this but probably best to write essentially yields
instead of yields
or something alike that doesn't imply inv(x)*x == one(x)
base/number.jl
Outdated
Return the multiplicative inverse of `x`, such that `x*inv(x)` or `inv(x)*x` | ||
yields [`one(x)`](@ref) (the multiplicative identity). | ||
|
||
If `x` is a number, this is essentially the same as `one(x)/x`, but for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It need not be identical under roundoff errors, nor is it necessarily computationally identical. Hence "essentially"
inv(x)
returns the multiplicative identity for anyx
, not just matrices, but this wasn't documented.(See comments at JuliaMath/SpecialFunctions.jl#32.)