Average Error: 31.0 → 19.5
Time: 57.9s
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.3399530066993955 \cdot 10^{+154}:\\ \;\;\;\;\sqrt[3]{\left(\frac{-1}{\log base} \cdot \frac{-1}{\log base}\right) \cdot \frac{-1}{\log base}} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;im \le -5.086940247903466 \cdot 10^{+133}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt[3]{{\left(\log base\right)}^{6}}}\\ \mathbf{elif}\;im \le -2.998359259370555 \cdot 10^{+73}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\sqrt{\frac{-1}{re}}} \cdot \sqrt[3]{\sqrt{\frac{-1}{re}}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -6.520207338444156 \cdot 10^{-157}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt[3]{{\left(\log base\right)}^{6}}}\\ \mathbf{elif}\;im \le 8.90817629013856 \cdot 10^{+24}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\sqrt{\frac{-1}{re}}} \cdot \sqrt[3]{\sqrt{\frac{-1}{re}}}\right) \cdot \frac{-1}{\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 4 regimes
  2. if im < -1.3399530066993955e+154

    1. Initial program 62.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. Simplified62.0

      \[\leadsto \color{blue}{\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. Simplified51.9

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

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

    if -1.3399530066993955e+154 < im < -5.086940247903466e+133 or -2.998359259370555e+73 < im < -6.520207338444156e-157

    1. Initial program 16.6

      \[\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. Simplified16.6

      \[\leadsto \color{blue}{\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.8

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}\]
    5. Applied add-cbrt-cube16.9

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}\]
    6. Applied cbrt-unprod16.8

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

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

    if -5.086940247903466e+133 < im < -2.998359259370555e+73 or -6.520207338444156e-157 < im < 8.90817629013856e+24

    1. Initial program 23.6

      \[\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. Simplified23.6

      \[\leadsto \color{blue}{\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. Simplified15.2

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

      \[\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-prod15.3

      \[\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-in15.3

      \[\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)}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt15.3

      \[\leadsto \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]{\color{blue}{\sqrt{\frac{-1}{re}} \cdot \sqrt{\frac{-1}{re}}}}\right)\]
    11. Applied cbrt-prod15.3

      \[\leadsto \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 \color{blue}{\left(\sqrt[3]{\sqrt{\frac{-1}{re}}} \cdot \sqrt[3]{\sqrt{\frac{-1}{re}}}\right)}\]

    if 8.90817629013856e+24 < im

    1. Initial program 41.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. Simplified41.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -1.3399530066993955 \cdot 10^{+154}:\\ \;\;\;\;\sqrt[3]{\left(\frac{-1}{\log base} \cdot \frac{-1}{\log base}\right) \cdot \frac{-1}{\log base}} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{elif}\;im \le -5.086940247903466 \cdot 10^{+133}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt[3]{{\left(\log base\right)}^{6}}}\\ \mathbf{elif}\;im \le -2.998359259370555 \cdot 10^{+73}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\sqrt{\frac{-1}{re}}} \cdot \sqrt[3]{\sqrt{\frac{-1}{re}}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{elif}\;im \le -6.520207338444156 \cdot 10^{-157}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\sqrt[3]{{\left(\log base\right)}^{6}}}\\ \mathbf{elif}\;im \le 8.90817629013856 \cdot 10^{+24}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) + \log \left(\sqrt[3]{\sqrt{\frac{-1}{re}}} \cdot \sqrt[3]{\sqrt{\frac{-1}{re}}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 
(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: 55.3s)Debug log

sample1.2s

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
6.0ms
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0)) (+ (* (log base) (log base)) (* 0 0)))

prune13.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.6b

localize32.0ms

Local error

Found 4 expressions with local error:

31.2b
(sqrt (+ (* re re) (* im im)))
0.6b
(* (log base) (log base))
0.3b
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
0.3b
(* (log (sqrt (+ (* re re) (* im im)))) (log base))

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
20×add-exp-log
20×add-cbrt-cube
12×pow1
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
associate-*l*
cbrt-unprod
prod-exp
associate-*r*
add-log-exp
div-exp
cbrt-undiv
sqrt-prod
*-commutative
log-pow
pow-prod-down
sqrt-div
pow1/2
associate-/l*
div-inv
flip-+
pow-prod-up
pow-plus
times-frac
flip3-+
frac-2neg
associate-/r*
clear-num
rem-sqrt-square
pow2
Counts
4 → 74
Calls
4 calls:
Slowest
11.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
11.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
4.0ms
(* (log base) (log base))
2.0ms
(sqrt (+ (* re re) (* im im)))

series376.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
180.0ms
(* (log base) (log base))
105.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
71.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
19.0ms
(sqrt (+ (* re re) (* im im)))

simplify3.0s

