Closed ekatko1 closed 3 years ago
Operations with logarithms can be certainly improved, but these expressions are not equivalent:
a=5
b=2
log(a) / log(b)
#> [1] 2.321928
log(a-b)
#> [1] 1.098612
Probably you meant
a=set_units(5, 1)
b=set_units(2, 1)
log(a) - log(b)
#> 0.9162907 [ln(re 1)]
log(a/b)
#> 0.9162907 [ln(re 1)]
which works fine.
I also noted that
> exp(log(set_units(1:10, 1)))
[1] 1 2 3 4 5 6 7 8 9 10
Warning message:
In Math.units(log(set_units(1:10))) :
Operation exp not meaningful for units
where we seem to miss the exception?
Yeap, good catch. We missed the exp
case in the Math.units
method.
Apologies for the previous blunder with regards to the rules of exponentiation. Thank you for looking into it regardless.
Additionally, the base 10 analogy to edzer's comment does not compute at all:
> 10^log10(set_units(1:10, 1))
Error in UseMethod("units") :
no applicable method for 'units' applied to an object of class "c('double', 'numeric')"
Thank you for fixing this. I recently encountered an issue where I wanted to do something like exp(log(x))
in my code, and I was going to give a bug report/feature request like this one.
So, thanks!
Consider the following code:
This results in the following error:
An equivalent expression,
Returns
1.098612 [ln(re 1)]
I would expect both expressions to return the same result. I also see no reason to preserve the
ln(re 1)
notation for unitless quantities.Kindly, Egor