% ErrorCalc function to calculate errors associated with using the
% AMTD and Underwood approximation

function [eU1 eU2 eAM1 eAM2] = ErrorCalc(dTcold1, dThot1, dTcold2, dThot2)


%Logarithmic mean temperature difference
LM1 = (dThot1-dTcold1)./log(dThot1./dTcold1);
LM2 = (dThot2-dTcold2)./log(dThot2./dTcold2);

%Arithmetic mean temperature difference
AM1 = (dTcold1+dThot1)./2;
AM2 = (dTcold2+dThot2)./2;

% Underwood temperature difference
U1 = ((((dTcold1).^(1/3))+((dThot1).^(1/3)))./2).^3;
U2 = ((((dTcold2).^(1/3))+((dThot2).^(1/3)))./2).^3;

%AMTD error
eAM1 = (AM1-LM1)./LM1*100;
eAM2 = (AM2-LM2)./LM2*100;

%Underwood error
eU1 = (U1-LM1)./LM1*100;
eU2 = (U2-LM2)./LM2*100;

end
