summaryrefslogtreecommitdiffstats
path: root/Modules/cmathmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-06-30 02:29:22 (GMT)
committerGuido van Rossum <guido@python.org>2000-06-30 02:29:22 (GMT)
commitf385c5e544bd7e13c6c6714e85828292d6de8b8e (patch)
tree9005e425c82cedd34d11eef1f75e0e7feea18ca4 /Modules/cmathmodule.c
parent730067effc4347809f66add6af3c63bc46be9dd9 (diff)
downloadcpython-f385c5e544bd7e13c6c6714e85828292d6de8b8e.zip
cpython-f385c5e544bd7e13c6c6714e85828292d6de8b8e.tar.gz
cpython-f385c5e544bd7e13c6c6714e85828292d6de8b8e.tar.bz2
Patch by Nadav Horesh to make acosh and asinh better.
Tim posted a long comment to python-dev (subject: "Controversial patch (cmath)"; date: 6/29/00). The conclusion is that this whole module stinks and this patch isn't perfect, but it's better than the acosh and asinh we had, so let's check it in.
Diffstat (limited to 'Modules/cmathmodule.c')
-rw-r--r--Modules/cmathmodule.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index ab8b5e1..313827b 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -57,8 +57,11 @@ Return the arc cosine of x.";
static Py_complex c_acosh(x)
Py_complex x;
{
- return c_log(c_sum(x,c_prod(c_i,
- c_sqrt(c_diff(c_1,c_prod(x,x))))));
+ Py_complex z;
+ z = c_sqrt(c_half);
+ z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_1)),
+ c_sqrt(c_diff(x,c_1)))));
+ return c_sum(z, z);
}
static char c_acosh_doc [] =
@@ -70,8 +73,11 @@ Return the hyperbolic arccosine of x.";
static Py_complex c_asin(x)
Py_complex x;
{
- return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),
- c_sqrt(c_diff(c_1,c_prod(x,x)))))));
+ Py_complex z;
+ z = c_sqrt(c_half);
+ z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_i)),
+ c_sqrt(c_diff(x,c_i)))));
+ return c_sum(z, z);
}
static char c_asin_doc [] =
@@ -85,9 +91,8 @@ static Py_complex c_asinh(x)
{
/* Break up long expression for WATCOM */
Py_complex z;
- z = c_sum(c_1,c_prod(x,x));
- z = c_diff(c_sqrt(z),x);
- return c_neg(c_log(z));
+ z = c_sum(c_1,c_prod(x, x));
+ return c_log(c_sum(c_sqrt(z), x));
}
static char c_asinh_doc [] =