Average Error: 31.4 → 13.3
Time: 13.3s
Precision: 64
Internal precision: 384
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;im \le -4.62649320279714 \cdot 10^{+120}:\\
\;\;\;\;\frac{\log \left(-im\right)}{\log base}\\
\mathbf{if}\;im \le -7.945478500947738 \cdot 10^{-259}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{{im}^2 + re \cdot re}\right)}}\\
\mathbf{if}\;im \le 2.196524360140306 \cdot 10^{-303}:\\
\;\;\;\;\frac{\log re}{\log base}\\
\mathbf{if}\;im \le 1.808337382703412 \cdot 10^{+83}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{{im}^2 + re \cdot re}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if im < -4.62649320279714e+120
Initial program 53.8
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
Applied simplify 53.8
\[\leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^2}}\]
Applied taylor 0.5
\[\leadsto \frac{\log base \cdot \log \left(-1 \cdot im\right)}{{\left(\log base\right)}^2}\]
Taylor expanded around -inf 0.5
\[\leadsto \frac{\log base \cdot \log \color{blue}{\left(-1 \cdot im\right)}}{{\left(\log base\right)}^2}\]
Applied simplify 0.4
\[\leadsto \color{blue}{\frac{\log \left(-im\right)}{\log base}}\]
if -4.62649320279714e+120 < im < -7.945478500947738e-259 or 2.196524360140306e-303 < im < 1.808337382703412e+83
Initial program 20.8
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
Applied simplify 20.8
\[\leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^2}}\]
- Using strategy
rm
Applied clear-num 20.8
\[\leadsto \color{blue}{\frac{1}{\frac{{\left(\log base\right)}^2}{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}}}\]
Applied simplify 20.7
\[\leadsto \frac{1}{\color{blue}{\frac{\log base}{\log \left(\sqrt{{im}^2 + re \cdot re}\right)}}}\]
if -7.945478500947738e-259 < im < 2.196524360140306e-303
Initial program 30.8
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
Applied simplify 30.8
\[\leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^2}}\]
Applied taylor 0.5
\[\leadsto \frac{\log base \cdot \log re}{{\left(\log base\right)}^2}\]
Taylor expanded around 0 0.5
\[\leadsto \frac{\log base \cdot \log \color{blue}{re}}{{\left(\log base\right)}^2}\]
Applied simplify 0.3
\[\leadsto \color{blue}{\frac{\log re}{\log base}}\]
if 1.808337382703412e+83 < im
Initial program 48.9
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\]
Applied simplify 48.9
\[\leadsto \color{blue}{\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^2}}\]
Applied taylor 0.5
\[\leadsto \frac{\log base \cdot \log im}{{\left(\log base\right)}^2}\]
Taylor expanded around inf 0.5
\[\leadsto \frac{\log base \cdot \log \color{blue}{im}}{{\left(\log base\right)}^2}\]
Applied simplify 0.4
\[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (re im base)
:name "math.log/2 on complex, real part"
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0)) (+ (* (log base) (log base)) (* 0 0))))