How can I check if a function is always positive?

In general the over-estimation of the range comes when a variable is repeated more than once in an expression, as is the case for x^2 - 2x. This is due to the definition of subtraction of two intervals as

X - Y := \{x - y: x \in X, y \in Y \}

So that if e.g. X = [0, 1] then X - X = [-1, 1] instead of 0. This is known as the dependency effect. It is difficult to get rid of, unfortunately.

In the case of g(x) = x^2 - 2x you can do the following:

julia> g(X.lo)
9800.0

julia> ForwardDiff.derivative(g, X)
[198, ∞]

Since the derivative is positive everywhere in X, the function is increasing. Since it starts out positive, it remains positive.

But then

julia> h(x) = x^3 - 3x^2
h (generic function with 1 method)

julia> ForwardDiff.derivative(h, X)
[-∞, ∞]

so in that case you would need to go to the second derivative.

For a complicated transcendental function I’m not sure what you would do.