function h = sphere_conserved ( xyz )

%*****************************************************************************80
%
%% sphere_conserved evaluates conserved quantities for the sphere ODE.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Ernst Hairer,
%    Solving differential equations on manifolds,
%    Universite de Geneve,
%    June 2011.
%
%  Input:
%
%    real XYZ(N,3): the current coordinates.
%
%  Output:
%
%    real H(N,2): the conserved quantities.
%
  i1 = 1.6;
  i2 = 1.0;
  i3 = 2.0 / 3.0;

  x = xyz(:,1);
  y = xyz(:,2);
  z = xyz(:,3);

  h1 = x.^2 + y.^2 + z.^2;
  h2 = 0.5 * ( x.^2 / i1 + y.^2 / i2 + z.^2 / i3 );

  h = [ h1; h2 ];

  return
end

