\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 \leq -5.775193541606794 \cdot 10^{+65}:\\
\;\;\;\;\frac{\log \left(-im\right)}{\log base}\\
\mathbf{elif}\;im \leq 6.398018456610941 \cdot 10^{+82}:\\
\;\;\;\;0.5 \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{-0.5 \cdot \frac{\log base}{-\log im}}\\
\end{array}(FPCore (re im base) :precision binary64 (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base)
:precision binary64
(if (<= im -5.775193541606794e+65)
(/ (log (- im)) (log base))
(if (<= im 6.398018456610941e+82)
(* 0.5 (/ (log (+ (* re re) (* im im))) (log base)))
(/ 0.5 (* -0.5 (/ (log base) (- (log im))))))))double code(double re, double im, double base) {
return ((log(sqrt((re * re) + (im * im))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
double code(double re, double im, double base) {
double tmp;
if (im <= -5.775193541606794e+65) {
tmp = log(-im) / log(base);
} else if (im <= 6.398018456610941e+82) {
tmp = 0.5 * (log((re * re) + (im * im)) / log(base));
} else {
tmp = 0.5 / (-0.5 * (log(base) / -log(im)));
}
return tmp;
}











Bits error versus re











Bits error versus im











Bits error versus base
Results
| Alternative 1 | |
|---|---|
| Error | 17.8 |
| Cost | 14146 |
| Alternative 2 | |
|---|---|
| Error | 25.5 |
| Cost | 14532 |
| Alternative 3 | |
|---|---|
| Error | 25.8 |
| Cost | 15239 |
| Alternative 4 | |
|---|---|
| Error | 26.9 |
| Cost | 13773 |
| Alternative 5 | |
|---|---|
| Error | 36.5 |
| Cost | 13634 |
| Alternative 6 | |
|---|---|
| Error | 43.7 |
| Cost | 13313 |
| Alternative 7 | |
|---|---|
| Error | 54.4 |
| Cost | 385 |
| Alternative 8 | |
|---|---|
| Error | 57.3 |
| Cost | 64 |

if im < -5.77519354160679366e65Initial program 46.5
Simplified46.4
Taylor expanded around -inf 10.0
Simplified10.0
Simplified10.0
if -5.77519354160679366e65 < im < 6.39801845661094094e82Initial program 22.5
Simplified22.5
rmApplied pow1_binary64_13922.5
Applied log-pow_binary64_16722.5
Applied pow1/2_binary64_15822.5
Applied log-pow_binary64_16722.5
Applied times-frac_binary64_8422.5
Simplified22.5
Simplified22.5
if 6.39801845661094094e82 < im Initial program 49.4
Simplified49.3
rmApplied pow1/2_binary64_15849.3
Applied log-pow_binary64_16749.3
Applied associate-/l*_binary64_2349.3
Taylor expanded around inf 10.4
Simplified10.4
Simplified10.4
Final simplification17.8
herbie shell --seed 2021044
(FPCore (re im base)
:name "math.log/2 on complex, real part"
:precision binary64
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))