function [ u, ut, ux, uxx, uxxx ] = kdv_exact_sech ( x, t )

%*****************************************************************************80
%
%% kdv_exact_sech(): exact solution of KDV PDE using sech().
%
%  Discussion:
%
%    This solution u(x,t) satisfies the Korteweg-Devries PDE:
%      u' - 6 u ux + uxxx = 0
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 November 2023
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    John D Cook,
%    Solitons and the KdV equation,
%    03 November 2023,
%    https://www.johndcook.com/blog/2023/11/03/solitons-and-the-kdv-equation/
%
%  Input:
%
%    real x: the position.
%
%    real t: the time.
%
%  Output:
%
%    real u, ut, ux, uxx, uxxx:
%    the values of the solution and its derivatives.
%

%
%  Retrieve parameters a and v.
%
  [ a, v, ~, ~ ] = kdv_parameters ( );

  argument = 0.5 * sqrt ( v ) * ( x - v * t - a );
  sa = sech ( argument );
  ta = tanh ( argument );

  u =    - 0.5  * v     * sa.^2;

  ut =   - 0.5  * v^2.5 * sa.^2 .* ta;

  ux =     0.5  * v^1.5 * sa.^2 .* ta;

  uxx =  + 0.25 * v^2   * sa.^4 ...
         - 0.5  * v^2   * sa.^2 .* ta.^2;

  uxxx =         - v^2.5 * sa.^4 .* ta ...
         + 0.5  * v^2.5 * sa.^2 .* ta.^3;

  return
end

