function [ q3, eW]=...
    inner(q1, q2 ,inner_parms, parms)


%this function takes q2 as an argument, rather 
%than generating it in the routine

x_lower=inner_parms(1);  x_upper=inner_parms(2);
y_lower=inner_parms(3);  y_upper=inner_parms(4);
innersteps=inner_parms(5);
dx_max=inner_parms(6); dy_max=inner_parms(7); 
dx_12=inner_parms(8); dy_12=inner_parms(9); 
RL=[x_lower;y_lower];
num_trials=inner_parms(10);

RM_12=[ (x_upper-x_lower)*dx_12 0 ; 0 (y_upper-y_lower)*dy_12];  
RM=[ (x_upper-x_lower)*dx_max 0 ; 0 (y_upper-y_lower)*dy_max];  

p1        = e_V(q1(1), q1(2), parms);
p2        = e_V(q2(1), q2(2), parms);  
%eW=p2/p1;
dq_12=q2-q1;
q0=q2; p0=p2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j=1:innersteps %innersteps
    dq=RM *( rand(2,1) - 0.5);
    qt     = q0 + dq ;
    pt     = e_V(qt(1), qt(2), parms) ;
    if (rand<pt/(p0+pt)), 
      %disp('accept')
      p0=pt; q0=qt;
    end
end
q3=q0;

p3=p0;

q4=q3-dq_12;
p4= e_V(q4(1), q4(2), parms);  
%eW=(p4+p1)/(p2+p3);
eW=(p2+p3)/(p1+p4);
%keyboard;

