function cost_plot ( cost_vec )

%*****************************************************************************80
%
%% cost_plot() plots the cost function over the iterations.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 July 2022
%
%  Author:
%
%    Catherine Higham, Desmond Higham.
%    Modifications by John Burkardt.
%
%  Input:
%
%    real cost_vec(it_num+1): the cost at each iteration.
%
  it_num = size ( cost_vec, 1 ) - 1;

  clf ( );
  i = intspace ( 0, it_num, 101 );
  semilogy ( i, cost_vec(i+1), 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- Iteration -->' );
  ylabel ( '<-- Cost -->' );
  title ( 'Cost reduction during stochastic gradient descent' );
  filename = 'neural_network.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

