Average Error: 31.0 → 18.1
Time: 1.5m
Precision: 64
Internal Precision: 128
\[\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 -1.3407413557386721 \cdot 10^{+154}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\sqrt[3]{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le -9.185883036294188 \cdot 10^{+33}:\\ \;\;\;\;\frac{\sqrt[3]{\left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right) \cdot \left(\left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right) \cdot \left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right)\right)}}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le -1.0788734361227054 \cdot 10^{-34}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -5.308155628389414 \cdot 10^{-107}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 2.992130444153369 \cdot 10^{-162}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\sqrt[3]{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le 3.4921476078665402 \cdot 10^{+93}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 5 regimes
  2. if im < -1.3407413557386721e+154 or -5.308155628389414e-107 < im < 2.992130444153369e-162

    1. Initial program 38.1

      \[\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}\]
    2. Initial simplification38.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Taylor expanded around -inf 62.8

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    4. Simplified21.4

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube21.6

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right)}}\]
    7. Using strategy rm
    8. Applied associate-*l/21.6

      \[\leadsto \sqrt[3]{\left(\left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \color{blue}{\frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}}}\]
    9. Applied associate-*l/21.6

      \[\leadsto \sqrt[3]{\left(\left(\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \color{blue}{\frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}}\right) \cdot \frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}}\]
    10. Applied associate-*l/21.6

      \[\leadsto \sqrt[3]{\left(\color{blue}{\frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}} \cdot \frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}\right) \cdot \frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}}\]
    11. Applied frac-times21.6

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \left(-1 \cdot \log \left(\frac{-1}{re}\right)\right)}{\log base \cdot \log base}} \cdot \frac{-1 \cdot \log \left(\frac{-1}{re}\right)}{\log base}}\]
    12. Applied frac-times21.6

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\left(\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \left(-1 \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \left(-1 \cdot \log \left(\frac{-1}{re}\right)\right)}{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    13. Applied cbrt-div21.6

      \[\leadsto \color{blue}{\frac{\sqrt[3]{\left(\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \left(-1 \cdot \log \left(\frac{-1}{re}\right)\right)\right) \cdot \left(-1 \cdot \log \left(\frac{-1}{re}\right)\right)}}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    14. Simplified21.6

      \[\leadsto \frac{\color{blue}{-\log \left(\frac{-1}{re}\right)}}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}\]

    if -1.3407413557386721e+154 < im < -9.185883036294188e+33

    1. Initial program 16.0

      \[\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}\]
    2. Initial simplification16.0

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube16.1

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right)\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right)}}}{\log base \cdot \log base}\]

    if -9.185883036294188e+33 < im < -1.0788734361227054e-34

    1. Initial program 14.7

      \[\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}\]
    2. Initial simplification14.7

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Taylor expanded around -inf 62.8

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    4. Simplified30.0

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt30.0

      \[\leadsto \frac{-1}{\log base} \cdot \log \color{blue}{\left(\left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \sqrt[3]{\frac{-1}{re}}\right)}\]
    7. Applied log-prod30.0

      \[\leadsto \frac{-1}{\log base} \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)}\]
    8. Applied distribute-lft-in30.1

      \[\leadsto \color{blue}{\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right)}\]

    if -1.0788734361227054e-34 < im < -5.308155628389414e-107 or 2.992130444153369e-162 < im < 3.4921476078665402e+93

    1. Initial program 16.4

      \[\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}\]
    2. Initial simplification16.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Using strategy rm
    4. Applied times-frac16.3

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \frac{\log base}{\log base}}\]
    5. Simplified16.3

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \color{blue}{1}\]

    if 3.4921476078665402e+93 < im

    1. Initial program 49.7

      \[\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}\]
    2. Initial simplification49.7

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}\]
    3. Taylor expanded around 0 9.8

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification18.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.3407413557386721 \cdot 10^{+154}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\sqrt[3]{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le -9.185883036294188 \cdot 10^{+33}:\\ \;\;\;\;\frac{\sqrt[3]{\left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right) \cdot \left(\left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right) \cdot \left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base\right)\right)}}{\log base \cdot \log base}\\ \mathbf{elif}\;im \le -1.0788734361227054 \cdot 10^{-34}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -5.308155628389414 \cdot 10^{-107}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 2.992130444153369 \cdot 10^{-162}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\sqrt[3]{\log base \cdot \left(\log base \cdot \log base\right)}}\\ \mathbf{elif}\;im \le 3.4921476078665402 \cdot 10^{+93}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

