Average Error: 31.2 → 17.0
Time: 19.0s
Precision: 64
Internal Precision: 128
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
\[\begin{array}{l} \mathbf{if}\;re \le -2.1579456935513238 \cdot 10^{+106}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log 10}\\ \mathbf{elif}\;re \le 7.774313934961458 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\sqrt{\sqrt[3]{im \cdot im + re \cdot re}} \cdot \left|\sqrt[3]{im \cdot im + re \cdot re}\right|\right)}{\sqrt{\log 10}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\log 10}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if re < -2.1579456935513238e+106

    1. Initial program 51.5

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Taylor expanded around -inf 8.1

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

      \[\leadsto \frac{\log \color{blue}{\left(-re\right)}}{\log 10}\]

    if -2.1579456935513238e+106 < re < 7.774313934961458e+95

    1. Initial program 21.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt21.0

      \[\leadsto \frac{\log \left(\sqrt{\color{blue}{\left(\sqrt[3]{re \cdot re + im \cdot im} \cdot \sqrt[3]{re \cdot re + im \cdot im}\right) \cdot \sqrt[3]{re \cdot re + im \cdot im}}}\right)}{\log 10}\]
    4. Applied sqrt-prod21.0

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

      \[\leadsto \frac{\log \left(\color{blue}{\left|\sqrt[3]{re \cdot re + im \cdot im}\right|} \cdot \sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}{\log 10}\]
    6. Using strategy rm
    7. Applied add-exp-log21.0

      \[\leadsto \frac{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right| \cdot \color{blue}{e^{\log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}}\right)}{\log 10}\]
    8. Applied add-exp-log21.1

      \[\leadsto \frac{\log \left(\color{blue}{e^{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right|\right)}} \cdot e^{\log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}\right)}{\log 10}\]
    9. Applied prod-exp21.1

      \[\leadsto \frac{\log \color{blue}{\left(e^{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right|\right) + \log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}\right)}}{\log 10}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt21.1

      \[\leadsto \frac{\log \left(e^{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right|\right) + \log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}\right)}{\color{blue}{\sqrt{\log 10} \cdot \sqrt{\log 10}}}\]
    12. Applied *-un-lft-identity21.1

      \[\leadsto \frac{\color{blue}{1 \cdot \log \left(e^{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right|\right) + \log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}\right)}}{\sqrt{\log 10} \cdot \sqrt{\log 10}}\]
    13. Applied times-frac21.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(e^{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right|\right) + \log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}\right)}{\sqrt{\log 10}}}\]
    14. Simplified21.0

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

    if 7.774313934961458e+95 < re

    1. Initial program 50.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\]
    2. Taylor expanded around inf 10.1

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

      \[\leadsto \color{blue}{\frac{\log re}{\log 10}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -2.1579456935513238 \cdot 10^{+106}:\\ \;\;\;\;\frac{\log \left(-re\right)}{\log 10}\\ \mathbf{elif}\;re \le 7.774313934961458 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(\sqrt{\sqrt[3]{im \cdot im + re \cdot re}} \cdot \left|\sqrt[3]{im \cdot im + re \cdot re}\right|\right)}{\sqrt{\log 10}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\log 10}\\ \end{array}\]

Reproduce

herbie shell --seed 2019016 
(FPCore (re im)
  :name "math.log10 on complex, real part"
  (/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))

Details

Time bar (total: 16.8s)Debug log

sample62.0ms

Algorithm
intervals
Results
256×(pre true 80)
256×(body real 80)

simplify8.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
8.0ms
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.0b

localize45.0ms

Local error

Found 2 expressions with local error:

31.4b
(sqrt (+ (* re re) (* im im)))
0.6b
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
15×times-frac
14×add-sqr-sqrt
13×add-cube-cbrt
13×*-un-lft-identity
log-pow
pow1
associate-/l*
pow1/2
add-exp-log
sqrt-div
add-cbrt-cube
sqrt-prod
associate-/r*
add-log-exp
flip-+
div-sub
flip3-+
log-div
div-inv
div-exp
frac-2neg
clear-num
rem-sqrt-square
cbrt-undiv
Counts
2 → 51
Calls
2 calls:
Slowest
8.0ms
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10))
3.0ms
(sqrt (+ (* re re) (* im im)))

series181.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
144.0ms
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10))
37.0ms
(sqrt (+ (* re re) (* im im)))

simplify1.0s

Counts
51 → 57
Calls
51 calls:
Slowest
145.0ms
(sqrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
136.0ms
(/ (* (* (log (sqrt (+ (* re re) (* im im)))) (log (sqrt (+ (* re re) (* im im))))) (log (sqrt (+ (* re re) (* im im))))) (* (* (log 10) (log 10)) (log 10)))
136.0ms
(/ (log (sqrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))) (log 10))
78.0ms
(* -1 (/ (log (/ 1 re)) (log 10)))
75.0ms
(* -1 (/ (log (/ -1 re)) (log 10)))

prune721.0ms

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 8.6b

localize31.0ms

Local error

Found 4 expressions with local error:

32.5b
(cbrt (+ (* re re) (* im im)))
32.5b
(cbrt (+ (* re re) (* im im)))
0.6b
(/ (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))) (log 10))
0.3b
(* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))

rewrite59.0ms

