Finding the angle between two functions

5.2k Views Asked by At

I know that $\cos(\theta) = \frac{\langle f,g \rangle}{\|f\| \|g\|}$ for two functions $f$ and $g$. So, for two functions $x^n$ and $x^m$, $n \neq m$, on the interval $[-1,1]$ I want to find the angle between the two functions. Setting this up, I believe it would be

$$\cos(\theta) = \frac{\int_{-1}^1x^nx^m\,dx}{(\int_{-1}^1|x^n|\,dx)(\int_{-1}^1|x^m|\,dx)}$$

Evaluating this, I seem to get a mess of

$$\cos(\theta) = \frac{(1 + (-1)^{n+m})(n+1)(m+1)}{4n+4m+4}$$

which doesn't feel right. Am I overlooking something simple about this?

1

There are 1 best solutions below

0
On BEST ANSWER

If the inner product is $\displaystyle \langle f,g\rangle = \int_{-1}^1 f(x) g(x)\, dx$ then $\displaystyle \|f\| = \sqrt{\langle f,f\rangle} = \sqrt{\int_{-1}^1 f(x)^2\, dx},$ so \begin{align} \cos\theta = {} & \frac{\langle x^n, x^m\rangle}{\|x^n\|\|x^m\|} = \frac{\int_{-1}^1 x^{n+m} \,dx}{\sqrt{\int_{-1}^1 (x^n)^2\,dx \int_{-1}^1 (x^m)^2\, dx}} \\[10pt] = {} & \frac{2/(n+m+1)}{\sqrt{(2/(2n+1)) (2/(2m+1))}} \text{ if } n,m \text{ have the same parity} \\ & \qquad\qquad\qquad\qquad\qquad\qquad \text{and 0 if they have opposite parities} \\[10pt] = {} & \frac{\sqrt{(2n+1)(2m+1)}}{n+m+1} \end{align}