Calculate the norm $ L ^ {2}$

Hi, please I have a question:
I need a command that allows me to calculate norm ||.||_{L^{2}(0,1)}, for example ,
for a function x^{2} it gives

||x^2||_{L^{2}(0,1)} = \int_{0}^{1} x^{2} dx

thanks.

Depending on whether you want to do symbolic or numerical integration, you can use either

L2[f_] := Sqrt[Integrate[Abs[f[x]]^2, {x, 0, 1}]]

(symbolic) or

NL2[f_] := Sqrt[NIntegrate[Abs[f[x]]^2, {x, 0, 1}]]

(numeric).

Note also that this operation takes in the function you want to get the L^2 norm of; to specify x^2, for example, we could use

f = (#^2 &)

or

f[x_] := x^2

or

f = Function[x, x^2]

and then evaluate L2[f].

Also (as far as I can tell) there’s a typo in your question—a missing square root, as such:

\|\,f(x)\|_{L^2(0,1)}\equiv\left(\int_0^1\left| \,f(x)\right|^2\;dx\right)^{1/2}