Counts
49 → 86
Calls
49 calls:
Slowest
396.0ms
(- (log (* (log (sqrt (+ (* re re) (* im im)))) (log base))) (log (* (log base) (log base))))
394.0ms
(* -1 (* (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))
342.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (+ (log (log base)) (log (log base))))
319.0ms
(- (log (* (log (sqrt (+ (* re re) (* im im)))) (log base))) (+ (log (log base)) (log (log base))))
304.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (log (* (log base) (log base))))

prune1.2s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 6.4b

localize11.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
log-prod
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
div-inv
add-exp-log
associate-*l*
associate-*r*
add-cbrt-cube
distribute-lft-in
distribute-rgt-in
associate-/r*
add-log-exp
cbrt-unprod
*-commutative
log-pow
prod-exp
associate-*l/
pow-prod-down
frac-2neg
clear-num
Counts
2 → 41
Calls
2 calls:
Slowest
4.0ms
(* (/ -1 (log base)) (log (/ -1 re)))
0.0ms
(/ -1 (log base))

series354.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
262.0ms
(/ -1 (log base))
92.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

simplify1.2s

Counts
27 → 47
Calls
27 calls:
Slowest
478.0ms
(* (* (* (/ -1 (log base)) (/ -1 (log base))) (/ -1 (log base))) (* (* (log (/ -1 re)) (log (/ -1 re))) (log (/ -1 re))))
115.0ms
(* -1 (/ (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))
98.0ms
(* -1 (/ (- (log -1) (log re)) (log base)))
72.0ms
(* (log (/ 1 re)) (/ -1 (log base)))
59.0ms
(* (/ -1 (log base)) (log (/ 1 re)))

prune638.0ms

Pruning

20 alts after pruning (20 fresh and 0 done)

Merged error: 6.4b

localize46.0ms

Local error

Found 4 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
20×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
pow1
associate-*l*
associate-*r*
pow1/3
cbrt-div
add-exp-log
div-inv
add-log-exp
add-cbrt-cube
pow-prod-up
pow-prod-down
cbrt-unprod
*-commutative
associate-*r/
prod-exp
associate-*l/
pow-plus
frac-times
pow2
Counts
4 → 72
Calls
4 calls:
Slowest
6.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
0.0ms
(cbrt (/ -1 re))
0.0ms
(cbrt (/ -1 re))
0.0ms
(cbrt (/ -1 re))

series1.2s

Counts
4 → 12
Calls
4 calls:
Slowest
343.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
327.0ms
(cbrt (/ -1 re))
302.0ms
(cbrt (/ -1 re))
257.0ms
(cbrt (/ -1 re))

simplify198.0ms

Counts
53 → 84
Calls
53 calls:
Slowest
21.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
21.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
14.0ms
(* (/ -1 re) (/ -1 re))
14.0ms
(* (/ -1 re) (/ -1 re))
7.0ms
(* (pow (/ 1 re) 1/3) (cbrt -1))

prune1.4s

Pruning

19 alts after pruning (19 fresh and 0 done)

Merged error: 6.4b

localize31.0ms

Local error

Found 4 expressions with local error:

0.6b
(cbrt (sqrt (/ -1 re)))
0.6b
(cbrt (sqrt (/ -1 re)))
0.6b
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
0.6b
(cbrt (/ -1 re))

rewrite10.0ms

Algorithm
rewrite-expression-head
Rules
26×cbrt-prod
13×add-cube-cbrt
13×*-un-lft-identity
13×add-sqr-sqrt
pow1
sqrt-prod
associate-*l*
associate-*r*
pow1/3
cbrt-div
add-exp-log
div-inv
add-log-exp
add-cbrt-cube
pow-prod-up
pow-prod-down
sqrt-div
cbrt-unprod
*-commutative
associate-*r/
prod-exp
associate-*l/
pow-plus
frac-times
pow2
Counts
4 → 78
Calls
4 calls:
Slowest
7.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
1.0ms
(cbrt (sqrt (/ -1 re)))
1.0ms
(cbrt (sqrt (/ -1 re)))
0.0ms
(cbrt (/ -1 re))

series876.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
352.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
282.0ms
(cbrt (/ -1 re))
129.0ms
(cbrt (sqrt (/ -1 re)))
112.0ms
(cbrt (sqrt (/ -1 re)))

simplify154.0ms

Counts
59 → 90
Calls
59 calls:
Slowest
21.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
21.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
14.0ms
(* (/ -1 re) (/ -1 re))
14.0ms
(* (/ -1 re) (/ -1 re))
6.0ms
(* (pow (/ 1 re) 1/3) (cbrt -1))

prune1.5s

Pruning

19 alts after pruning (18 fresh and 1 done)

Merged error: 6.4b

regimes733.0ms

Accuracy

44% (12.2b remaining)

Error of 19.5b against oracle of 7.3b and baseline of 29.1b

bsearch4.5s

end0.0ms

sample36.7s

Algorithm
intervals