google / autobound

AutoBound automatically computes upper and lower bounds on functions.
Apache License 2.0
355 stars 19 forks source link

Implement trigonometric functions #6

Open clemisch opened 1 year ago

clemisch commented 1 year ago

Sine and cosine are not implemented, as you state in the paper:

For example, we do not currently have a way to compute sharp Taylor enclosures for periodic functions, such as sine or cosine.

I only skimmed the paper, but I assume periodic functions are a non-trivial limitation?

mstreeter commented 1 year ago

Coming up with sharp (i.e., optimal) bounds for sine and cosine would require proving some new theorems. However, it wouldn't be too much work to implement non-sharp bounds based on the range of the kth derivative, and these bounds should still be pretty good in practice.

clemisch commented 1 year ago

Just now coming back to this.

Does autobound have an interface for

non-sharp bounds based on the range of the kth derivative

? Or would I have to read the paper and implement it by hand?

mstreeter commented 1 year ago

Good question. The main thing that would need to be done is to modify the get_range() function in elementwise_functions.py so that it can compute the range of sin or cos, as well as the range of their derivatives: https://github.com/google/autobound/blob/1f82563346895efb87bceefd1bcd48ce7713426c/autobound/elementwise_functions.py#L246

This could be done by first normalizing the trust_region so that its endpoints are in the interval [-pi, pi], then using the existing _get_range() function which takes a list of local minima / maxima within the trust region. Let me know if any of this is unclear!

After that there is some boilerplate to hook things up, which I'd be happy to add.