Average Error: 31.8 → 12.2
Time: 7.9s
Precision: 64
Internal precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
⬇
\[\begin{array}{l}
\mathbf{if}\;im \le -3.1392156119995164 \cdot 10^{+40}:\\
\;\;\;\;\log \left(-im\right)\\
\mathbf{if}\;im \le 5.8170505962259145 \cdot 10^{+31}:\\
\;\;\;\;\log \left(\sqrt{{im}^2 + {re}^2}\right)\\
\mathbf{else}:\\
\;\;\;\;\log im\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if im < -3.1392156119995164e+40
Initial program 45.7
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
Applied simplify 45.7
\[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]
Applied taylor 0
\[\leadsto \log \left(-1 \cdot im\right)\]
Taylor expanded around -inf 0
\[\leadsto \log \color{blue}{\left(-1 \cdot im\right)}\]
Applied simplify 0
\[\leadsto \color{blue}{\log \left(-im\right)}\]
if -3.1392156119995164e+40 < im < 5.8170505962259145e+31
Initial program 21.9
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
Applied simplify 21.9
\[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]
if 5.8170505962259145e+31 < im
Initial program 42.5
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
Applied simplify 42.5
\[\leadsto \color{blue}{\log \left(\sqrt{{im}^2 + {re}^2}\right)}\]
Applied taylor 0
\[\leadsto \log im\]
Taylor expanded around inf 0
\[\leadsto \log \color{blue}{im}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1223212368 681115741 519175933 3070294417 3186843951 2418817505)'
(FPCore (re im)
:name "math.log/1 on complex, real part"
(log (sqrt (+ (* re re) (* im im)))))