function octave_mistake_test01 ( )

%*****************************************************************************80
%
%% octave_mistake_test01() puts numbers in an array, except they don't get there!
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 January 2014
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'octave_mistake_test01():\n' );
  fprintf ( 1, '  Set X(I) = 1 / ( I - 5 ) for I = 1 to 10\n' );
  fprintf ( 1, '  but set X(5) to zero.\n' );

  x = zeros ( 10, 1 );

  for i = 1 : 10
    if ( i ~= 5 )
      x(i) == 1 / ( i - 5 ); 
    else
      x(i) = 99;
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now let''s print out X!\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10
    fprintf ( 1, '  X(%d) = %f\n', i, x(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  That was NOT what we expected!\n' );
%
%  ???Maybe we have to use a "real" 1.0 as the numerator???
%
  x = zeros ( 10, 1 );

  for i = 1 : 10
    if ( i ~= 5 )
      x(i) == 1.0 / ( i - 5 ); 
    else
      x(i) = 99.0;
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now let''s print out X!\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10
    fprintf ( 1, '  X(%d) = %f\n', i, x(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  That was NOT what we expected!\n' );
%
%  ???What if we just write them out???
%
  x = [ 1.0 / -4, 1.0 / -3, 1.0 / -2, 1.0 / -1, 99, 1.0 / 1, 1.0 / 2, 1.0 / 3, 1.0 / 4, 1.0 / 5 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now let''s print out X!\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10
    fprintf ( 1, '  X(%d) = %f\n', i, x(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  By this time, the right answer is NOT what we expected!\n' );
%
%  Notice what happens if we initialize x to 1's!
%
  x = ones ( 10, 1 );

  for i = 1 : 10
    if ( i ~= 5 )
      x(i) == 1 / ( i - 5 ); 
    else
      x(i) = 99;
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now let''s print out X!\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10
    fprintf ( 1, '  X(%d) = %f\n', i, x(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now we see that the assignment statement is not assigning x(i)!\n' );
%
%  ANSWER:
%  It's not impossible to misuse a double equals sign instead of an equals sign.
%  It can be hard to notice this mistake.
%  The line that wants to assign x(i) to 1 / ( i - 5 ) is, instead, simply
%  defining a logical expression!
%
  return
end

