Average Error: 0.5 → 0.5
Time: 25.4s
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{\left(a1 \cdot a1 + a2 \cdot a2\right) \cdot \cos th}{\sqrt{2}}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 \left(a1 \cdot a1 + a2 \cdot a2\right)}\]
  3. Using strategy rm
  4. Applied associate-*l/0.5

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

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

Reproduce

herbie shell --seed 2019016 
(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: 24.6s)Debug log

sample254.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)

simplify69.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
69.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

localize26.0ms

Local error

Found 3 expressions with local error:

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

rewrite20.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
add-log-exp
pow1
associate-/l*
flip-+
associate-*r*
flip3-+
associate-/r*
div-inv
cbrt-unprod
associate-*r/
prod-exp
div-exp
cbrt-undiv
frac-times
*-commutative
associate-*l/
pow-prod-down
distribute-lft-in
frac-2neg
sum-log
clear-num
+-commutative
distribute-rgt-in
Counts
3 → 74
Calls
3 calls:
Slowest
11.0ms
(* (/ (cos th) (sqrt 2)) (+ (* a1 a1) (* a2 a2)))
4.0ms
(+ (* a1 a1) (* a2 a2))
3.0ms
(/ (cos th) (sqrt 2))

series294.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
217.0ms
(* (/ (cos th) (sqrt 2)) (+ (* a1 a1) (* a2 a2)))
52.0ms
(/ (cos th) (sqrt 2))
25.0ms
(+ (* a1 a1) (* a2 a2))

simplify2.7s

Counts
64 → 83
Calls
64 calls:
Slowest
394.0ms
(* (cos th) (- (* (* a1 a1) (* a1 a1)) (* (* a2 a2) (* a2 a2))))
393.0ms
(* (sqrt 2) (- (* a1 a1) (* a2 a2)))
225.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
216.0ms
(* (/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2))) (* (* (+ (* a1 a1) (* a2 a2)) (+ (* a1 a1) (* a2 a2))) (+ (* a1 a1) (* a2 a2))))
207.0ms
(+ (* (* a1 a1) (* a1 a1)) (- (* (* a2 a2) (* a2 a2)) (* (* a1 a1) (* a2 a2))))

prune1.0s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize5.0ms

Local error

Found 3 expressions with local error:

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

rewrite23.0ms

Algorithm
rewrite-expression-head
Rules
10×add-exp-log
10×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
pow1
associate-*r/
flip-+
associate-*l*
associate-*r*
times-frac
flip3-+
associate-/r*
associate-/l/
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
associate-/l*
div-inv
*-commutative
pow-prod-down
distribute-lft-in
frac-2neg
sum-log
clear-num
+-commutative
distribute-rgt-in
Counts
3 → 55
Calls
3 calls:
Slowest
10.0ms
(/ (* (cos th) (+ (* a1 a1) (* a2 a2))) (sqrt 2))
8.0ms
(* (cos th) (+ (* a1 a1) (* a2 a2)))
4.0ms
(+ (* a1 a1) (* a2 a2))

series316.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
177.0ms
(/ (* (cos th) (+ (* a1 a1) (* a2 a2))) (sqrt 2))
123.0ms
(* (cos th) (+ (* a1 a1) (* a2 a2)))
15.0ms
(+ (* a1 a1) (* a2 a2))

simplify1.5s

Counts
38 → 64
Calls
38 calls:
Slowest
401.0ms
(* (cos th) (- (* (* a1 a1) (* a1 a1)) (* (* a2 a2) (* a2 a2))))
182.0ms
(/ (* (* (* (cos th) (cos th)) (cos th)) (* (* (+ (* a1 a1) (* a2 a2)) (+ (* a1 a1) (* a2 a2))) (+ (* a1 a1) (* a2 a2)))) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
160.0ms
(+ (* (* a1 a1) (* a1 a1)) (- (* (* a2 a2) (* a2 a2)) (* (* a1 a1) (* a2 a2))))
140.0ms
(* (cos th) (+ (pow (* a1 a1) 3) (pow (* a2 a2) 3)))
129.0ms
(/ (* (* (* (cos th) (+ (* a1 a1) (* a2 a2))) (* (cos th) (+ (* a1 a1) (* a2 a2)))) (* (cos th) (+ (* a1 a1) (* a2 a2)))) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))

prune777.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

localize17.0ms

Local error

Found 4 expressions with local error:

