Logarithms yearning to be free
johndcook.com
johndcook.com
Bear with me here, I know infinitesimal math isn’t a fully coherent thing. But there’s a reason why Newton used it, it sometimes works surprisingly well to make intuitive analogies. Maybe there’s a way to make it work here.
For example: The function ln(x) grows strictly slower than x^a for any positive real a, but faster than x^0. Hence, it’s x^ε, where 0 < ε < a for any positive real a.
Note that lots of functions have rates of growth between x^0 and all x^a, so the rationale isn't great. Log(x) doesn't actually have to behave like any exponential.
Worse yet, it's similarly pretty easy to prove that x^ε must be closer to 1 than any other real (for positive x). Log(x) seems curvier than a constant, so x^ε doesn't look like quite the right representation.
That said, (x^ε-1)/ε _is_ actually closer to log(x) than any other real. The easiest way to get an intuitive feel for that is to rewrite x^ε as e^(ε log(x)) and examine the maclaurin series. There are some details in proving that works appropriately, but everything does actually fall into place.
In some view then, x^ε really does have the same asymptomatic structure as log(x). They just differ by infinite constant factors rather than finite ones, so they definitely don't grow at the same rate in any classical sense (Big O, Big Theta, ...).
Incidentally, exactly that same idea plays into one of the examples from TFA. Integrate x^(ε-1) with the ordinary power rule, and you'll find (1/ε)x^ε, or with that same maclaurin expansion (1/ε) + log(x) + O(ε). Admittedly the infinite constant looks a little odd (and I haven't taken care to prove that the results of that particular integration procedure are anything more than a happy accident), but that bears a striking resemblance to C + log(x).
It is definitely nice to have multiple routes to the same answer though to help verify that some stupid mistake didn't infect the results.
What a neat limit. Probably best to leave the powerfn/logfn() as a dumb symbolic symbol until the end (until after later parameter substitution)?
integral{from t=0, to t=x} t^{-1+0} dx
but you calculate instead
f(x) = lim_{ε->0} [ integral{from t=0, to t=x} t^{-1+ε} dx ]
that is just
= lim_{ε->0} [ (t^ε - 1) / ε ]
replacing t^ε
= lim_{ε->0} [ (e^(ln(t)*ε) - 1) / ε ]
by https://en.wikipedia.org/wiki/L%27H%C3%B4pital%27s_rule
= lim_{ε->0} [ ln(t)*e^(ln(t)*ε) / 1 ]
that is easy to calculate
= ln(t)*e^(ln(t)*0) / 1
= ln(t)*1 / 1
= ln(t)
So f(t)=ln(t)
We throw ZeroDivisionError instead of axiomatically defining a ranking for
scalar*parameter*inf
if x > 0:
2*x*inf > x*inf
# because
2 > 1
But basically every CAS just prematurely throws away all terms next to infinity (by replacing the information in that expression with just infinity)? And nothing yet implements e.g. Conway's Surreal numbers infinities?Is negative infinity to the infinity greater or lesser than infinity?
assert (-1*math.inf)**math.inf == math.inf
assert (-1*sympy.oo)**sympy.oo == sympy.oo
Here's a dumb Real/Function instead of prematurely discarding information that could be useful: from sympy import symbol
from sympy.abc import x
Infinity = symbol('Infinity', real=True) # *
#
from sympy.symbols import Wild
All the axioms just change there. limit(-x**-1)
An uphill battle for certain."[Python-ideas] Re: 'Infinity' constant in Python" https://mail.python.org/archives/list/python-ideas@python.or...
Plenty of functions are discontinuous. Almost all of them, in fact. (This isn't true constructively, but GP is clearly doing classical analysis.)
> If a [math] function returns a more complex type signature instead of throwing a ZeroDivisionError (as Python core does) what is that then called? Is it differentiable or no, etc?
Depends on the smooth structures you've imposed on the domain and codomain, which requires much more powerful types to represent than are available in any mainstream language I'm aware of. (You might be able to contort Haskell into something sort of close, but it wouldn't be simple.)
but you calculate instead
f(x) = lim_{ε->0} [ integral{from t=0, to t=x} t^{-1+ε} dx ]
that is just
= lim_{ε->0} [ (t^ε - 1) / ε ]
replacing t^ε
= lim_{ε->0} [ (e^(ln(t)ε) - 1) / ε ]
by https://en.wikipedia.org/wiki/L%27H%C3%B4pital%27s_rule
= lim_{ε->0} [ ln(t)e^(ln(t)ε) / 1 ]
that is easy to calculate
= ln(t)e^(ln(t)0) / 1
= ln(t)1 / 1
= ln(t)
So f(t)=ln(t)
reply