Average Error: 30.6 → 16.7
Time: 2.6s
Precision: 64
Internal Precision: 128
\[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.6813385983305504 \cdot 10^{+75}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 1.509340664542111 \cdot 10^{+112}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \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 < -1.6813385983305504e+75

    1. Initial program 45.1

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

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

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

    if -1.6813385983305504e+75 < re < 1.509340664542111e+112

    1. Initial program 21.2

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right)\]

    if 1.509340664542111e+112 < re

    1. Initial program 51.3

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

      \[\leadsto \log \color{blue}{re}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.6813385983305504 \cdot 10^{+75}:\\ \;\;\;\;\log \left(-re\right)\\ \mathbf{elif}\;re \le 1.509340664542111 \cdot 10^{+112}:\\ \;\;\;\;\log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;\log re\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 2.2s)Debug log

sample47.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

5.0ms
(log (sqrt (+ (* re re) (* im im))))

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.2b

localize38.0ms

Local error

Found 1 expressions with local error:

31.9b
(sqrt (+ (* re re) (* im im)))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
1 → 14
Calls

1 calls. Slowest were:

4.0ms
(sqrt (+ (* re re) (* im im)))

series35.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

35.0ms
(sqrt (+ (* re re) (* im im)))

simplify171.0ms

Counts
9 → 17
Calls

9 calls. Slowest were:

112.0ms
(sqrt (- (* (* re re) (* re re)) (* (* im im) (* im im))))
41.0ms
(sqrt (+ (pow (* re re) 3) (pow (* im im) 3)))
7.0ms
(sqrt (* (cbrt (+ (* re re) (* im im))) (cbrt (+ (* re re) (* im im)))))

prune152.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 9.0b

localize5.0ms

Local error

Found 0 expressions with local error:

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
0 → 0
Calls

0 calls. Slowest were:

series0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

simplify0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

prune5.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 9.0b

localize3.0ms

Local error

Found 0 expressions with local error:

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
0 → 0
Calls

0 calls. Slowest were:

series0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

simplify0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

prune2.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 9.0b

localize3.0ms

Local error

Found 0 expressions with local error:

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
0 → 0
Calls

0 calls. Slowest were:

series0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

simplify0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

prune0.0ms

Pruning

4 alts after pruning (0 fresh and 4 done)

Merged error: 9.0b

regimes300.0ms

Accuracy

59.4% (9.5b remaining)

Error of 16.7b against oracle of 7.2b and baseline of 30.6b

bsearch110.0ms

end0.0ms

sample1.3s

Algorithm
intervals