% mydissfuniii_fzero.m
function [n5, e, iterations] = mydissfuniii_fzero(c, h, o, temp, feq, airs, press)
   

    % Debugging input
    disp('--- Debugging Inputs ---');
    disp(['c = ', num2str(c), ', h = ', num2str(h), ', o = ', num2str(o)]);
    disp(['temp = ', num2str(temp), ', feq = ', num2str(feq)]);
    disp(['airs = ', num2str(airs), ', press = ', num2str(press)]);
    
    % Gibbs free energy function (replace with your own equation)
    gibbs_free_energy = @(n5) (n5^2 - 2*n5 + 1); 

    % Initial guess for fzero
    initial_guess = 1.0;

    % Options for fzero to set tolerance and iteration limits
    options = optimset('TolX', 1e-6, 'TolFun', 1e-6, 'MaxIter', 1000);

    % Use fzero to solve for n5
    [n5, fval, exitflag, output] = fzero(gibbs_free_energy, initial_guess, options);

    % Check for convergence issues
    if exitflag <= 0
        error('fzero failed to converge. Check the input parameters or initial guess.');
    end

    % Energy calculation (this will depend on your equation)
    e = n5^2; 

    % Display iteration information
    iterations = output.iterations;
    disp(['Converged n5: ', num2str(n5)]);
    disp(['Function value (Gibbs Free Energy) at n5: ', num2str(fval)]);
    disp(['Energy e: ', num2str(e)]);
end

