Average Error: 17.1 → 8.0
Time: 38.2s
Precision: 64
Internal Precision: 128
\[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
\[\begin{array}{l} \mathbf{if}\;J \le -8.337566087302848 \cdot 10^{-234} \lor \neg \left(J \le 2.216732952222694 \cdot 10^{-301}\right):\\ \;\;\;\;\left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot -2\right)\right) \cdot \sqrt{1^2 + \left(\frac{1}{2} \cdot \frac{U}{J \cdot \cos \left(K \cdot \frac{1}{2}\right)}\right)^2}^*\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array}\]

Error

Bits error versus J

Bits error versus K

Bits error versus U

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if J < -8.337566087302848e-234 or 2.216732952222694e-301 < J

    1. Initial program 15.4

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
    2. Initial simplification6.4

      \[\leadsto \sqrt{1^2 + \left(\frac{\frac{\frac{U}{2}}{J}}{\cos \left(\frac{K}{2}\right)}\right)^2}^* \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot J\right)\right)\]
    3. Taylor expanded around -inf 6.3

      \[\leadsto \sqrt{1^2 + \color{blue}{\left(\frac{1}{2} \cdot \frac{U}{\cos \left(\frac{1}{2} \cdot K\right) \cdot J}\right)}^2}^* \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot J\right)\right)\]

    if -8.337566087302848e-234 < J < 2.216732952222694e-301

    1. Initial program 40.5

      \[\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}\]
    2. Initial simplification26.4

      \[\leadsto \sqrt{1^2 + \left(\frac{\frac{\frac{U}{2}}{J}}{\cos \left(\frac{K}{2}\right)}\right)^2}^* \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot J\right)\right)\]
    3. Taylor expanded around -inf 26.4

      \[\leadsto \sqrt{1^2 + \color{blue}{\left(\frac{1}{2} \cdot \frac{U}{\cos \left(\frac{1}{2} \cdot K\right) \cdot J}\right)}^2}^* \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot J\right)\right)\]
    4. Using strategy rm
    5. Applied div-inv26.6

      \[\leadsto \sqrt{1^2 + \left(\frac{1}{2} \cdot \color{blue}{\left(U \cdot \frac{1}{\cos \left(\frac{1}{2} \cdot K\right) \cdot J}\right)}\right)^2}^* \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(-2 \cdot J\right)\right)\]
    6. Taylor expanded around inf 30.4

      \[\leadsto \color{blue}{-1 \cdot U}\]
    7. Simplified30.4

      \[\leadsto \color{blue}{-U}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \le -8.337566087302848 \cdot 10^{-234} \lor \neg \left(J \le 2.216732952222694 \cdot 10^{-301}\right):\\ \;\;\;\;\left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot -2\right)\right) \cdot \sqrt{1^2 + \left(\frac{1}{2} \cdot \frac{U}{J \cdot \cos \left(K \cdot \frac{1}{2}\right)}\right)^2}^*\\ \mathbf{else}:\\ \;\;\;\;-U\\ \end{array}\]

Reproduce

herbie shell --seed 2018365 +o rules:numerics
(FPCore (J K U)
  :name "Maksimov and Kolovsky, Equation (3)"
  (* (* (* -2 J) (cos (/ K 2))) (sqrt (+ 1 (pow (/ U (* (* 2 J) (cos (/ K 2)))) 2)))))

Details

Time bar (total: 24.5s)Debug log

start326.0ms

Algorithm
intervals

setup458.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 9.1b

localize60.0ms

Local error

Found 4 expressions with local error:

9.0b
(* (hypot 1 (/ (/ (/ U 2) J) (cos (/ K 2)))) (* (cos (/ K 2)) (* -2 J)))
0.1b
(* (cos (/ K 2)) (* -2 J))
0.1b
(/ (/ (/ U 2) J) (cos (/ K 2)))
0.0b
(hypot 1 (/ (/ (/ U 2) J) (cos (/ K 2))))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 81
Calls

4 calls. Slowest were:

22.0ms
(* (hypot 1 (/ (/ (/ U 2) J) (cos (/ K 2)))) (* (cos (/ K 2)) (* -2 J)))
9.0ms
(/ (/ (/ U 2) J) (cos (/ K 2)))
9.0ms
(* (cos (/ K 2)) (* -2 J))

series615.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

300.0ms
(* (hypot 1 (/ (/ (/ U 2) J) (cos (/ K 2)))) (* (cos (/ K 2)) (* -2 J)))
189.0ms
(hypot 1 (/ (/ (/ U 2) J) (cos (/ K 2))))
79.0ms
(/ (/ (/ U 2) J) (cos (/ K 2)))
46.0ms
(* (cos (/ K 2)) (* -2 J))

