xref: /openbsd-src/lib/libm/src/s_csinh.c (revision 2f2c00629eff6a304ebffb255fc56f4fa7a1833b)
1*2f2c0062Sguenther /*	$OpenBSD: s_csinh.c,v 1.7 2016/09/12 19:47:02 guenther Exp $	*/
27b36286aSmartynas /*
37b36286aSmartynas  * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
47b36286aSmartynas  *
57b36286aSmartynas  * Permission to use, copy, modify, and distribute this software for any
67b36286aSmartynas  * purpose with or without fee is hereby granted, provided that the above
77b36286aSmartynas  * copyright notice and this permission notice appear in all copies.
87b36286aSmartynas  *
97b36286aSmartynas  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
107b36286aSmartynas  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
117b36286aSmartynas  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
127b36286aSmartynas  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
137b36286aSmartynas  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
147b36286aSmartynas  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
157b36286aSmartynas  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167b36286aSmartynas  */
177b36286aSmartynas 
187b36286aSmartynas /*							csinh
197b36286aSmartynas  *
207b36286aSmartynas  *	Complex hyperbolic sine
217b36286aSmartynas  *
227b36286aSmartynas  *
237b36286aSmartynas  *
247b36286aSmartynas  * SYNOPSIS:
257b36286aSmartynas  *
267b36286aSmartynas  * double complex csinh();
277b36286aSmartynas  * double complex z, w;
287b36286aSmartynas  *
297b36286aSmartynas  * w = csinh (z);
307b36286aSmartynas  *
317b36286aSmartynas  * DESCRIPTION:
327b36286aSmartynas  *
337b36286aSmartynas  * csinh z = (cexp(z) - cexp(-z))/2
347b36286aSmartynas  *         = sinh x * cos y  +  i cosh x * sin y .
357b36286aSmartynas  *
367b36286aSmartynas  * ACCURACY:
377b36286aSmartynas  *
387b36286aSmartynas  *                      Relative error:
397b36286aSmartynas  * arithmetic   domain     # trials      peak         rms
407b36286aSmartynas  *    IEEE      -10,+10     30000       3.1e-16     8.2e-17
417b36286aSmartynas  *
427b36286aSmartynas  */
437b36286aSmartynas 
447b36286aSmartynas #include <complex.h>
45de3697aaSmartynas #include <float.h>
467b36286aSmartynas #include <math.h>
477b36286aSmartynas 
487b36286aSmartynas double complex
csinh(double complex z)497b36286aSmartynas csinh(double complex z)
507b36286aSmartynas {
517b36286aSmartynas 	double complex w;
527b36286aSmartynas 	double x, y;
537b36286aSmartynas 
547b36286aSmartynas 	x = creal(z);
557b36286aSmartynas 	y = cimag(z);
567b36286aSmartynas 	w = sinh (x) * cos (y)  +  (cosh (x) * sin (y)) * I;
577b36286aSmartynas 	return (w);
587b36286aSmartynas }
59*2f2c0062Sguenther DEF_STD(csinh);
60*2f2c0062Sguenther LDBL_MAYBE_UNUSED_CLONE(csinh);
61