function error = residual(f_approx_nm1,f_approx,z,A,sqrt_M)
global eps;global delv;
vdx_fn = vdx_fn_perd_1st(f_approx_nm1);
vdx_fn =  MultiD_times(vdx_fn,sig_1(z));
Pf = Trig_Multi(A,f_approx.*sqrt_M)./sqrt_M/(delv^2);
Pf =  MultiD_times(Pf,sig_3(z)/eps);
error = vdx_fn - Pf; 
