Average Error: 30.9 → 17.2
Time: 53.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 -3.5682013288131524 \cdot 10^{+182}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right) + \frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right)\\ \mathbf{elif}\;im \le -8.397655948177386 \cdot 10^{-157}:\\ \;\;\;\;\sqrt[3]{\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3}} \cdot \left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\right)}\\ \mathbf{elif}\;im \le 1.0408756895191287 \cdot 10^{-157}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \left(\log \left(\sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right)\right)\\ \mathbf{elif}\;im \le 2.8851346015141857 \cdot 10^{+66}:\\ \;\;\;\;\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\right)\\ \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 < -3.5682013288131524e+182

    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. Simplified52.1

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

      \[\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-prod52.1

      \[\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-rgt-in52.1

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

    if -3.5682013288131524e+182 < im < -8.397655948177386e-157

    1. Initial program 19.2

      \[\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. Simplified19.2

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

      \[\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-cube19.5

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

      \[\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. Applied add-cbrt-cube19.4

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \color{blue}{\sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}}{\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)}}\]
    8. Applied add-cbrt-cube19.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}} \cdot \sqrt[3]{\left(\log base \cdot \log base\right) \cdot \log base}}{\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)}}\]
    9. Applied cbrt-unprod19.4

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}}}{\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)}}\]
    10. Applied cbrt-undiv19.3

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)\right) \cdot \left(\left(\log base \cdot \log base\right) \cdot \log base\right)}{\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)}}}\]
    11. Simplified19.3

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

    if -8.397655948177386e-157 < im < 1.0408756895191287e-157

    1. Initial program 30.3

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

      \[\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. Simplified6.5

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

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

      \[\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. Using strategy rm
    9. Applied pow1/36.5

      \[\leadsto \frac{-1}{\log base} \cdot \left(\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \color{blue}{{\left(\frac{-1}{re}\right)}^{\frac{1}{3}}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)\]
    10. Applied pow1/36.5

      \[\leadsto \frac{-1}{\log base} \cdot \left(\log \left(\color{blue}{{\left(\frac{-1}{re}\right)}^{\frac{1}{3}}} \cdot {\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) + \log \left(\sqrt[3]{\frac{-1}{re}}\right)\right)\]
    11. Applied pow-prod-up6.5

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

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

    if 1.0408756895191287e-157 < im < 2.8851346015141857e+66

    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. Simplified16.4

      \[\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 div-inv16.5

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

    if 2.8851346015141857e+66 < im

    1. Initial program 45.2

      \[\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. Simplified45.2

      \[\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 10.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -3.5682013288131524 \cdot 10^{+182}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}}\right) + \frac{-1}{\log base} \cdot \log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right)\\ \mathbf{elif}\;im \le -8.397655948177386 \cdot 10^{-157}:\\ \;\;\;\;\sqrt[3]{\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{{\left(\log base\right)}^{3}} \cdot \left(\log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\right)}\\ \mathbf{elif}\;im \le 1.0408756895191287 \cdot 10^{-157}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \left(\log \left(\sqrt[3]{\frac{-1}{re}}\right) + \log \left({\left(\frac{-1}{re}\right)}^{\frac{2}{3}}\right)\right)\\ \mathbf{elif}\;im \le 2.8851346015141857 \cdot 10^{+66}:\\ \;\;\;\;\frac{1}{\log base \cdot \log base} \cdot \left(\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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

sample960.0ms

Algorithm
intervals
Results
744.0ms279×body10240exit
135.0ms556×body80nan
49.0ms256×body80valid

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)))

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.9b

localize47.0ms

Local error

Found 4 expressions with local error:

30.5b
(sqrt (+ (* re re) (* im im)))
0.5b
(* (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))

rewrite401.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
385.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
7.0ms
(* (log base) (log base))
4.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
3.0ms
(sqrt (+ (* re re) (* im im)))

series406.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
216.0ms
(* (log base) (log base))
91.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
80.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
19.0ms
(sqrt (+ (* re re) (* im im)))

simplify3.2s

Counts
49 → 86
Calls
49 calls:
Slowest
363.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (log (* (log base) (log base))))
353.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (+ (log (log base)) (log (log base))))
336.0ms
(* -1 (* (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))
320.0ms
(pow (- (log -1) (log (/ -1 base))) 2)
309.0ms
(- (log (* (log (sqrt (+ (* re re) (* im im)))) (log base))) (log (* (log base) (log base))))

prune1.1s

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 6.5b

localize18.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.0ms

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

series490.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
197.0ms
(/ -1 (log base))
175.0ms
(log (/ -1 re))
118.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

simplify1.2s

Counts
36 → 64
Calls
36 calls:
Slowest
458.0ms
(* (* (* (/ -1 (log base)) (/ -1 (log base))) (/ -1 (log base))) (* (* (log (/ -1 re)) (log (/ -1 re))) (log (/ -1 re))))
136.0ms
(* -1 (/ (- (log -1) (log re)) (log base)))
125.0ms
(* -1 (/ (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))
61.0ms
(* (log (/ 1 re)) (/ -1 (log base)))
53.0ms
(+ (log (/ -1 (log base))) (log (log (/ -1 re))))

prune594.0ms

Pruning

21 alts after pruning (21 fresh and 0 done)

Merged error: 6.4b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite10.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
7.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
1.0ms
(cbrt (/ -1 re))
1.0ms
(cbrt (/ -1 re))
1.0ms
(cbrt (/ -1 re))

series1.2s

Counts
4 → 12
Calls
4 calls:
Slowest
311.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
297.0ms
(cbrt (/ -1 re))
282.0ms
(cbrt (/ -1 re))
281.0ms
(cbrt (/ -1 re))

simplify147.0ms

Counts
53 → 84
Calls
53 calls:
Slowest
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))
9.0ms
(* (/ -1 re) (/ -1 re))
7.0ms
(* (/ -1 re) (/ -1 re))
6.0ms
(* (pow (/ 1 re) 1/3) (cbrt -1))

prune1.1s

Pruning

20 alts after pruning (20 fresh and 0 done)

Merged error: 6.4b

localize14.0ms

Local error

Found 4 expressions with local error:

0.8b
(cbrt (/ -1 re))
0.8b
(cbrt (/ -1 re))
0.8b
(cbrt (/ -1 re))
0.5b
(* (cbrt (/ -1 re)) (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
333.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
319.0ms
(cbrt (/ -1 re))
302.0ms
(cbrt (/ -1 re))
291.0ms
(cbrt (/ -1 re))

simplify119.0ms

Counts
53 → 84
Calls
53 calls:
Slowest
12.0ms
(* (/ -1 re) (/ -1 re))
12.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
10.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
8.0ms
(* (/ -1 re) (/ -1 re))
6.0ms
(* (pow (/ 1 re) 1/3) (cbrt -1))

prune1.0s

Pruning

20 alts after pruning (19 fresh and 1 done)

Merged error: 6.4b

regimes806.0ms

Accuracy

52.5% (10.0b remaining)

Error of 17.2b against oracle of 7.1b and baseline of 28.3b

bsearch2.4s

end0.0ms

sample34.9s

Algorithm
intervals
Results
26.8s7990×body10240exit
4.8s16018×body80nan
2.6s8000×body80valid