# Use StepMonitor and Dynamic to plot progress of FindMinimum

The obvious way of plotting the progress of FindMinimum fails with an error about things not being localizable:

Dynamic[ListPlot[vals]]
vals={};FindMinimum[x1^2, {x1}, StepMonitor :> vals = Append[vals, x1]];
FindMinimum::vloc: The variable StepMonitor:>vals=Append[vals,x1] cannot be localized so that it can be assigned to numerical values. >>


I am not certain of the usefulness of the error, as when I added the StepMonitor to a more complex FindMinimum expression (that previously worked), it led to an error about the Gradient (when I put the StepMonitor after the Gradient) or the same error as above (otherwise).

Is this achievable in some way?

vals = {};