function x = log_normal_truncated_ab_cdf_inv ( cdf, mu, sigma, a, b )

%*****************************************************************************80
%
%% log_normal_truncated_ab_cdf_inv() inverts the Log Normal truncated AB CDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real CDF, the value of the CDF.
%    0 < CDF < 1.
%
%    real MU, SIGMA, the parameters of the log normal PDF.
%    0.0 < SIGMA.
%
%    real A, B, the lower and upper truncation limits.
%    A < B.
%
%  Output:
%
%    real X, the argument of the PDF with the given CDF.
%
  check = log_normal_truncated_ab_check ( mu, sigma, a, b );

  if ( ~ check )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'LOG_NORMAL_TRUNCATED_AB_CDF_INV - Fatal error!\n' );
    fprintf ( 1, '  Illegal parameter values.\n' );
  end

  if ( cdf <= 0.0 )

    x = a;

  elseif ( 1.0 <= cdf )

    x = b;

  else

    lncdf_a = log_normal_cdf ( a, mu, sigma );
    lncdf_b = log_normal_cdf ( b, mu, sigma );

    lncdf_x = lncdf_a + cdf * ( lncdf_b - lncdf_a );
    x = log_normal_cdf_inv ( lncdf_x, mu, sigma );

  end

  return
end