herbie shell --seed 2018365 
(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))))

Details

Time bar (total: 36.5s)Debug log

start1.9s

Algorithm
intervals

setup17.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.9b

localize24.0ms

Local error

Found 4 expressions with local error:

31.5b
(sqrt (+ (* re re) (* im im)))
0.5b
(* (log base) (log base))
0.4b
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
0.4b
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))

rewrite394.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

365.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
21.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
4.0ms
(* (log base) (log base))

series452.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

201.0ms
(* (log base) (log base))
112.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
102.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
36.0ms
(sqrt (+ (* re re) (* im im)))

simplify3.4s

Counts
49 → 86
Calls

49 calls. Slowest were:

401.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (+ (log (log base)) (log (log base))))
389.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (log (* (log base) (log base))))
332.0ms
(* -1 (* (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))

prune1.2s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 8.7b

localize24.0ms

Local error

Found 2 expressions with local error:

0.3b
(* (/ -1 (log base)) (log (/ -1 re)))
0.3b
(/ -1 (log base))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
2 → 41
Calls

2 calls. Slowest were:

9.0ms
(* (/ -1 (log base)) (log (/ -1 re)))
1.0ms
(/ -1 (log base))

series282.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

182.0ms
(/ -1 (log base))
99.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

simplify1.2s

Counts
27 → 47
Calls

27 calls. Slowest were:

508.0ms
(* (* (* (/ -1 (log base)) (/ -1 (log base))) (/ -1 (log base))) (* (* (log (/ -1 re)) (log (/ -1 re))) (log (/ -1 re))))
125.0ms
(* -1 (/ (- (log -1) (log re)) (log base)))
121.0ms
(* -1 (/ (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))

prune640.0ms

Pruning

22 alts after pruning (21 fresh and 1 done)

Merged error: 8.6b

localize39.0ms

Local error

Found 4 expressions with local error:

0.5b
(cbrt (/ -1 re))
0.5b
(cbrt (/ -1 re))
0.5b
(cbrt (/ -1 re))
0.5b
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

8.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
1.0ms
(cbrt (/ -1 re))
1.0ms
(cbrt (/ -1 re))

series1.2s

Counts
4 → 12
Calls

4 calls. Slowest were:

320.0ms
(cbrt (/ -1 re))
301.0ms
(cbrt (/ -1 re))
300.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
273.0ms
(cbrt (/ -1 re))

simplify149.0ms

Counts
53 → 84
Calls

53 calls. Slowest were:

12.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
11.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
10.0ms
(* (pow (/ 1 re) 1/3) (cbrt -1))

prune1.4s

Pruning

24 alts after pruning (22 fresh and 2 done)

Merged error: 8.6b

localize9.0ms

Local error

Found 4 expressions with local error:

0.5b
(cbrt (* (* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))))
0.5b
(* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re))))
0.3b
(* (/ -1 (log base)) (log (/ -1 re)))
0.3b
(* (/ -1 (log base)) (log (/ -1 re)))

rewrite70.0ms

Algorithm
rewrite-expression-head
Counts
4 → 121
Calls

4 calls. Slowest were:

40.0ms
(cbrt (* (* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))))
20.0ms
(* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re))))
4.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

series477.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

138.0ms
(cbrt (* (* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))))
122.0ms
(* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re))))
112.0ms
(* (/ -1 (log base)) (log (/ -1 re)))
104.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

simplify13.8s

Counts
101 → 133
Calls

101 calls. Slowest were:

1.2s
(* (* (* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (* (* (/ -1 (log base)) (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))))
973.0ms
(* (* -1 (log (/ -1 re))) (* (/ -1 (log base)) (log (/ -1 re))))
658.0ms
(cbrt (* (* (* -1 (log (/ -1 re))) (* -1 (log (/ -1 re)))) (* (/ -1 (log base)) (log (/ -1 re)))))

prune1.6s

Pruning

23 alts after pruning (22 fresh and 1 done)

Merged error: 8.6b

regimes920.0ms

Accuracy

50.9% (10.6b remaining)

Error of 18.1b against oracle of 7.4b and baseline of 29.1b

bsearch7.3s