3

I want to know how to perform a rotation in 2D interval arithmetic. That amounts to computing the tightest interval containing

$$ x\ \mathrm{cos}(\varphi) + y\ \mathrm{sin}(\varphi), \tag{1}$$

where $x$, $y$ and $\varphi$ are all (real number) intervals.

The first approach one might try is to directly use interval arithmetic on (1). However, this leads to poor bounds, e.g. taking $x = [-1,1]$, $y = [-1,1]$, $\varphi = [0,2 \pi]$ one gets

$$\begin{align} x\ \mathrm{cos}(\varphi) + y\ \mathrm{sin}(\varphi) & = [-1,1] \ \mathrm{cos}([0,2 \pi]) + [-1,1] \ \mathrm{sin}([0,2 \pi]) \\ &= [-1,1] \cdot [-1,1] + [-1,1] \cdot [-1,1] \\ &= [-2, 2]\end{align}$$

However, this isn't the tighest bound, because $x\ \mathrm{cos}(\varphi) + y\ \mathrm{sin}(\varphi)$ is clearly bounded by $\sqrt{x^2 + y^2}$; this observation leads to the tight bound $[-\sqrt{2}, \sqrt{2}]$ in this case.

To eliminate the dependency problem with the variable $\varphi$, we can rewrite the formula so that $\varphi$ only occurs once:

$$ \sqrt{x^2 + y^2}\ \mathrm{cos}\left (\varphi - \mathrm{atan2}(x,y) \right ), \tag{2}$$

where $\mathrm{atan2}$ is the 2-argument arctangent function that gives the polar angle of the given point.

(2) computes the optimal bound in the example above. Unfortunately, it can perform worse than (1) when $\varphi$ is a small interval. For example, taking $x = y = [0.9,1.1]$ and $\varphi = [0,0]$, evaluating (2) with interval arithmetic gives an answer of about $[0.805, 1.204]$, which is worse than the obvious answer $[0.9,1.1]$ that (1) computes. We've gotten rid of the dependency in $\varphi$, but now we introduced a dependency problem in the variables $x$ and $y$.

Furthermore, taking the intersection of (1) and (2) doesn't always give tight bounds. For example, take $x = y = [1,2]$, $\varphi = [0, \frac{\pi}{2}]$. Evaluating (1) gives $[0,4]$, (2) gives approximately $[0.63, 2\sqrt{2}]$, while the actual answer is $[1,2\sqrt{2}]$.

Question: Is there a differentiable expression that can be evaluated using interval arithmetic and computes $ x\ \mathrm{cos}(\varphi) + y\ \mathrm{sin}(\varphi) $, with a tight bound in all cases? I'm happy to assume that $x > 0$ and $y > 0$, but $\varphi$ may span several quadrants.

Note that I do need an actual formula which I can differentiate, as the problem I'm working on relies on automatic differentiation. That is, in practice, $\varphi$ is not just an interval but is an interval-valued differential, and I don't know how I would evaluate the expression with differentials if we are taking minimums & maximums over a finite set of values. I also don't want to simply formulate a nonlinear optimisation problem and solve it numerically, as again that doesn't give me a procedure that I can differentiate.

Will
  • 1,850
  • 2
    I am not sure I understand. Given $a\le b$, $c\le d$, $e\le f$, and the function $g(x,y,\varphi)=x\cos\varphi+y\sin\varphi$, you want to find the minimum and maximum of $g$ over the set $(x,y,\varphi)\in [a,b]\times[c,d]\times[e,f]$? – Gio67 May 17 '23 at 09:54
  • Yes, but I want the minimum/maximum to be expressed as a differentiable function of the inputs a,b,c,d,e,f. – Will May 17 '23 at 13:51
  • 1
    Since $x$ and $y$ are only appearing as a monotone function in a single summand of the objective, we only need to look at their max & min values. And for fixed $x,y$ you can solve (1) for min/max, resulting in another case distinction. Since AD allows for control flow (e.g. torch.where), and the piecewise function you get is probably almost everywhere differentiable, I think this kind of representation shouldn't cause any problems – Sudix May 17 '23 at 15:42
  • @Sudix OK, I didn't realise it was possible for AD to handle piecewise definitions like that. I'll have to look into it. I implemented a custom framework because I need derivatives up to order 3. So I just take minimum/maximum over $x \in { x_\textrm{min}, x_\textrm{max} }$ $y \in { y_\textrm{min}, y_\textrm{max} }$ and $ \varphi \in { \varphi_\textrm{min}, \varphi_\textrm{max} } \cup \left ( [\varphi_\textrm{min}, \varphi_\textrm{max}] \cap { k \pi + \mathrm{atan2}(x,y) | k \in \mathbb{Z} } \right ) $? – Will May 17 '23 at 19:12
  • If $ k \pi + \mathrm{atan2}(x,y)$ for $k\in\mathbb Z$ gives all extreme points for (1) for fixed $x,y$, then yes – Sudix May 17 '23 at 19:55

0 Answers0