Average Error: 14.3 → 13.4
Time: 35.2s
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}\;x \le -1535735619.0759058:\\ \;\;\;\;\frac{\cos B \cdot \left(-x\right)}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;(\left({\left((2 \cdot x + \left((F \cdot F + 2)_*\right))_*\right)}^{\frac{-1}{2}}\right) \cdot \left(\frac{1}{\sin B} \cdot F\right) + \left(\left(-\cos B\right) \cdot \frac{x}{\sin 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 x < -1535735619.0759058

    1. Initial program 9.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. Simplified9.5

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

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

      \[\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(F \cdot \frac{1}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\]
    7. Applied unpow-prod-down9.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(F \cdot \frac{1}{\sin B}\right) + \left(\frac{-x}{\tan B}\right))_*\]
    8. Taylor expanded around inf 0.6

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}}\]
    9. Simplified0.6

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

    if -1535735619.0759058 < x

    1. Initial program 14.7

      \[\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. Simplified14.7

      \[\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 div-inv14.7

      \[\leadsto (\left({\left((2 \cdot x + \left((F \cdot F + 2)_*\right))_*\right)}^{\frac{-1}{2}}\right) \cdot \color{blue}{\left(F \cdot \frac{1}{\sin B}\right)} + \left(\frac{-x}{\tan B}\right))_*\]
    5. Using strategy rm
    6. Applied tan-quot14.7

      \[\leadsto (\left({\left((2 \cdot x + \left((F \cdot F + 2)_*\right))_*\right)}^{\frac{-1}{2}}\right) \cdot \left(F \cdot \frac{1}{\sin B}\right) + \left(\frac{-x}{\color{blue}{\frac{\sin B}{\cos B}}}\right))_*\]
    7. Applied associate-/r/14.7

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

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

Reproduce

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

sample895.0ms

Algorithm
intervals

simplify407.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
406.0ms
(+ (- (* x (/ 1 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2)))))

prune38.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 13.6b

localize73.0ms

Local error

Found 4 expressions with local error:

17.0b
(pow (fma 2 x (fma F F 2)) -1/2)
6.4b
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))
0.2b
(/ (- x) (tan B))
0.1b
(/ F (sin B))

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
15×add-cube-cbrt
15×*-un-lft-identity
15×add-sqr-sqrt
12×times-frac
add-exp-log
add-cbrt-cube
associate-/r*
pow1
add-log-exp
associate-/l*
log1p-expm1-u
neg-mul-1
expm1-log1p-u
unpow-prod-down
div-inv
frac-2neg
clear-num
fma-udef
associate-/r/
distribute-frac-neg
tan-quot
pow-exp
div-exp
div-sub
pow-pow
cbrt-undiv
pow-to-exp
neg-sub0
Counts
4 → 76
Calls
4 calls:
Slowest
7.0ms
(/ (- x) (tan B))
6.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
1.0ms
(/ F (sin B))
0.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))

series662.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
245.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (/ F (sin B)) (/ (- x) (tan B)))
239.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
127.0ms
(/ (- x) (tan B))
50.0ms
(/ F (sin B))

simplify1.7s

Counts
54 → 88
Calls
54 calls:
Slowest
233.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
225.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))))))
221.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))))))
206.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)))
199.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.4s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 13.0b

localize21.0ms

Local error

Found 4 expressions with local error:

17.0b
(pow (fma 2 x (fma F F 2)) -1/2)
6.4b
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (/ (- x) (tan B)))
0.2b
(* F (/ 1 (sin B)))
0.2b
(/ (- x) (tan B))

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
15×add-cube-cbrt
15×*-un-lft-identity
15×add-sqr-sqrt
12×times-frac
add-exp-log
add-cbrt-cube
pow1
add-log-exp
associate-/l*
log1p-expm1-u
associate-*r*
neg-mul-1
expm1-log1p-u
unpow-prod-down
associate-/r*
div-inv
fma-udef
*-commutative
un-div-inv
associate-/r/
distribute-frac-neg
associate-*r/
tan-quot
pow-exp
div-exp
div-sub
frac-2neg
pow-pow
clear-num
cbrt-undiv
pow-to-exp
neg-sub0
Counts
4 → 77
Calls
4 calls:
Slowest
6.0ms
(/ (- x) (tan B))
2.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
2.0ms
(* F (/ 1 (sin B)))
0.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (/ (- x) (tan B)))