simplify2.4s

Counts
59 → 93
Calls

59 calls. Slowest were:

582.0ms
(/ (* (* (/ (/ U 2) J) (/ (/ U 2) J)) (/ (/ U 2) J)) (* (* (cos (/ K 2)) (cos (/ K 2))) (cos (/ K 2))))
205.0ms
(+ (* 1/16 (/ (* (pow K 2) U) J)) (* 1/2 (/ U J)))
160.0ms
(* (* (* (cos (/ K 2)) (cos (/ K 2))) (cos (/ K 2))) (* (* (* -2 J) (* -2 J)) (* -2 J)))

prune1.5s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 5.0b

localize33.0ms

Local error

Found 4 expressions with local error:

9.0b
(* (hypot 1 (* 1/2 (/ U (* (cos (* 1/2 K)) J)))) (* (cos (/ K 2)) (* -2 J)))
0.1b
(* (cos (/ K 2)) (* -2 J))
0.1b
(* (cos (* 1/2 K)) J)
0.1b
(/ U (* (cos (* 1/2 K)) J))

rewrite22.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

10.0ms
(* (hypot 1 (* 1/2 (/ U (* (cos (* 1/2 K)) J)))) (* (cos (/ K 2)) (* -2 J)))
7.0ms
(* (cos (/ K 2)) (* -2 J))
4.0ms
(* (cos (* 1/2 K)) J)

series436.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

283.0ms
(* (hypot 1 (* 1/2 (/ U (* (cos (* 1/2 K)) J)))) (* (cos (/ K 2)) (* -2 J)))
62.0ms
(/ U (* (cos (* 1/2 K)) J))
50.0ms
(* (cos (/ K 2)) (* -2 J))
41.0ms
(* (cos (* 1/2 K)) J)

simplify1.6s

Counts
28 → 75
Calls

28 calls. Slowest were:

202.0ms
(* (* (* (cos (/ K 2)) (cos (/ K 2))) (cos (/ K 2))) (* (* (* -2 J) (* -2 J)) (* -2 J)))
191.0ms
(+ (* 1/8 (/ (* (pow K 2) U) J)) (/ U J))
156.0ms
(+ (log (hypot 1 (* 1/2 (/ U (* (cos (* 1/2 K)) J))))) (+ (log (cos (/ K 2))) (log (* -2 J))))

prune1.5s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.0b

localize27.0ms

Local error

Found 4 expressions with local error:

9.0b
(* (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))) (* (cos (/ K 2)) (* -2 J)))
0.2b
(* U (/ 1 (* (cos (* 1/2 K)) J)))
0.1b
(* (cos (/ K 2)) (* -2 J))
0.1b
(/ 1 (* (cos (* 1/2 K)) J))

rewrite46.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

21.0ms
(* (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))) (* (cos (/ K 2)) (* -2 J)))
9.0ms
(* (cos (/ K 2)) (* -2 J))
7.0ms
(/ 1 (* (cos (* 1/2 K)) J))

series399.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

266.0ms
(* (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))) (* (cos (/ K 2)) (* -2 J)))
51.0ms
(* U (/ 1 (* (cos (* 1/2 K)) J)))
49.0ms
(* (cos (/ K 2)) (* -2 J))
32.0ms
(/ 1 (* (cos (* 1/2 K)) J))

simplify2.9s

Counts
33 → 81
Calls

33 calls. Slowest were:

662.0ms
(sqrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))))
334.0ms
(* (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))) (* (cos (/ K 2)) (* -2 J)))
310.0ms
(* (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))) (* (cos (/ K 2)) (* -2 J)))

prune1.5s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 5.0b

localize64.0ms

Local error

Found 4 expressions with local error:

9.2b
(cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))))
9.2b
(cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))
9.2b
(cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))
3.3b
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

29.0ms
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))
1.0ms
(cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))))
1.0ms
(cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))

series1.1s

Counts
4 → 12
Calls

4 calls. Slowest were:

312.0ms
(cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))
302.0ms
(cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))
285.0ms
(cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J))))))
247.0ms
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))

simplify6.0s

Counts
41 → 81
Calls

41 calls. Slowest were:

402.0ms
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))
368.0ms
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))
307.0ms
(* (* (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2))))) (cbrt (hypot 1 (/ (* 1/2 (/ U J)) (cos (* K 1/2)))))) (* (cbrt (hypot 1 (* 1/2 (* U (/ 1 (* (cos (* 1/2 K)) J)))))) (* (cos (/ K 2)) (* -2 J))))

prune2.2s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 5.0b

regimes723.0ms

Accuracy

-6.9% (4.2b remaining)

Error of 8.0b against oracle of 3.7b and baseline of 7.7b

bsearch433.0ms