Average Error: 42.7 → 0.0
Time: 56.0s
Precision: 64
Internal Precision: 4224
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
↓
\[\begin{array}{l}
\mathbf{if}\;re \le 1.470483924151545 \cdot 10^{-276}:\\
\;\;\;\;0.5 \cdot \sqrt{2.0 \cdot \left(-1 \cdot re + re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if re < 1.470483924151545e-276
Initial program 48.6
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
Taylor expanded around -inf 0
\[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{-1 \cdot re} + re\right)}\]
if 1.470483924151545e-276 < re
Initial program 30.6
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
- Using strategy
rm Applied difference-of-squares30.6
\[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{blue}{\left(re + im\right) \cdot \left(re - im\right)}} + re\right)}\]
Applied sqrt-prod0.1
\[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{\sqrt{re + im} \cdot \sqrt{re - im}} + re\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1062930989 876886121 3990119081 3032829768 3060892583 1929069376)'
(FPCore (re im)
:name "math.sqrt on complex, imaginary part, im greater than 0 branch"
(* 0.5 (sqrt (* 2.0 (+ (sqrt (- (* re re) (* im im))) re)))))