I need to show the energy level density around the local maximum of this double-well potential. I can do it using the following:

a0 = 0.02; a1 = 0.64; L = 10;
U[x_] := a0*x^4 - a1*x^2 + a1^2/(4 a0)
vals = NDEigenvalues[{-1/2 Laplacian[u[x], {x}] + U[x]*u[x], 
    DirichletCondition[u[x] == 0, True]}, u[x], {x, -L, L}, 25, 
   Method -> {"PDEDiscretization" -> {"FiniteElement", {"MeshOptions" \
-> {"MaxCellMeasure" -> 0.001}}}}];

Show[ Plot[{vals}, {x, -L, L}, PlotRange -> {Automatic, {-1.0, 15.0}},
   ImageSize -> 500, RotateLabel -> False, 
  FrameLabel -> {{"\!\(\*SubscriptBox[\(E\), \(n\)]\)", "U(x)"}, {"x",
      None}}, PlotTheme -> "Scientific"], 
 Plot[U[x], {x, -L, L}, 
  PlotStyle -> {Directive[Darker[Green], Thickness[0.005]]}, 
  Filling -> Axis, FillingStyle -> Directive[Opacity[0.9], White]]]

enter image description here

1. The above diagram serves the purpose; however, I require another representation using the density of states. The graph should look more or less like a Gaussian curve around the energy value of the hilltop. How do we plot that graph?

I have plotted the Differences[vals] using ListLinePlot as shown in the figure below. However, I believe there must be a better way to represent the energy level density around the hilltop of the double well. Besides, the x-axis in this graph makes no sense as it contains "number of differences".

enter image description here

2. How can the energy levels be plotted with vertical lines, the energy spread along the horizontal line instead of the vertical, so that it can look like an energy spectrum through a spectrometer?


1 Answer 1


You are probably looking for SmoothHistogram.


enter image description here

And you can use ListPlot for vertical lines.

ListPlot[{#, 1} & /@ vals, Filling -> Bottom, PlotMarkers -> "", FillingStyle -> Thick]

enter image description here

  • $\begingroup$ Thank you @Domen. Just one more query, is there a way to make these vertical lines colourful? Different colours for each line? PlotStyle and ColorFunction is not working $\endgroup$
    – user444
    Feb 29 at 7:44
  • 1
    $\begingroup$ Just plot each of them as a separate list: ListPlot[{{#, 1}} & /@ vals, Filling -> Bottom, PlotMarkers -> "", FillingStyle -> Thick]. Also, note that SmoothHistogram takes the kernel size as the second argument, for example: SmoothHistogram[vals, 0.5] $\endgroup$
    – Domen
    Feb 29 at 10:14
  • $\begingroup$ Thank you so much @Domen $\endgroup$
    – user444
    Feb 29 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.