%
  
  function J = energy_fun(q,P,udata);
  
  alpha_1 = q(1,1);
  alpha_11 = q(2,1);
  alpha_111 = q(3,1);

  psi = alpha_1*P.^2 + alpha_11*P.^4 + alpha_111*P.^6;
  res = psi - udata;
  J = res'*res;

