function [energy, gradient] = potential_and_gradient(x)
% Compute potential energy and gradient for one or more configurations in one-dimensional two-well potential.
%
% [energy, gradient] = potential(x)
%
% ARGUMENTS
%   x (float or vector) - positions to evaluate energy and gradient
%
% RETURN VALUES
%   energy - the potential energy at x
%   gradient - the gradient at x

% Evaluate potential energy.

% asymmetric double well
K = 10;
energy = K * (x-1).^2 .* (x+1).^2 + 0.1*x;
gradient = K * (x-1).^2 .* 2 .* (x+1) + K * (x+1).^2 .* 2 .* (x-1) + 0.1;

% symmetric double well
% energy = (q-1).^2 .* (q+1).^2;

return
