function [volt1] = equilibrium2(epsilon,epsilon1,c,p0,R,F,potential1,activity,potential0,fixed)
%Finds the equilibrium path with parameter c as an implicit function of pressure
%and temperature. Finds the paths of maximal activity as functions of temperature and
%pressure. Calculates the potential along the path of maximal reaction after varying 
%temperature or pressure in increments, given the potential reading in a range of 
%temperatures and pressures. Tells you how to vary the power supply in line with the 
%temperature or pressure increase.%
for i=1:1000
    v(i)=epsilon*log((p0+(i/10)));
end
for j=1:1000
    w(j)=((R*(293+(j/10)))*log(c));
end

for i=1:1000
    for j=1:1000
        h(i,j)=v(i)-epsilon1(i,j)-w(j);
    end
end

for j=1:1000
    a(j)=min(h(:,j));
end
for j=1:1000
    s(j)=1;
end
for j=1:1000
    for i=1:1000
        if h(i,j)==a(j)
            s(j)=i;
        else if h(i,j)~=a(j)
            s(j)=s(j);
            end
        end
    end
end

for i=1:999
    for j=1:1000
      parpepsilon1(i,j)=(10*(epsilon1(i+1,j)-epsilon1(i,j)));
    end
end
   for i=1:1000
    for j=1:999
      partepsilon1(i,j)=(10*(epsilon1(i,j+1)-epsilon1(i,j)));
    end
end   
for i=1:999
    for j=1:999
        pathtop(i,j)=(((epsilon*(293+(j/10)))*p0)-(((p0+(i/10))*(293+(j/10)))*parpepsilon1(i,j)));
        pathbottom(i,j)=((((-epsilon)*(p0+(i/10)))*log(p0+(i/10)))+((p0+(i/10))*epsilon1(i,j))-(((p0+(i/10))*(293+(j/10)))*partepsilon1(i,j)));
        path(i,j)=(pathtop(i,j)/pathbottom(i,j));
        path2(i,j)=abs(path(i,j));
    end
end
for i=1:999
    v1(i)=max(path(i,:));
    v2(i)=min(path(i,:));
end
w1=max(v1);
w2=min(v2);
G(1)=800;
for j=1:25
   G(j+1)=G(j)+path(round(G(j)),499+j);     
        
end
for j=1:1000
EQP(j)=(p0+(s(j)/10));
T(j)=(293+(j/10));
end

for j=1:25
MQP(j)=(p0+(G(j)/10));
MT(j)=(293+((499+j)/10));
end

for i=1:1000
    for j=1:1000
   g(i,j)=(((4*F)*potential1(i,j))+((R*(293+(j/10)))*log(activity(i,j)))+epsilon1(i,j));    
        
    end
end
for j=1:25
    volt(j)=((1/(4*F))*(g(round(G(j)),499+j)-((R*(293+((499+j)/10)))*log(activity(round(G(j)),499+j)))-epsilon1(round(G(j)),499+j)));
delay(j)=(1500*volt(j));
end    

for j=1:25
    volt1(j)=volt(j)+potential0(499+j);
end
%the potential to drive the motor%
for j=1:25
    volt1fixed(j)=volt1(j)+fixed;
end
%the operating potential with the dc power supply on%

for i=1:1000
    a1(i)=min(h(i,:));
end
for i=1:1000
    s1(i)=1;
end
for i=1:1000
    for j=1:1000
        if h(i,j)==a1(i)
            s1(i)=j;
        else if h(i,j)~=a1(i)
            s1(i)=s1(i);
            end
        end
    end
end


for i=1:999
    for j=1:999
       path1(i,j)=(pathbottom(i,j)/pathtop(i,j));
    end
end
for i=1:999
    v11(i)=max(path1(i,:));
    v21(i)=min(path1(i,:));
end
w1=max(v11);
w2=min(v21);
H(1)=800;
for j=1:25
   H(j+1)=(H(j)+path(round(H(j)),500+j));     
        
end
for i=1:1000
EQP1(i)=(p0+(i/10));
T1(i)=(293+(s1(i)/10));
end

for i=1:25
MQP1(i)=(p0+(i/10));
MT1(i)=(293+(H(i)/10));
end


for i=1:25
    volt2(i)=((1/(4*F))*(g(499+i,round(H(i)))-((R*(293+(round(H(i))/10)))*log(activity(499+i,round(H(i)))))-epsilon1(499+i,round(H(i)))));
delay1(i)=(1500*volt1(i));
end

for i=1:25
  volt3(i)=volt2(i)+potential0(round(H(i)));  
end
%the potential to drive the motor%
for i=1:25
  volt3fixed(i)=volt3(i)+fixed;  
end
%the operating potential with the dc power supply in the background%
end




