Average Error: 13.6 → 12.1
Time: 34.4s
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 -3.708582369031604 \cdot 10^{+154} \lor \neg \left(F \le 2.0342863373936442 \cdot 10^{+151}\right):\\ \;\;\;\;\frac{\left(-x\right) \cdot \cos B}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;(\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))_*\\ \end{array}\]

Error

Bits error versus F

Bits error versus B

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if F < -3.708582369031604e+154 or 2.0342863373936442e+151 < F

    1. Initial program 40.3

      \[\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. Simplified40.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-sqrt40.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-down40.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))_*\]
    6. Using strategy rm
    7. Applied pow-prod-up40.3

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

      \[\leadsto (\left({\left(\sqrt{(2 \cdot x + \left((F \cdot F + 2)_*\right))_*}\right)}^{\color{blue}{-1}}\right) \cdot \left(\frac{F}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\]
    9. Taylor expanded around inf 35.4

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}}\]
    10. Simplified35.4

      \[\leadsto \color{blue}{\frac{\cos B \cdot \left(-x\right)}{\sin B}}\]

    if -3.708582369031604e+154 < F < 2.0342863373936442e+151

    1. Initial program 2.5

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

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

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

      \[\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))_*\]
  3. Recombined 2 regimes into one program.
  4. Final simplification12.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \le -3.708582369031604 \cdot 10^{+154} \lor \neg \left(F \le 2.0342863373936442 \cdot 10^{+151}\right):\\ \;\;\;\;\frac{\left(-x\right) \cdot \cos B}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;(\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))_*\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 +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: 31.6s)Debug log

sample434.0ms

Algorithm
intervals

simplify212.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune27.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 13.9b

localize49.0ms

Local error

Found 4 expressions with local error:

16.3b
(pow (fma 2 x (fma F F 2)) -1/2)
6.8b
(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))

series693.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

252.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))
209.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
165.0ms
(/ (- x) (tan B))
67.0ms
(/ F (sin B))

simplify1.8s

Counts
54 → 88
Calls

54 calls. Slowest were:

262.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))))))
246.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
238.0ms
(- (+ (exp (* -1/2 (- (log -2) (log (/ -1 x))))) (* 3/8 (/ (exp (* -1/2 (- (log -2) (log (/ -1 x))))) (pow x 2)))) (* 1/2 (/ (exp (* -1/2 (- (log -2) (log (/ -1 x))))) x)))

prune1.6s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 13.4b

localize34.0ms

Local error

Found 4 expressions with local error:

16.2b
(sqrt (fma 2 x (fma F F 2)))
16.2b
(sqrt (fma 2 x (fma F F 2)))
6.8b
(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))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

15.0ms
(* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2))
2.0ms
(sqrt (fma 2 x (fma F F 2)))
2.0ms
(sqrt (fma 2 x (fma F F 2)))

series374.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

184.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)))
85.0ms
(sqrt (fma 2 x (fma F F 2)))
53.0ms
(* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2))
52.0ms
(sqrt (fma 2 x (fma F F 2)))

simplify1.9s

Counts
50 → 91
Calls

50 calls. Slowest were:

220.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
183.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))
183.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))

prune1.8s

Pruning

17 alts after pruning (16 fresh and 1 done)

Merged error: 10.9b

localize8.0ms

Local error

Found 4 expressions with local error:

16.2b
(sqrt (fma 2 x (fma F F 2)))
6.8b
(fma (pow (sqrt (fma 2 x (fma F F 2))) -1) (/ F (sin B)) (/ (- x) (tan B)))
0.3b
(pow (sqrt (fma 2 x (fma F F 2))) -1)
0.1b
(/ (- x) (tan B))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

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

series476.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

254.0ms
(fma (pow (sqrt (fma 2 x (fma F F 2))) -1) (/ F (sin B)) (/ (- x) (tan B)))
101.0ms
(/ (- x) (tan B))
65.0ms
(sqrt (fma 2 x (fma F F 2)))
56.0ms
(pow (sqrt (fma 2 x (fma F F 2))) -1)

simplify1.4s

Counts
59 → 92
Calls

59 calls. Slowest were:

223.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))
206.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
184.0ms
(/ (* (* (- x) (- x)) (- x)) (* (* (tan B) (tan B)) (tan B)))

prune1.6s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 10.9b

localize10.0ms

Local error

Found 4 expressions with local error:

16.3b
(pow (fma 2 x (fma F F 2)) -1/2)
6.8b
(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.1b
(/ (tan B) x)

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
4 → 58
Calls

4 calls. Slowest were:

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

series587.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

224.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ -1 (/ (tan B) x)))
208.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
103.0ms
(/ -1 (/ (tan B) x))
51.0ms
(/ (tan B) x)

simplify1.5s

Counts
24 → 70
Calls

24 calls. Slowest were:

252.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))))))
239.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))))))
223.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))

prune1.1s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 10.9b

regimes625.0ms

Accuracy

66.5% (0.7b remaining)

Error of 12.1b against oracle of 11.4b and baseline of 13.5b

bsearch630.0ms

end0.0ms

sample14.6s

Algorithm
intervals