bjornbm / dimensional

Dimensional library variant built on Data Kinds, Closed Type Families, TypeNats (GHC 7.8+).
BSD 3-Clause "New" or "Revised" License
102 stars 15 forks source link

Add dimensionless wrappers for log1p and friends #203

Closed dmcclean closed 5 years ago

dmcclean commented 5 years ago

Since base-4.9 the Floating class has had log1p, expm1, log1pexp, and log1mexp.

We should likely add Dimensionless wrappers for these.

bjornbm commented 5 years ago

Looks OK to me. Do you know what the tradeoff is? Perhaps we should consider making these the “least effort” options? E.g.:

log = fmap Numeric.log1p
log_ = fmap Prelude.log
dmcclean commented 5 years ago

I think it's basically along these lines: Pro: If you go looking for something from the Floating typeclass, there is a dimensional wrapper for it, so you have guidance as to what the proper dimensions are. Con: Additional name consumption, and of some strange names.

I'm confused by the alternative you propose. log1p = log . (+1) but with a possibly more precise result when the argument is very small.

μ> Numeric.log1p 2
1.0986122886681098
μ> Prelude.log 3
1.0986122886681098
bjornbm commented 5 years ago

Ah, sorry, I misread the docs and purpose of log1p (et al). I think this change is good. 👍