Average Error: 13.7 → 0.3
Time: 37.1s
Precision: 64
Internal Precision: 128
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
\[\begin{array}{l} \mathbf{if}\;F \le -247587564.04612592:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \left(\frac{1}{{F}^{2} \cdot \sin B} - \frac{1}{\sin B}\right)\\ \mathbf{elif}\;F \le 19780.345943679087:\\ \;\;\;\;(\left({\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}} \cdot {\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}}\right) \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\sin B} - \frac{1}{{F}^{2} \cdot \sin B}\right) + x \cdot \frac{-1}{\tan B}\\ \end{array}\]

Error

Bits error versus F

Bits error versus B

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if F < -247587564.04612592

    1. Initial program 25.4

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Taylor expanded around -inf 0.2

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\left(\frac{1}{{F}^{2} \cdot \sin B} - \frac{1}{\sin B}\right)}\]

    if -247587564.04612592 < F < 19780.345943679087

    1. Initial program 0.4

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{(\left({\left((2 \cdot x + \left((F \cdot F + 2)_*\right))_*\right)}^{\frac{-1}{2}}\right) \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.3

      \[\leadsto (\left({\color{blue}{\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*} \cdot \sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}}^{\frac{-1}{2}}\right) \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\]
    5. Applied unpow-prod-down0.3

      \[\leadsto (\color{blue}{\left({\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}} \cdot {\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}}\right)} \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\]

    if 19780.345943679087 < F

    1. Initial program 24.6

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Taylor expanded around inf 0.2

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\left(\frac{1}{\sin B} - \frac{1}{{F}^{2} \cdot \sin B}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \le -247587564.04612592:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \left(\frac{1}{{F}^{2} \cdot \sin B} - \frac{1}{\sin B}\right)\\ \mathbf{elif}\;F \le 19780.345943679087:\\ \;\;\;\;(\left({\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}} \cdot {\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\frac{-1}{2}}\right) \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\sin B} - \frac{1}{{F}^{2} \cdot \sin B}\right) + x \cdot \frac{-1}{\tan B}\\ \end{array}\]

Reproduce

herbie shell --seed 2019004 +o rules:numerics
(FPCore (F B x)
  :name "VandenBroeck and Keller, Equation (23)"
  (+ (- (* x (/ 1 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))))))

Details

Time bar (total: 35.1s)Debug log

sample590.0ms

Algorithm
intervals

simplify153.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

152.0ms
(+ (- (* x (/ 1 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))))

prune22.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 14.7b

localize85.0ms

Local error

Found 4 expressions with local error:

20.7b
(pow (fma 2 x (fma F F 2)) -1/2)
7.9b
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))
0.1b
(/ (- x) (tan B))
0.1b
(/ F (sin B))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

6.0ms
(/ (- x) (tan B))
5.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
1.0ms
(/ F (sin B))

series688.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

284.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))
221.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
111.0ms
(/ (- x) (tan B))
71.0ms
(/ F (sin B))

simplify1.9s

Counts
54 → 88
Calls

54 calls. Slowest were:

243.0ms
(- (/ (* F (exp (* -1/2 (- (log 2) (log (/ 1 x)))))) (sin B)) (+ (/ (* x (cos B)) (sin B)) (* 1/2 (/ (* F (exp (* -1/2 (- (log 2) (log (/ 1 x)))))) (* x (sin B))))))
242.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
224.0ms
(- (+ (* 3/8 (/ (exp (* -1/2 (- (log 2) (log (/ 1 x))))) (pow x 2))) (exp (* -1/2 (- (log 2) (log (/ 1 x)))))) (* 1/2 (/ (exp (* -1/2 (- (log 2) (log (/ 1 x))))) x)))

prune1.5s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 14.2b

localize17.0ms

Local error

Found 4 expressions with local error:

20.7b
(sqrt (fma 2 x (fma F F 2)))
20.7b
(sqrt (fma 2 x (fma F F 2)))
7.9b
(fma (* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2)) (/ F (sin B)) (/ (- x) (tan B)))
0.6b
(* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

7.0ms
(* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2))
1.0ms
(sqrt (fma 2 x (fma F F 2)))
1.0ms
(sqrt (fma 2 x (fma F F 2)))

series353.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

181.0ms
(fma (* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2)) (/ F (sin B)) (/ (- x) (tan B)))
63.0ms
(sqrt (fma 2 x (fma F F 2)))
62.0ms
(sqrt (fma 2 x (fma F F 2)))
46.0ms
(* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2))

simplify2.0s

Counts
50 → 91
Calls

50 calls. Slowest were:

319.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
187.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))
179.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))

prune1.8s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 12.5b

localize21.0ms

Local error

Found 4 expressions with local error:

20.7b
(pow (fma 2 x (fma F F 2)) -1/2)
7.9b
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ -1 (/ (tan B) x)))
0.3b
(/ -1 (/ (tan B) x))
0.2b
(/ (tan B) x)

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
4 → 58
Calls

4 calls. Slowest were:

3.0ms
(/ (tan B) x)
1.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
0.0ms
(/ -1 (/ (tan B) x))

series522.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

198.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ -1 (/ (tan B) x)))
185.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
88.0ms
(/ -1 (/ (tan B) x))
51.0ms
(/ (tan B) x)

simplify1.6s

Counts
24 → 70
Calls

24 calls. Slowest were:

281.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
253.0ms
(- (/ (* (exp (* -1/2 (- (log -2) (log (/ -1 x))))) F) (sin B)) (+ (/ (* x (cos B)) (sin B)) (* 1/2 (/ (* (exp (* -1/2 (- (log -2) (log (/ -1 x))))) F) (* x (sin B))))))
217.0ms
(- (/ (* F (exp (* -1/2 (- (log 2) (log (/ 1 x)))))) (sin B)) (+ (/ (* x (cos B)) (sin B)) (* 1/2 (/ (* F (exp (* -1/2 (- (log 2) (log (/ 1 x)))))) (* x (sin B))))))

prune1.3s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 12.5b

localize51.0ms

Local error

Found 4 expressions with local error:

20.7b
(pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))
8.0b
(* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))))
0.3b
(* x (/ 1 (tan B)))
0.2b
(/ 1 (tan B))

rewrite72.0ms

Algorithm
rewrite-expression-head
Counts
4 → 95
Calls

4 calls. Slowest were:

52.0ms
(* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))))
15.0ms
(pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))
2.0ms
(* x (/ 1 (tan B)))

series459.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

169.0ms
(* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))))
163.0ms
(* x (/ 1 (tan B)))
80.0ms
(pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))
47.0ms
(/ 1 (tan B))

simplify2.8s

Counts
63 → 107
Calls

63 calls. Slowest were:

417.0ms
(- (pow 2 -1/2) (+ (* 1/2 (* (pow F 2) (sqrt 1/8))) (* 1/2 (* x (sqrt 1/2)))))
222.0ms
(+ (log (/ F (sin B))) (* (log (+ (+ (* F F) 2) (* 2 x))) (- (/ 1 2))))
216.0ms
(* (* (* (/ F (sin B)) (/ F (sin B))) (/ F (sin B))) (* (* (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))))

prune1.8s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes410.0ms

Accuracy

97.9% (0.2b remaining)

Error of 0.3b against oracle of 0.1b and baseline of 10.6b

bsearch1.7s

end0.0ms

sample15.2s

Algorithm
intervals