Interval arithmetic and functions of intervals

93 Views Asked by At

I'm playing with the interval arithmetic and found a Wikipedia article https://en.wikipedia.org/wiki/Interval_arithmetic

Consider the positive interval $[a,b]$ ($a\gt 0$).

Then what is $\sin([a,b])$?

I tried to do it with Taylor series: $$\sin(x)=x-\frac{x^3}{3!}+\frac{x^5}{5!}+\ldots$$ Since $[a,b]$ is positive, then $[a,b]^n=[a^n,b^n]$.

Thus, $$\sin([a,b])=[a,b]-\frac{[a,b]^3}{3!}+\frac{[a,b]^5}{5!}+\ldots=\left[a-\frac{b^3}{3!}+\frac{a^5}{5!}+\ldots,b-\frac{a^3}{3!}+\frac{b^5}{5!}+\ldots\right]$$

This can be rewritten $$\sin([a,b])=\left[\sum_{n=0}^{\infty} \frac{a^{4n+1}}{(4n+1)!}-\frac{b^{4n+3}}{(4n+3)!},\sum_{n=0}^{\infty} \frac{b^{4n+1}}{(4n+1)!}-\frac{a^{4n+3}}{(4n+3)!}\right]=\frac{1}{2}\left[\sin(a)+\sin(b)+\sinh(a)-\sinh(b),\sin(a)+\sin(b)-\sinh(a)+\sinh(b)\right]$$

Is this used somewhere, is it useful or just a junk?

Thank you.

3

There are 3 best solutions below

3
On BEST ANSWER

Assuming the absolute convergence of the Taylor series over the whole interval $[a,b]$, your approach is perfectly sound. Though it's not guaranteed to give the tightest possible bound, it will certainly give you valid lower and upper bounds for the values of $f(x)$ when $x\in[a,b]$. Another way to state what you're doing is this. Take $a \le x \le b$. You have $$ f(x)=\sum_kc_k x^k = \sum_{k\in K_+}|c_k| x^k -\sum_{k\not\in K_+} |c_k|x^k, $$ where $K_+$ is the set of indices for which $c_k \ge 0$. Each series can be bracketed by its values at $a$ and $b$: $$ \sum_{k\in K_+}|c_k|a^k \le \sum_{k\in K_+}|c_k|x^k \le \sum_{k\in K_+}|c_k|b^k $$ and $$ \sum_{k\not\in K_+}|c_k|a^k \le \sum_{k\not\in K_+}|c_k|x^k \le \sum_{k\not\in K_+}|c_k|b^k. $$ Combining these gives you $$ \sum_{k\in K_+}|c_k|a^k - \sum_{k\not\in K_+}|c_k|b^k \le f(x) \le \sum_{k\in K_+}|c_k|b^k - \sum_{k\not\in K_+}|c_k|a^k, $$ which is what you calculated.

1
On

What you did was calculating the Taylor polynomial with interval arithmetic. But that wasn’t the question. Since -1 <= sin x <= 1, the correct result must be a subset of [-1, 1].

You’ll have to find the minimum and maximum of sin x for a <= x <= b. The maximum is one of sin a, sin b, and 1. The minimum is one of sin a, sin b, and -1. To find which you need to find if (2k + 1/2) pi is between a and b, or whether (2k - 1/2) pi is between them, or both.

0
On

I wrote the following python code to apply cos and sin to an interval.

It uses the following properties:

  • if a and b are on the same increasing branch, then $\cos([a, b]) = [\cos a, \cos b]$;
  • if a and b are on the same decreasing branch, then $\cos([a, b]) = [\cos b, \cos a]$;
  • if $[a, b]$ contains $[n \pi, (n+1) \pi]$ then $\cos([a, b]) = [-1, +1]$;
  • if $2 k \pi \leq a \leq (2 k + 1)\pi \leq b \leq (2k+2) \pi$ then $\cos([a, b]) = [-1, \max(\cos a, \cos b)]$;
  • if $(2k-1)\pi \leq a \leq 2k \pi \leq b \leq (2k+1) \pi$ then $\cos([a,b]) = [\min(\cos a, \cos b), +1]$
def intervalcos(a, b):
    old_a = a
    a = old_a % twopi   # principal value of a in [0, 2pi]
    b = b + (a - old_a) # translate b accordingly with a
    if 0 <= a <= b <= pi:       # decreasing \
        return [cos(b), cos(a)]
    elif pi <= a <= b <= twopi: # increasing /
        return [cos(a), cos(b)]
    elif b <= twopi:            # unimodal with minimum \/
        return [-1, max(cos(a), cos(b))]
    elif a <= pi < twopi <= b:  # surjective [pi, 2pi] -> [-1, 1]
        return [-1, 1] 
    elif 3 * pi <= b:           # surjective [2pi, 3pi] -> [-1, 1]
        return [-1, 1]
    else:                       # unimodal with maximum /\
        return [min(cos(a), cos(b)), 1]

def intervalsin(a, b):
    return intervalcos(halfpi - b, halfpi - a)