I have a little problem; I have defined the following Piecewise-function in the variables {x,L,w}:
f[x_, L_, w_] := Piecewise[{{x w (L - x), 0 <= x <= L}}];
Then I have defined the normalization of this function:
norm[L_, w_] := Integrate[f[x, L, w]^2, {x, 0, L},Assumptions -> (L > 0) \[And] (w > 0) \[And] (L >= x >= 0)];
(I have tried different forms of 'Assumptions' but the following problem persists). Then I defined the normalized function:
fnorm[x_, L_, w_] := f[x, L, w]/Sqrt[norm[L, w]];
When I tried to plot the previous normalized function, for some numerical values of variables {L,w}, many problems appears:
Plot[fnorm[x, 1, 1], {x, 0, 1}];
Integrate::ilim: Invalid integration variable or limit(s) in {0.0000204286,0,1}.
NIntegrate::itraw: Raw object 0.000020428571428571424` cannot be used as an iterator.
NIntegrate::itraw: Raw object 0.000020428571428571424` cannot be used as an iterator.
Integrate::ilim: Invalid integration variable or limit(s) in {0.0204286,0,1}.
NIntegrate::itraw: Raw object 0.02042859183673469` cannot be used as an iterator.
General::stop: Further output of NIntegrate::itraw will be suppressed during this calculation.
Integrate::ilim: Invalid integration variable or limit(s) in {0.0408368,0,1}.
General::stop: Further output of Integrate::ilim will be suppressed during this calculation.
Obviously the plot of the normalized function dosen't appeare. The plot,for a range of numerical value for {L,w}, of the normalization, appears:
Plot3D[norm[L, w], {L, 0.5, 1}, {w, 0.5, 1}]
The previos plot appears without problems.
Thanks for any tips and helps!


Evaluate[fnorm[x, 1, 1]]. — Somewhere on site this question is already answered in full. I’ll try to find it. – Michael E2 Nov 27 '21 at 13:53=instead of:=in definingnorm[], since the symbolic integral can be done:norm[L_, w_] = Integrate[..]. If you want to keep:=, then best practice would be to localizex:norm[L_, w_] := Module[{x}, Integrate[..]]. The use ofSetDelayed(:=) means the integral is recalculated every timenorm[]is called, which would make the code quite slow probably. – Michael E2 Nov 27 '21 at 14:17