`convert/arctanh` := proc( form)
# 
# this function modifies the expression FORM
# by replacing all occurences of ln or inverse hyperbolic trig functions
# by equivalent expressions in arctanh.
# e.g.  convert( ln( x+a), arctanh) => 2*arctanh( (x+a-1)/(x+a+1)).
# 
# Vincent Broman, broman@nosc.mil
#
   local newform, fn, ar;

   if type( form, {string, numeric}) then
      form
   else
      newform := map( procname, form);
      if type( newform, function) and
	 member( op( 0, newform), {ln, arcsinh, arccosh,
	       	     	      	   arccoth, arccsch, arcsech}) and
	 type( [op( newform)], [algebraic])
      then
      	 fn := op( 0, newform);
	 ar := op( 1, newform);
	 if fn = 'arcsinh' then
	    2*arctanh( (ar - 1 + sqrt( ar**2 + 1))/(ar + 1 + sqrt( ar**2 + 1)));
	 elif fn = 'arccosh' then
	    2*arctanh( (ar - 1 + sqrt( ar**2 - 1))/(ar + 1 + sqrt( ar**2 - 1)));
	 elif fn = 'arccoth' then
	    arctanh( 1/ar);
	 elif fn = 'arccsch' then
	    2*arctanh( (1/ar - 1 + sqrt( 1/ar**2 + 1))
	       	      /(1/ar + 1 + sqrt( 1/ar**2 + 1)));
	 elif fn = 'arcsech' then
	    2*arctanh( (1/ar - 1 + sqrt( 1/ar**2 - 1))
	       	      /(1/ar + 1 + sqrt( 1/ar**2 - 1)));
      	 else # 'ln'
	    2*arctanh( (ar - 1)/(ar + 1));
	 fi;
      else
      	 newform;
      fi;
   fi;
end:

`help/text/convert/arctanh` := TEXT(
`FUNCTION: convert/arctanh - convert log and inverse hyperbolic fns to arctanh`,
`      `,
`CALLING SEQUENCE:`,
`   convert( expr, arctanh);`,
`      `,
`SYNOPSIS:   `,
`- convert/arctanh converts all natural logarithms and inverse hyperbolic`,
`  trig functions appearing in the expression expr to a corresponding form`,
`  in arctanh.`,
`      `,
`EXAMPLES:   `,
`> convert( ln( a( x)), arctanh);`,
`                                        a(x) - 1`,
`                              2 arctanh(--------)`,
`                                        a(x) + 1`,
`   `,
`> convert( f( 1 + arcsinh( g)), arctanh);`,
`                                               2     1/2`,
`                                     g - 1 + (g  + 1)`,
`                     f(1 + 2 arctanh(-------------------))`,
`                                               2     1/2`,
`                                     g + 1 + (g  + 1)`,
`   `,
`SEE ALSO:  convert[expln], convert[ln]`,
`   `,
`AUTHOR: Vincent Broman, Naval Command Control and Ocean Surveillance Center`
):

#save `arctanh.m`;
#quit
