From 9a733a623c9e9cc4b3c570555dcd8c88ea06460f Mon Sep 17 00:00:00 2001 From: Kushagra Date: Sun, 15 Mar 2026 14:54:27 +0530 Subject: [PATCH] Wrong formulas The correct formulas for complex trigonometry require cos(z) = (exp(iz) + exp(-iz)) / 2 sin(z) = (exp(iz) - exp(-iz)) / (2i) --- python/cmath.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cmath.py b/python/cmath.py index d45b9ec4..6ba69c1d 100644 --- a/python/cmath.py +++ b/python/cmath.py @@ -134,10 +134,10 @@ def atan(z: complex): return 1j / 2 * log((1 - 1j * z) / (1 + 1j * z)) def cos(z: complex): - return (exp(z) + exp(-z)) / 2 + return (exp(1j * z) + exp(-1j * z)) / 2 def sin(z: complex): - return (exp(z) - exp(-z)) / (2 * 1j) + return (exp(1j * z) - exp(-1j * z)) / (2 * 1j) def tan(z: complex): return sin(z) / cos(z)