# Plot producing many error messages when given complicated function

I'm new to Mathematica and am running in to all sorts of silly difficulties with coding in it. I'm trying to calculate a function f[x, k], normalise it with another function n[k] and then calculate and plot a thrid function en[k] that depends on the first two. Unfortunately, Mathematica won't plot it, and I can't see what I did wrong. I'm sure it's a trivial mistake on my part and I'm sorry to have to ask. Here's my code:

L = 8;
f[x_, k_] :=
Cos[Pi k/(2 L)]^2  Exp[(-(x - k)^2)/2] - Sin[Pi k/(2 L)]^2 (x - L) Exp[(-(x - k)^2)/2];
n[k_] := Integrate[f[u, k]^2, {u, -L, L}];
en[k_] := Integrate[f[v, k] (-f''[v, k] + (v - k)^2  f[v, k]), {v, -L, L}]/n[k];
Plot[en[k], {k, 0, L}]

• I think you should specify the derivation variable in f''[v,k] Oct 24, 2013 at 23:11
• Thanks, that did it. You deserve a kiss.
– Kris
Oct 24, 2013 at 23:47
• You don't mention the nominated kisser, but I'll take that as a compliment at any rate. Oct 24, 2013 at 23:57

First, as Belisarius points out, you need to indicate the variable for your second derivative. You also need to carry out your differentiation and integrations before you try to plot en[k] Also, please look at the help that is provided here, especially the discussions of the difference between = and :=.
L = 8;