Average Error: 0.5 → 0.5
Time: 23.8s
Precision: 64
Internal Precision: 128
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
\[\frac{(a1 \cdot a1 + \left(a2 \cdot a2\right))_* \cdot \cos th}{\sqrt{2}}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Derivation

  1. Initial program 0.5

    \[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  2. Simplified0.5

    \[\leadsto \color{blue}{\frac{\cos th}{\sqrt{2}} \cdot (a1 \cdot a1 + \left(a2 \cdot a2\right))_*}\]
  3. Using strategy rm
  4. Applied associate-*l/0.5

    \[\leadsto \color{blue}{\frac{\cos th \cdot (a1 \cdot a1 + \left(a2 \cdot a2\right))_*}{\sqrt{2}}}\]
  5. Final simplification0.5

    \[\leadsto \frac{(a1 \cdot a1 + \left(a2 \cdot a2\right))_* \cdot \cos th}{\sqrt{2}}\]

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  (+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))

Details

Time bar (total: 22.9s)Debug log

sample212.0ms

Algorithm
intervals
Results
447×(pre true 80)
250×(body real 80)
96×(body real 1280)
60×(body real 640)
22×(body real 320)
19×(body real 160)

simplify81.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
81.0ms
(+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2)))

prune19.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.5b

localize39.0ms

Local error

Found 3 expressions with local error:

0.7b
(/ (cos th) (sqrt 2))
0.4b
(* (/ (cos th) (sqrt 2)) (fma a1 a1 (* a2 a2)))
0.0b
(fma a1 a1 (* a2 a2))

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
19×add-cube-cbrt
19×*-un-lft-identity
19×add-sqr-sqrt
18×times-frac
13×associate-*l*
10×add-exp-log
10×add-cbrt-cube
pow1
add-log-exp
associate-/l*
log1p-expm1-u
fma-udef
associate-*r*
associate-/r*
expm1-log1p-u
div-inv
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
*-commutative
associate-*l/
pow-prod-down
distribute-lft-in
frac-2neg
clear-num
distribute-rgt-in
Counts
3 → 73
Calls
3 calls:
Slowest
8.0ms
(/ (cos th) (sqrt 2))
6.0ms
(* (/ (cos th) (sqrt 2)) (fma a1 a1 (* a2 a2)))
0.0ms
(fma a1 a1 (* a2 a2))

series249.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
195.0ms
(* (/ (cos th) (sqrt 2)) (fma a1 a1 (* a2 a2)))
30.0ms
(/ (cos th) (sqrt 2))
25.0ms
(fma a1 a1 (* a2 a2))

simplify1.3s

Counts
57 → 82
Calls
57 calls:
Slowest
254.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
178.0ms
(- (+ (/ 1 (sqrt 2)) (* 1/24 (/ (pow th 4) (sqrt 2)))) (* 1/2 (/ (pow th 2) (sqrt 2))))
123.0ms
(* (/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2))) (* (* (fma a1 a1 (* a2 a2)) (fma a1 a1 (* a2 a2))) (fma a1 a1 (* a2 a2))))
102.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))
100.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))

prune909.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 3 expressions with local error:

0.4b
(/ (* (cos th) (fma a1 a1 (* a2 a2))) (sqrt 2))
0.2b
(* (cos th) (fma a1 a1 (* a2 a2)))
0.0b
(fma a1 a1 (* a2 a2))

rewrite24.0ms

Algorithm
rewrite-expression-head
Rules
10×add-exp-log
10×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
add-log-exp
log1p-expm1-u
fma-udef
associate-*l*
associate-*r*
times-frac
associate-/r*
expm1-log1p-u
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
associate-/l*
div-inv
*-commutative
pow-prod-down
distribute-lft-in
frac-2neg
clear-num
distribute-rgt-in
Counts
3 → 54
Calls
3 calls:
Slowest
15.0ms
(/ (* (cos th) (fma a1 a1 (* a2 a2))) (sqrt 2))
8.0ms
(* (cos th) (fma a1 a1 (* a2 a2)))
0.0ms
(fma a1 a1 (* a2 a2))

series318.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
182.0ms
(/ (* (cos th) (fma a1 a1 (* a2 a2))) (sqrt 2))
118.0ms
(* (cos th) (fma a1 a1 (* a2 a2)))
18.0ms
(fma a1 a1 (* a2 a2))

simplify1.2s

Counts
33 → 63
Calls
33 calls:
Slowest
452.0ms
(* (* (* (cos th) (cos th)) (cos th)) (* (* (fma a1 a1 (* a2 a2)) (fma a1 a1 (* a2 a2))) (fma a1 a1 (* a2 a2))))
114.0ms
(/ (* (* (* (cos th) (cos th)) (cos th)) (* (* (fma a1 a1 (* a2 a2)) (fma a1 a1 (* a2 a2))) (fma a1 a1 (* a2 a2)))) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
114.0ms
(/ (* (* (* (cos th) (fma a1 a1 (* a2 a2))) (* (cos th) (fma a1 a1 (* a2 a2)))) (* (cos th) (fma a1 a1 (* a2 a2)))) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
96.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))
89.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))

