function AER = Reheater(x,m3,mG2,T4x1,T0,P)
T3mid = x(1); TG3 = x(2); Q3 = x(3);

Cpg = P(1); dHvap45 = P(2); CpgG = P(11); TG0 = P(12); UA3 = P(15); % Parameters

% Computation of specific enthalpies [J/kg]
h4mid = m3*(Cpg*(T4x1 - T0) + dHvap45); 
h3mid = m3*(Cpg*(T3mid - T0) + dHvap45);

f1 = (h4mid - h3mid + Q3)/615; % AE to find T3mid
f2 = (mG2*CpgG*(TG0 - TG3) - UA3*((TG0+TG3)/2 - (T4x1+T3mid)/2))/1000; %AE to find TG3
f3 = (Q3 - mG2*CpgG*(TG0 - TG3))/1e6; % AE to find Q3

AER = [f1; f2; f3];
end

