Repository navigation
v0.2.0 — inverse functions, complex powers, quadratic solver
dsh-complex v0.2.0 — inverses, complex powers, quadratic solver
Maintenance release (R60) of the complex-number toolbox. Three user-visible additions, one real correctness fix.
Added
complex_quadratic— solvea z² + b z + c = 0with complex coefficients: the discriminant, both roots (principal square root first), the Vieta invariants−b/aandc/a, and each root's residual|a z² + b z + c|so the answer is self-checking.a = 0degrades to the linear equation;a = b = 0reports "every complex number is a solution" or "no solution" instead of inventing a root. Example:z² + i z + 1 = 0→0.6180339887i,-1.6180339887i.complex_calc(operation="pow")— general complex powera^b = exp(b·log a)with both operands complex:i^i = 0.2078795764,2^(1+i) = 1.5384778027+1.2779225526i,(-1)^0.5 = i.0^(positive real) = 0;0^0and0^(non-positive real)are honest errors.complex_functions— six inverse functions:asin,acos,atan,asinh,acosh,atanh, with the branch cut of each reported in the resultnote.
Fixed
- Silent conjugate values on the branch cuts. The naive principal-square-root identities return the conjugate value exactly on the cuts (real
|x| > 1, imaginary|y| > 1):asin(2)came back as1.5707963268-1.3169578969iinstead of1.5707963268+1.3169578969i, with the same defect inatanh(2),atan(±2i)andasinh(±2i). The cut cases now use the explicit C99 continuation (asin(x) = sign(x)·π/2 + i·acosh|x|,atan(iy) = π/2 + i·sign(y)·atanh(1/|y|),asinh(iy) = acosh|y| + i·sign(y)·π/2,atanh(x) = atanh(1/x) + iπ/2,acos = π/2 − asin) and are verified point-by-point against CPythoncmathon a grid that includes all four cuts.
Changed
- The oracle now ships with the repository:
test/oracle/anchors.py(sections A legacy / B inverses & cuts / C complex powers / D quadratic, with a--checkself-test) — it replaces the throwaway script that previously lived in/tmp. - Tests 123 → 181; coverage baseline 88.60% → 92.72%.
complex_calc's integerpowerand every existing tool anchor are unchanged (no regressions).
Install: dsh plugin --profile web add github:TYEclipse/dsh-complex#v0.2.0
中文说明
新增
complex_quadratic:求 复系数 二次方程a z² + b z + c = 0——判别式、两根(主平方根那支在前)、韦达不变量 −b/a 与 c/a、每根回代残差(答案自检);a = 0 退化为一次方程,a = b = 0 时如实报「任意复数皆解 / 无解」,不编造根。complex_calc新增pow:任意复幂a^b = exp(b·log a)(两操作数都可为复数)——i^i、2^(1+i)、(-1)^0.5;0^(正实数)= 0,0^0与0^(非正实数)诚实报错。complex_functions新增 6 个反函数:asin/acos/atan/asinh/acosh/atanh,各自切割位置写入结果 note。
修复
- 分支切割上的静默错误:朴素「主平方根恒等式」在实轴 |x| > 1、虚轴 |y| > 1 的切割上会返回共轭值(
asin(2)曾给 −1.3169578969i,实为 +1.3169578969i;atanh(2)、atan(±2i)、asinh(±2i)同型)——切割处改用显式 C99 延拓,并用覆盖四条切割的网格逐点与cmath对齐。
变更
- oracle 随仓提交(
test/oracle/anchors.py,--check自校验),取代原先放在/tmp的一次性脚本。 - 测试 123 → 181;覆盖率基线 88.60% → 92.72%;既有工具锚点无回归。
安装:dsh plugin --profile web add github:TYEclipse/dsh-complex#v0.2.0