series614.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
227.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
202.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (/ (- x) (tan B)))
117.0ms
(/ (- x) (tan B))
68.0ms
(* F (/ 1 (sin B)))

simplify1.9s

Counts
57 → 89
Calls
57 calls:
Slowest
288.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))))))
263.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)))
234.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)))
200.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.0b

localize27.0ms

Local error

Found 4 expressions with local error:

17.0b
(pow (fma 2 x (fma F F 2)) -1/2)
6.4b
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (* (/ (- x) (sin B)) (cos B)))
0.2b
(* F (/ 1 (sin B)))
0.2b
(* (/ (- x) (sin B)) (cos B))

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
16×associate-*l*
15×add-cube-cbrt
15×*-un-lft-identity
15×add-sqr-sqrt
12×times-frac
10×add-exp-log
add-cbrt-cube
associate-*r*
pow1
add-log-exp
log1p-expm1-u
expm1-log1p-u
unpow-prod-down
neg-mul-1
div-inv
cbrt-unprod
*-commutative
prod-exp
fma-udef
un-div-inv
distribute-frac-neg
associate-*r/
pow-exp
associate-*l/
pow-prod-down
div-exp
pow-pow
cbrt-undiv
pow-to-exp
distribute-lft-neg-out
Counts
4 → 77
Calls
4 calls:
Slowest
12.0ms
(* (/ (- x) (sin B)) (cos B))
2.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
2.0ms
(* F (/ 1 (sin B)))
0.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (* (/ (- x) (sin B)) (cos B)))

series577.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
202.0ms
(fma (pow (fma 2 x (fma F F 2)) -1/2) (* F (/ 1 (sin B))) (* (/ (- x) (sin B)) (cos B)))
195.0ms
(pow (fma 2 x (fma F F 2)) -1/2)
126.0ms
(* (/ (- x) (sin B)) (cos B))
54.0ms
(* F (/ 1 (sin B)))

simplify2.2s

Counts
48 → 89
Calls
48 calls:
Slowest
354.0ms
(* (* (* (/ (- x) (sin B)) (/ (- x) (sin B))) (/ (- x) (sin B))) (* (* (cos B) (cos B)) (cos B)))
279.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))))))
267.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)))
226.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
196.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.5s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 13.0b

localize31.0ms

Local error

Found 4 expressions with local error:

17.0b
(sqrt (fma 2 x (fma F F 2)))
17.0b
(sqrt (fma 2 x (fma F F 2)))
6.4b
(fma (* (pow (sqrt (fma 2 x (fma F F 2))) -1/2) (pow (sqrt (fma 2 x (fma F F 2))) -1/2)) (* F (/ 1 (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))

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
16×add-exp-log
14×add-sqr-sqrt
12×sqrt-prod
12×add-cube-cbrt
12×*-un-lft-identity
12×unpow-prod-down
prod-exp
associate-*l*
associate-*r*
pow-exp
add-cbrt-cube
pow-to-exp
add-log-exp
log1p-expm1-u
pow1
expm1-log1p-u
pow1/2
rem-sqrt-square
fma-udef
cbrt-unprod
pow-prod-up
*-commutative
pow-prod-down
pow2
Counts
4 → 79
Calls
4 calls:
Slowest
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)))
0.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 (/ 1 (sin B))) (/ (- x) (tan B)))

series378.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
212.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 (/ 1 (sin B))) (/ (- x) (tan B)))
59.0ms
(sqrt (fma 2 x (fma F F 2)))
55.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.8s

Counts
50 → 91
Calls
50 calls:
Slowest
247.0ms
(- (/ (* F (sqrt 1/2)) B) (+ (/ x B) (/ (* x (* F (sqrt 1/8))) B)))
159.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))
157.0ms
(- (+ (sqrt 2) (* x (sqrt 1/2))) (* 1/2 (* (pow x 2) (sqrt 1/8))))
145.0ms
(- (+ (* 3/2 (* (sqrt 1/32) (pow x 2))) (sqrt 1/2)) (* x (sqrt 1/8)))
86.0ms
(* -1 (/ (* x (cos B)) (sin B)))

prune1.5s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 10.5b

regimes529.0ms

Accuracy

37.5% (1.3b remaining)

Error of 13.4b against oracle of 12.1b and baseline of 14.2b

bsearch536.0ms

end0.0ms

sample14.4s

Algorithm
intervals