
%  The script file finda.m computes the critcial value of 
%  a for the PT-symmetric potential p(x) = x^4 + iax. 
%  It uses MATLAB's built-in function fminsearch to minimize
%  the distance between E0 and E1.   The objective function
%  is computed in F = acrit(a, x, D2)

N = 64;  c = 2;             % Increase order of matrices if necessary,
c = 2;                      % and adjust scaling parameter accordingly. 
 
[x,DM] = herdif(N,2,c);     % Assemble Hermite DMs and
D2 = DM(:,:,2);             % extract second derivative. 
 
options = optimset('TolX',1e-12);            % Adjust tolerance if necessary
acrit = fminsearch('acrit',3,options,x,D2)


