% % Calculate the pH of a Boric Acid Solution using the fsolve function - % This subroutine contains the boric acid equations to be solved simultaneously % % Variables are: x1 = B(OH)3 % x2 = B(OH)4 - % x3 = H3O + % x4 = OH - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function F = BAequation(X) global Ka Kw CT % % Calculation of the difference functions % F(1,1) = -X(2)+X(3)-X(4); % electroneutrality F(2,1) = X(1)+X(2)-CT; % mass balance F(3,1) = X(2)*X(3)-Ka*X(1); % boric acid equilibrium F(4,1) = X(3)*X(4)-Kw; % water equilibrium