Algorithm
rewrite-expression-head
Rules
20×add-cube-cbrt
20×*-un-lft-identity
20×add-sqr-sqrt
18×pow1
15×times-frac
associate-*r*
cbrt-prod
log-pow
add-exp-log
add-cbrt-cube
cbrt-div
sqrt-prod
associate-/l*
pow-prod-down
add-log-exp
flip-+
associate-*r/
sqrt-div
flip3-+
associate-*l*
associate-/r*
div-sub
pow1/3
log-div
div-inv
cbrt-unprod
*-commutative
prod-exp
div-exp
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 88
Calls
4 calls:
Slowest
45.0ms
(/ (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))) (log 10))
7.0ms
(* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))
3.0ms
(cbrt (+ (* re re) (* im im)))
2.0ms
(cbrt (+ (* re re) (* im im)))

series576.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
215.0ms
(/ (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))) (log 10))
128.0ms
(* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))
124.0ms
(cbrt (+ (* re re) (* im im)))
109.0ms
(cbrt (+ (* re re) (* im im)))

simplify2.1s

Counts
77 → 100
Calls
77 calls:
Slowest
440.0ms
(/ (* (* (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im)))))) (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im))))))) (log (* (fabs (cbrt (+ (* re re) (* im im)))) (sqrt (cbrt (+ (* re re) (* im im))))))) (* (* (log 10) (log 10)) (log 10)))
178.0ms
(+ (* (fabs (pow (+ (pow im 2) (pow re 2)) 1/3)) (pow im 1/3)) (* 1/6 (* (* (pow re 2) (fabs (pow (+ (pow im 2) (pow re 2)) 1/3))) (pow (/ 1 (pow im 5)) 1/3))))
160.0ms
(sqrt (cbrt (+ (* (* re re) (* re re)) (- (* (* im im) (* im im)) (* (* re re) (* im im))))))
146.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
141.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))

prune1.5s

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 8.5b

localize30.0ms

Local error

Found 4 expressions with local error:

32.5b
(cbrt (+ (* re re) (* im im)))
32.5b
(cbrt (+ (* re re) (* im im)))
32.5b
(cbrt (+ (* re re) (* im im)))
32.5b
(cbrt (+ (* re re) (* im im)))

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
12×cbrt-prod
add-cube-cbrt
*-un-lft-identity
cbrt-div
add-sqr-sqrt
add-log-exp
flip-+
add-exp-log
pow1/3
add-cbrt-cube
flip3-+
pow1
Counts
4 → 52
Calls
4 calls:
Slowest
1.0ms
(cbrt (+ (* re re) (* im im)))
1.0ms
(cbrt (+ (* re re) (* im im)))
1.0ms
(cbrt (+ (* re re) (* im im)))
1.0ms
(cbrt (+ (* re re) (* im im)))

series444.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
124.0ms
(cbrt (+ (* re re) (* im im)))
123.0ms
(cbrt (+ (* re re) (* im im)))
106.0ms
(cbrt (+ (* re re) (* im im)))
91.0ms
(cbrt (+ (* re re) (* im im)))

simplify862.0ms

Counts
32 → 64
Calls
32 calls:
Slowest
143.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
132.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
102.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
97.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
63.0ms
(cbrt (+ (pow (* re re) 3) (pow (* im im) 3)))

prune1.3s

Pruning

15 alts after pruning (14 fresh and 1 done)

Merged error: 8.5b

localize38.0ms

Local error

Found 4 expressions with local error:

32.5b
(cbrt (+ (* re re) (* im im)))
32.5b
(cbrt (+ (* re re) (* im im)))
5.8b
(exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))
0.6b
(/ (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))) (log 10))

rewrite152.0ms

Algorithm
rewrite-expression-head
Rules
52×log-pow
47×*-un-lft-identity
35×exp-prod
33×times-frac
28×pow1
27×add-cube-cbrt
27×add-sqr-sqrt
20×distribute-lft-out
11×associate-/l*
cbrt-div
add-exp-log
add-cbrt-cube
log-div
cbrt-prod
add-log-exp
flip-+
sqrt-div
exp-diff
flip3-+
associate-+r-
associate-/r*
rem-exp-log
div-sub
pow1/3
div-inv
exp-sum
div-exp
frac-2neg
sum-log
clear-num
cbrt-undiv
Counts
4 → 106
Calls
4 calls:
Slowest
114.0ms
(/ (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))) (log 10))
30.0ms
(exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))
3.0ms
(cbrt (+ (* re re) (* im im)))
2.0ms
(cbrt (+ (* re re) (* im im)))

series624.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
215.0ms
(/ (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))) (log 10))
206.0ms
(exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))
106.0ms
(cbrt (+ (* re re) (* im im)))
97.0ms
(cbrt (+ (* re re) (* im im)))

simplify2.2s

Counts
116 → 118
Calls
116 calls:
Slowest
282.0ms
(/ (* (* (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im)))))))) (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im))))))))) (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (+ (* re re) (* im im))))))))) (* (* (log 10) (log 10)) (log 10)))
142.0ms
(/ (log (exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))))))) (log 10))
128.0ms
(exp (+ (log (fabs (cbrt (+ (* re re) (* im im))))) (log (sqrt (cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))))))
116.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
115.0ms
(cbrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))

prune1.6s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 8.5b

regimes1.6s

Accuracy

59.7% (9.6b remaining)

Error of 17.0b against oracle of 7.4b and baseline of 31.2b

bsearch154.0ms

end0.0ms

sample1.4s

Algorithm
intervals
Results
8000×(pre true 80)
8000×(body real 80)