Average Error: 14.9 → 1.3
Time: 1.4m
Precision: 64
Internal Precision: 128
\[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
\[e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]

Error

Bits error versus K

Bits error versus m

Bits error versus n

Bits error versus M

Bits error versus l

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.9

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
  2. Taylor expanded around 0 1.3

    \[\leadsto \color{blue}{1} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
  3. Final simplification1.3

    \[\leadsto e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(FPCore (K m n M l)
  :name "Maksimov and Kolovsky, Equation (32)"
  (* (cos (- (/ (* K (+ m n)) 2) M)) (exp (- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n)))))))

Details

Time bar (total: 1.4m)Debug log

sample118.0ms

Algorithm
intervals
Results
268×(pre true 80)
262×(body real 80)
(body real 640)
(body real 1280)

simplify156.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
156.0ms
(* (cos (- (/ (* K (+ m n)) 2) M)) (exp (- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))))

prune17.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 16.7b

localize67.0ms

Local error

Found 4 expressions with local error:

34.5b
(cos (- (/ (* K (+ m n)) 2) M))
0.0b
(* K (+ m n))
0.0b
(pow (- (/ (+ m n) 2) M) 2)
0.0b
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))

rewrite174.0ms

Algorithm
rewrite-expression-head
Rules
54×prod-diff
48×*-un-lft-identity
46×add-sqr-sqrt
44×add-cube-cbrt
29×distribute-rgt-neg-in
28×distribute-lft-neg-in
27×unpow-prod-down
18×fma-neg
unpow2
add-log-exp
add-exp-log
pow1
log1p-expm1-u
add-cbrt-cube
neg-mul-1
expm1-log1p-u
associate-*r*
sub-neg
distribute-lft-out--
associate--r+
associate-*r/
diff-log
cos-sum
difference-of-squares
associate--r-
flip--
flip-+
*-commutative
pow-exp
neg-log
flip3--
flip3-+
distribute-lft-in
pow-pow
pow-to-exp
cos-diff
distribute-rgt-in
neg-sub0
associate--l-
Counts
4 → 139
Calls
4 calls:
Slowest
159.0ms
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))
6.0ms
(cos (- (/ (* K (+ m n)) 2) M))
6.0ms
(pow (- (/ (+ m n) 2) M) 2)
1.0ms
(* K (+ m n))

series258.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
136.0ms
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))
52.0ms
(cos (- (/ (* K (+ m n)) 2) M))
42.0ms
(pow (- (/ (+ m n) 2) M) 2)
27.0ms
(* K (+ m n))

simplify33.5s

Counts
159 → 151
Calls
159 calls:
Slowest
652.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
648.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
625.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
612.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
598.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))

prune3.2s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.8b

localize7.0ms

Local error

Found 3 expressions with local error:

0.0b
(pow (- (/ (+ m n) 2) M) 2)
0.0b
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))
0.0b
(- (/ (+ m n) 2) M)

rewrite203.0ms

Algorithm
rewrite-expression-head
Rules
54×prod-diff
47×*-un-lft-identity
45×add-sqr-sqrt
43×add-cube-cbrt
29×distribute-rgt-neg-in
28×distribute-lft-neg-in
27×unpow-prod-down
22×fma-neg
unpow2
add-log-exp
add-exp-log
neg-mul-1
pow1
log1p-expm1-u
add-cbrt-cube
sub-neg
expm1-log1p-u
distribute-lft-out--
associate--r+
flip--
diff-log
flip3--
difference-of-squares
associate--r-
div-inv
pow-exp
neg-log
pow-pow
pow-to-exp
neg-sub0
associate--l-
Counts
3 → 127
Calls
3 calls:
Slowest
185.0ms
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))
10.0ms
(pow (- (/ (+ m n) 2) M) 2)
5.0ms
(- (/ (+ m n) 2) M)

series208.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
137.0ms
(- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n))))
46.0ms
(pow (- (/ (+ m n) 2) M) 2)
25.0ms
(- (/ (+ m n) 2) M)

simplify32.7s

Counts
149 → 136
Calls
149 calls:
Slowest
813.0ms
(fma 1 (- (pow (- (/ (+ m n) 2) M) 2)) (- (* (- l (fabs (- m n))) 1)))
619.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
614.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
614.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))
609.0ms
(fma (- (- l (fabs (- m n)))) 1 (* (- l (fabs (- m n))) 1))

prune2.3s

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.8b

localize27.0ms

Local error

Found 4 expressions with local error:

34.5b
(cos (- (/ (* K (+ m n)) 2) M))
34.5b
(cos (- (/ (* K (+ m n)) 2) M))
34.5b
(cos (- (/ (* K (+ m n)) 2) M))
0.5b
(cbrt (cos (- (/ (* K (+ m n)) 2) M)))

rewrite45.0ms

Algorithm
rewrite-expression-head
Rules
cos-sum
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
sub-neg
cos-diff
cbrt-prod
pow1/3
Counts
4 → 49
Calls
4 calls:
Slowest
16.0ms
(cos (- (/ (* K (+ m n)) 2) M))
13.0ms
(cos (- (/ (* K (+ m n)) 2) M))
13.0ms
(cos (- (/ (* K (+ m n)) 2) M))
2.0ms
(cbrt (cos (- (/ (* K (+ m n)) 2) M)))

series426.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
198.0ms
(cbrt (cos (- (/ (* K (+ m n)) 2) M)))
83.0ms
(cos (- (/ (* K (+ m n)) 2) M))
79.0ms
(cos (- (/ (* K (+ m n)) 2) M))
65.0ms
(cos (- (/ (* K (+ m n)) 2) M))

simplify1.5s

Counts
24 → 61
Calls
24 calls:
Slowest
174.0ms
(pow (cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M)) 1/3)
141.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
134.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
124.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
114.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))

prune1.5s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.8b

localize19.0ms

Local error

Found 4 expressions with local error:

34.5b
(cos (- (/ (* K (+ m n)) 2) M))
34.5b
(cos (- (/ (* K (+ m n)) 2) M))
34.5b
(cos (- (/ (* K (+ m n)) 2) M))
34.5b
(cos (- (/ (* K (+ m n)) 2) M))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
cos-sum
add-log-exp
log1p-expm1-u
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
sub-neg
pow1
expm1-log1p-u
add-sqr-sqrt
cos-diff
Counts
4 → 48
Calls
4 calls:
Slowest
9.0ms
(cos (- (/ (* K (+ m n)) 2) M))
6.0ms
(cos (- (/ (* K (+ m n)) 2) M))
6.0ms
(cos (- (/ (* K (+ m n)) 2) M))
6.0ms
(cos (- (/ (* K (+ m n)) 2) M))

series241.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
80.0ms
(cos (- (/ (* K (+ m n)) 2) M))
59.0ms
(cos (- (/ (* K (+ m n)) 2) M))
54.0ms
(cos (- (/ (* K (+ m n)) 2) M))
48.0ms
(cos (- (/ (* K (+ m n)) 2) M))

simplify1.3s

Counts
24 → 60
Calls
24 calls:
Slowest
161.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
141.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
138.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
101.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))
95.0ms
(cos (- (+ (* 1/2 (* m K)) (* 1/2 (* K n))) M))

prune1.4s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.8b

regimes460.0ms

Accuracy

0% (0.2b remaining)

Error of 1.3b against oracle of 1.1b and baseline of 1.3b

bsearch3.0ms

end0.0ms

sample3.5s

Algorithm
intervals
Results
8511×(pre true 80)
8096×(body real 80)
141×(body real 640)
128×(body real 1280)
87×(body real 320)
59×(body real 160)