Como realizar o produto interno da função de forma concisa?
Uma família de funções é conhecida como $\left(\varphi_{0}, \varphi_{1}, \cdots, \varphi_{n}\right)$.
Gostaria de saber como expressar seu produto interno convenientemente da seguinte maneira:
$$\left(\begin{array}{cccc} \left(\varphi_{0}, \varphi_{0}\right) & \left(\varphi_{0}, \varphi_{1}\right) & \cdots & \left(\varphi_{0}, \varphi_{n}\right) \\ \left(\varphi_{1}, \varphi_{0}\right) & \left(\varphi_{1}, \varphi_{1}\right) & \cdots & \left(\varphi_{1}, \varphi_{n}\right) \\ \vdots & \vdots & & \vdots \\ \left(\varphi_{n}, \varphi_{0}\right) & \left(\varphi_{n}, \varphi_{1}\right) & \cdots & \left(\varphi_{n}, \varphi_{n}\right) \end{array}\right)$$
Onde $(f(x), g(x))$ é o produto interno: $(f(x), g(x))=\int_{a}^{b} f(x) g(x) \mathrm{d} x$
Nós podemos pegar $\{1,x,x^2,x^3,x^4\}$ e $\{a=-1,b=1\}$ como um exemplo para cumprir os requisitos acima.
Outer[Integrate[#1*#2, {x, -1, 1}] &, {1, x, x^2, x^3}, {1, x, x^2, x^3}]
Eu me pergunto se há alguma outra maneira de conseguir isso?
Respostas
Já que você está lidando com produtos internos, você pode tirar vantagem da simetria que $\left<f(x), g(x)\right> = \left<g(x), f(x)\right>$ para apenas computar o $n(n+1)/2$ elementos triangulares superiores em vez do total $n^2$.
Então, podemos usar SymmetrizedArraycomo
ipmatrix[ϕ_, n_, {a_, b_} /; a <= b] := SymmetrizedArray[
{j_, k_} :> Integrate[ϕ[x, j]*ϕ[x, k], {x, a, b}],
{n, n},
Symmetric
]
Para produzir o seu exemplo de
Normal@ipmatrix[#1^(#2 - 1) &, 5, {-1, 1}]
{{2, 0, 2/3, 0, 2/5}, {0, 2/3, 0, 2/5, 0}, {2/3, 0, 2/5, 0, 2/7} , {0, 2/5, 0, 2/7, 0}, {2/5, 0, 2/7, 0, 2/9}}