4.5b
(sqrt (+ (* a1 a1) (* a2 a2)))
4.5b
(sqrt (+ (* a1 a1) (* a2 a2)))
0.7b
(/ (cos th) (sqrt 2))
0.4b
(* (/ (cos th) (sqrt 2)) (sqrt (+ (* a1 a1) (* a2 a2))))

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
25×add-sqr-sqrt
23×add-cube-cbrt
23×*-un-lft-identity
18×times-frac
13×associate-*l*
11×add-exp-log
11×add-cbrt-cube
sqrt-prod
sqrt-div
associate-*r*
pow1
add-log-exp
flip-+
flip3-+
associate-/l*
associate-/r*
div-inv
cbrt-unprod
associate-*r/
prod-exp
div-exp
pow1/2
rem-sqrt-square
cbrt-undiv
frac-times
*-commutative
associate-*l/
pow-prod-down
frac-2neg
clear-num
Counts
4 → 92
Calls
4 calls:
Slowest
20.0ms
(* (/ (cos th) (sqrt 2)) (sqrt (+ (* a1 a1) (* a2 a2))))
6.0ms
(/ (cos th) (sqrt 2))
4.0ms
(sqrt (+ (* a1 a1) (* a2 a2)))
4.0ms
(sqrt (+ (* a1 a1) (* a2 a2)))

series246.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
153.0ms
(* (/ (cos th) (sqrt 2)) (sqrt (+ (* a1 a1) (* a2 a2))))
38.0ms
(/ (cos th) (sqrt 2))
32.0ms
(sqrt (+ (* a1 a1) (* a2 a2)))
24.0ms
(sqrt (+ (* a1 a1) (* a2 a2)))

simplify2.4s

Counts
79 → 104
Calls
79 calls:
Slowest
506.0ms
(* (* (* (/ (cos th) (sqrt 2)) (/ (cos th) (sqrt 2))) (/ (cos th) (sqrt 2))) (* (* (sqrt (+ (* a1 a1) (* a2 a2))) (sqrt (+ (* a1 a1) (* a2 a2)))) (sqrt (+ (* a1 a1) (* a2 a2)))))
254.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
189.0ms
(sqrt (+ (* (* a1 a1) (* a1 a1)) (- (* (* a2 a2) (* a2 a2)) (* (* a1 a1) (* a2 a2)))))
168.0ms
(* (sqrt 2) (sqrt (+ (* (* a1 a1) (* a1 a1)) (- (* (* a2 a2) (* a2 a2)) (* (* a1 a1) (* a2 a2))))))
146.0ms
(sqrt (- (* (* a1 a1) (* a1 a1)) (* (* a2 a2) (* a2 a2))))

prune1.3s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0b

localize8.0ms

Local error

Found 3 expressions with local error:

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

rewrite27.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
add-log-exp
pow1
associate-/l*
flip-+
associate-*r*
flip3-+
associate-/r*
div-inv
cbrt-unprod
associate-*r/
prod-exp
div-exp
cbrt-undiv
frac-times
*-commutative
associate-*l/
pow-prod-down
distribute-lft-in
frac-2neg
sum-log
clear-num
+-commutative
distribute-rgt-in
Counts
3 → 74
Calls
3 calls:
Slowest
15.0ms
(* (/ (cos th) (sqrt 2)) (+ (* a2 a2) (* a1 a1)))
6.0ms
(/ (cos th) (sqrt 2))
4.0ms
(+ (* a2 a2) (* a1 a1))

series219.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
159.0ms
(* (/ (cos th) (sqrt 2)) (+ (* a2 a2) (* a1 a1)))
34.0ms
(/ (cos th) (sqrt 2))
26.0ms
(+ (* a2 a2) (* a1 a1))

simplify2.6s

Counts
64 → 83
Calls
64 calls:
Slowest
396.0ms
(* (cos th) (- (* (* a2 a2) (* a2 a2)) (* (* a1 a1) (* a1 a1))))
336.0ms
(* (sqrt 2) (- (* a2 a2) (* a1 a1)))
220.0ms
(/ (* (* (cos th) (cos th)) (cos th)) (* (* (sqrt 2) (sqrt 2)) (sqrt 2)))
190.0ms
(+ (* (* a2 a2) (* a2 a2)) (- (* (* a1 a1) (* a1 a1)) (* (* a2 a2) (* a1 a1))))
180.0ms
(* (* (* (/ (cos th) (sqrt 2)) (/ (cos th) (sqrt 2))) (/ (cos th) (sqrt 2))) (* (* (+ (* a2 a2) (* a1 a1)) (+ (* a2 a2) (* a1 a1))) (+ (* a2 a2) (* a1 a1))))

prune945.0ms

Pruning

6 alts after pruning (3 fresh and 3 done)

Merged error: 0b

regimes521.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.2s

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)