prune804.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

localize22.0ms

Local error

Found 4 expressions with local error:

4.5b
(sqrt (fma a1 a1 (* a2 a2)))
0.7b
(/ (cos th) (sqrt 2))
0.4b
(* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2))))
0.2b
(* (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2)))) (hypot a1 a2))

rewrite36.0ms

Algorithm
rewrite-expression-head
Rules
24×add-sqr-sqrt
23×add-cube-cbrt
23×*-un-lft-identity
20×add-exp-log
20×add-cbrt-cube
18×times-frac
14×associate-*l*
11×pow1
associate-*r*
cbrt-unprod
prod-exp
sqrt-prod
add-log-exp
log1p-expm1-u
pow-prod-down
expm1-log1p-u
associate-/l*
associate-*l/
div-exp
associate-/r*
cbrt-undiv
div-inv
*-commutative
hypot-def
fma-udef
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 102
Calls
4 calls:
Slowest
23.0ms
(* (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2)))) (hypot a1 a2))
7.0ms
(* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2))))
3.0ms
(/ (cos th) (sqrt 2))
1.0ms
(sqrt (fma a1 a1 (* a2 a2)))

series492.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
242.0ms
(* (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2)))) (hypot a1 a2))
162.0ms
(* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2))))
49.0ms
(/ (cos th) (sqrt 2))
38.0ms
(sqrt (fma a1 a1 (* a2 a2)))

simplify3.0s

Counts
78 → 114
Calls
78 calls:
Slowest
569.0ms
(* (* (* (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2)))) (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2))))) (* (/ (cos th) (sqrt 2)) (sqrt (fma a1 a1 (* a2 a2))))) (* (* (hypot a1 a2) (hypot a1 a2)) (hypot a1 a2)))
449.0ms
(* (* (* (/ (cos th) (sqrt 2)) (/ (cos th) (sqrt 2))) (/ (cos th) (sqrt 2))) (* (* (sqrt (fma a1 a1 (* a2 a2))) (sqrt (fma a1 a1 (* a2 a2)))) (sqrt (fma a1 a1 (* a2 a2)))))
270.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
170.0ms
(- (+ (/ 1 (sqrt 2)) (* 1/24 (/ (pow th 4) (sqrt 2)))) (* 1/2 (/ (pow th 2) (sqrt 2))))
169.0ms
(+ (+ (- (log (cos th)) (log (sqrt 2))) (log (sqrt (fma a1 a1 (* a2 a2))))) (log (hypot a1 a2)))

prune1.7s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0b

localize6.0ms

Local error

Found 3 expressions with local error:

0.7b
(/ (cos th) (sqrt 2))
0.4b
(* (fma a1 a1 (* a2 a2)) (/ (cos th) (sqrt 2)))
0.0b
(fma a1 a1 (* a2 a2))

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
19×add-cube-cbrt
19×*-un-lft-identity
19×add-sqr-sqrt
18×times-frac
13×associate-*r*
10×add-exp-log
10×add-cbrt-cube
pow1
add-log-exp
associate-/l*
log1p-expm1-u
associate-*l*
associate-/r*
expm1-log1p-u
div-inv
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
fma-udef
*-commutative
associate-*r/
pow-prod-down
frac-2neg
clear-num
Counts
3 → 71
Calls
3 calls:
Slowest
7.0ms
(/ (cos th) (sqrt 2))
6.0ms
(* (fma a1 a1 (* a2 a2)) (/ (cos th) (sqrt 2)))
0.0ms
(fma a1 a1 (* a2 a2))

series247.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
179.0ms
(* (fma a1 a1 (* a2 a2)) (/ (cos th) (sqrt 2)))
36.0ms
(/ (cos th) (sqrt 2))
32.0ms
(fma a1 a1 (* a2 a2))

simplify1.4s

Counts
55 → 80
Calls
55 calls:
Slowest
457.0ms
(* (* (* (fma a1 a1 (* a2 a2)) (fma a1 a1 (* a2 a2))) (fma a1 a1 (* a2 a2))) (* (* (/ (cos th) (sqrt 2)) (/ (cos th) (sqrt 2))) (/ (cos th) (sqrt 2))))
247.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
140.0ms
(- (+ (/ 1 (sqrt 2)) (* 1/24 (/ (pow th 4) (sqrt 2)))) (* 1/2 (/ (pow th 2) (sqrt 2))))
94.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))
91.0ms
(+ (/ (* (pow a1 2) (cos th)) (sqrt 2)) (/ (* (cos th) (pow a2 2)) (sqrt 2)))

prune940.0ms

Pruning

6 alts after pruning (3 fresh and 3 done)

Merged error: 0b

regimes425.0ms

Accuracy

0% (0.4b remaining)

Error of 0.5b against oracle of 0.0b and baseline of 0.5b

bsearch2.0ms

end0.0ms

sample9.5s

Algorithm
intervals
Results
14144×(pre true 80)
7907×(body real 80)
2534×(body real 1280)
2102×(body real 640)
1066×(body real 320)
535×(body real 160)