function u = schroedinger_nonlinear_exact ( x, t )

%*****************************************************************************80
%
%% schroedinger_nonlinear_exact returns the exact solution.
%
%  Discussion:
%
%    Since we have the exact solution, we can use this formula not only
%    for error computations, but also for the initial condition.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 February 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Willem Hundsdorfer, Jan Verwer,
%    Numerical solution of time-dependent advection-diffusion-reaction equations,
%    Springer, 2003
%    ISBN: 978-3-662-09017-6
%
%    http://eqworld.ipmnet.ru/
%    Exact Solutions > 
%    Nonlinear Partial Differential Equations > 
%    Second-Order Parabolic Partial Differential Equations > 
%    Schrodinger Equation with a Cubic Nonlinearity
%
%  Input:
%
%    real X, T: the spatial positions and time.
%
%  Output:
%
%    real U: the value of the exact solution at X and T.
%
  [ alpha, c1, c2, delta, gamma, t0, xmin, xmax ] = ...
    schroedinger_nonlinear_parameters ( );

  arg1 = i * ( ( c1 / 2.0 ) *   x           + ( alpha - ( c1 / 2.0 )^2 ) * t );
  arg3 = i * ( ( c2 / 2.0 ) * ( x - delta ) + ( alpha - ( c2 / 2.0 )^2 ) * t );

  arg2 = sqrt ( alpha ) * ( x         - c1 * t );
  arg4 = sqrt ( alpha ) * ( x - delta - c2 * t );

  u = sqrt ( alpha ) * sqrt ( 2.0 / gamma ) * ...
    ( exp ( arg1 ) .* sech ( arg2 ) + exp ( arg3 ) .* sech ( arg4 ) );
%
%  Force U to be a row vector.
%
  u = u(:);
  u = transpose ( u );

  return
end
