Average Error: 31.1 → 16.8
Time: 54.5s
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}\;re \le -1.2142195196570871 \cdot 10^{+89}:\\ \;\;\;\;\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base} + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\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 2 regimes
  2. if re < -1.2142195196570871e+89

    1. Initial program 48.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. Simplified48.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 -inf 62.8

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

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

      \[\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-prod9.4

      \[\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-in9.4

      \[\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 pow1/39.4

      \[\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({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right)}\]

    if -1.2142195196570871e+89 < re

    1. Initial program 21.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. Simplified21.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 times-frac21.1

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \color{blue}{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.2142195196570871 \cdot 10^{+89}:\\ \;\;\;\;\log \left(\sqrt[3]{\frac{-1}{re}} \cdot \sqrt[3]{\frac{-1}{re}}\right) \cdot \frac{-1}{\log base} + \log \left({\left(\frac{-1}{re}\right)}^{\frac{1}{3}}\right) \cdot \frac{-1}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\ \end{array}\]

Reproduce

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

sample1.1s

Algorithm
intervals

simplify13.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

13.0ms
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0)) (+ (* (log base) (log base)) (* 0 0)))

prune22.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.4b

localize83.0ms

Local error

Found 4 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

19.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
9.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
7.0ms
(* (log base) (log base))

series417.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

212.0ms
(* (log base) (log base))
95.0ms
(* (log (sqrt (+ (* re re) (* im im)))) (log base))
77.0ms
(/ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log base) (log base)))
33.0ms
(sqrt (+ (* re re) (* im im)))

simplify3.4s

Counts
49 → 86
Calls

49 calls. Slowest were:

576.0ms
(/ (* (* (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) (log base))) (* (log (sqrt (+ (* re re) (* im im)))) (log base))) (* (* (* (log base) (log base)) (log base)) (* (* (log base) (log base)) (log base))))
362.0ms
(- (+ (log (log (sqrt (+ (* re re) (* im im))))) (log (log base))) (+ (log (log base)) (log (log base))))
358.0ms
(* -1 (* (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))

prune1.1s

Pruning

17 alts after pruning (17 fresh and 0 done)

Merged error: 8.8b

localize22.0ms

Local error

Found 3 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 55
Calls

3 calls. Slowest were:

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

series474.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

184.0ms
(/ -1 (log base))
171.0ms
(log (/ -1 re))
120.0ms
(* (/ -1 (log base)) (log (/ -1 re)))

simplify1.1s

Counts
36 → 64
Calls

36 calls. Slowest were:

422.0ms
(* (* (* (/ -1 (log base)) (/ -1 (log base))) (/ -1 (log base))) (* (* (log (/ -1 re)) (log (/ -1 re))) (log (/ -1 re))))
122.0ms
(* -1 (/ (- (log -1) (log re)) (log base)))
117.0ms
(* -1 (/ (log (/ -1 re)) (- (log -1) (log (/ -1 base)))))

prune747.0ms

Pruning

24 alts after pruning (24 fresh and 0 done)

Merged error: 8.7b

localize21.0ms

Local error

Found 4 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

4.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
0.0ms
(cbrt (/ -1 re))
0.0ms
(cbrt (/ -1 re))

series1.2s

Counts
4 → 12
Calls

4 calls. Slowest were:

332.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
310.0ms
(cbrt (/ -1 re))
283.0ms
(cbrt (/ -1 re))
282.0ms
(cbrt (/ -1 re))

simplify168.0ms

Counts
53 → 84
Calls

53 calls. Slowest were:

26.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
22.0ms
(* (pow (/ 1 (pow re 2)) 1/3) (pow (cbrt -1) 2))
8.0ms
(* (/ -1 re) (/ -1 re))

prune1.3s

Pruning

25 alts after pruning (25 fresh and 0 done)

Merged error: 8.7b

localize34.0ms

Local error

Found 4 expressions with local error:

5.0b
(pow (/ -1 re) 1/3)
0.6b
(cbrt (/ -1 re))
0.6b
(cbrt (/ -1 re))
0.5b
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

8.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
2.0ms
(pow (/ -1 re) 1/3)
1.0ms
(cbrt (/ -1 re))

series1.2s

Counts
4 → 12
Calls

4 calls. Slowest were:

350.0ms
(cbrt (/ -1 re))
324.0ms
(* (cbrt (/ -1 re)) (cbrt (/ -1 re)))
294.0ms
(cbrt (/ -1 re))
254.0ms
(pow (/ -1 re) 1/3)

simplify321.0ms

Counts
54 → 86
Calls

54 calls. Slowest were:

81.0ms
(exp (* 1/3 (+ (log (/ 1 re)) (log -1))))
62.0ms
(exp (* 1/3 (- (log -1) (log re))))
24.0ms
(* (log (/ -1 re)) 1/3)

prune1.2s

Pruning

25 alts after pruning (24 fresh and 1 done)

Merged error: 8.7b

regimes867.0ms

Accuracy

55.1% (9.7b remaining)

Error of 16.8b against oracle of 7.2b and baseline of 28.7b

bsearch303.0ms

end0.0ms

sample35.5s

Algorithm
intervals