I have two functions, $f(x)=\sin x$ and $g(x)=\sin\frac{pi}{4}x$, and I want to calculate the average Euclidean metric as an expected value to score for the average distance between the two functions on $l^2$.
Using the metric:
$d(f,g)=|f(x)-g(x)|=\sqrt{|x(t)|^2+|y(t)|^2}$
would be the best option. So I looked up at Wolfram Reference and found these two options,
EuclideanDistance[{a, b, c}, {x, y, z}]
NormalizedSquaredEuclideanDistance[{a, b}, {x, y}]
However, both are for vectors, and not for real-valued functions.
Any ideas appreciated.
Thanks
Integrate
may help. $\endgroup$f[x_] = Sin[x]; g[x_] = Sin[π/4 x]; L2[a_, b_] = Integrate[(f[x] - g[x])^2, {x, a, b}, Assumptions -> a < b]^(1/2); l2[a_, b_] := NIntegrate[(f[x] - g[x])^2, {x, a, b}]^( 1/2); {L2[-2, 2] // N, l2[-2, 2]}
$\endgroup$