Average Error: 28.0 → 8.0
Time: 18.5s
Precision: 64
Internal Precision: 128
\[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
\[\begin{array}{l} \mathbf{if}\;{cos}^{2} \le 1.5034798266949682 \cdot 10^{-306} \lor \neg \left({cos}^{2} \le 1.5266182343325565 \cdot 10^{+96}\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot \left(sin \cdot \left(\left(sin \cdot x\right) \cdot cos\right)\right)\right) \cdot cos}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{cos}^{2} \cdot \left(\left(sin \cdot x\right) \cdot \left(sin \cdot x\right)\right)}\\ \end{array}\]

Error

Bits error versus x

Bits error versus cos

Bits error versus sin

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (pow cos 2) < 1.5034798266949682e-306 or 1.5266182343325565e+96 < (pow cos 2)

    1. Initial program 31.1

      \[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
    2. Using strategy rm
    3. Applied unpow231.1

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot \color{blue}{\left(sin \cdot sin\right)}\right) \cdot x\right)}\]
    4. Applied associate-*r*27.1

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\color{blue}{\left(\left(x \cdot sin\right) \cdot sin\right)} \cdot x\right)}\]
    5. Using strategy rm
    6. Applied unpow227.1

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(cos \cdot cos\right)} \cdot \left(\left(\left(x \cdot sin\right) \cdot sin\right) \cdot x\right)}\]
    7. Applied associate-*l*19.1

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{cos \cdot \left(cos \cdot \left(\left(\left(x \cdot sin\right) \cdot sin\right) \cdot x\right)\right)}}\]
    8. Using strategy rm
    9. Applied associate-*r*15.2

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{cos \cdot \color{blue}{\left(\left(cos \cdot \left(\left(x \cdot sin\right) \cdot sin\right)\right) \cdot x\right)}}\]
    10. Using strategy rm
    11. Applied associate-*r*8.6

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

    if 1.5034798266949682e-306 < (pow cos 2) < 1.5266182343325565e+96

    1. Initial program 21.3

      \[\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\]
    2. Using strategy rm
    3. Applied unpow221.3

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot \color{blue}{\left(sin \cdot sin\right)}\right) \cdot x\right)}\]
    4. Applied associate-*r*10.8

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\color{blue}{\left(\left(x \cdot sin\right) \cdot sin\right)} \cdot x\right)}\]
    5. Using strategy rm
    6. Applied associate-*l*6.6

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \color{blue}{\left(\left(x \cdot sin\right) \cdot \left(sin \cdot x\right)\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;{cos}^{2} \le 1.5034798266949682 \cdot 10^{-306} \lor \neg \left({cos}^{2} \le 1.5266182343325565 \cdot 10^{+96}\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot \left(sin \cdot \left(\left(sin \cdot x\right) \cdot cos\right)\right)\right) \cdot cos}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{cos}^{2} \cdot \left(\left(sin \cdot x\right) \cdot \left(sin \cdot x\right)\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019002 
(FPCore (x cos sin)
  :name "cos(2*x)/(cos^2(x)*sin^2(x))"
  (/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x))))

Details

Time bar (total: 17.1s)Debug log

sample165.0ms

Algorithm
intervals

simplify226.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

225.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.0b

localize47.0ms

Local error

Found 4 expressions with local error:

19.8b
(* (pow cos 2) (* (* x (pow sin 2)) x))
7.3b
(* x (pow sin 2))
4.7b
(* (* x (pow sin 2)) x)
0.5b
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))

rewrite36.0ms

Algorithm
rewrite-expression-head
Counts
4 → 60
Calls

4 calls. Slowest were:

15.0ms
(* (pow cos 2) (* (* x (pow sin 2)) x))
12.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))
6.0ms
(* (* x (pow sin 2)) x)

series120.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

51.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))
37.0ms
(* (pow cos 2) (* (* x (pow sin 2)) x))
16.0ms
(* (* x (pow sin 2)) x)
16.0ms
(* x (pow sin 2))

simplify3.0s

Counts
35 → 72
Calls

35 calls. Slowest were:

542.0ms
(* (* (* (pow cos 2) (pow cos 2)) (pow cos 2)) (* (* (* (* x (pow sin 2)) x) (* (* x (pow sin 2)) x)) (* (* x (pow sin 2)) x)))
305.0ms
(- (+ (/ 1 (* (pow x 2) (* (pow sin 2) (pow cos 2)))) (* 2/3 (/ (pow x 2) (* (pow sin 2) (pow cos 2))))) (* 2 (/ 1 (* (pow sin 2) (pow cos 2)))))
294.0ms
(- (log (cos (* 2 x))) (log (* (pow cos 2) (* (* x (pow sin 2)) x))))

prune628.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 10.7b

localize14.0ms

Local error

Found 4 expressions with local error:

19.8b
(* (pow cos 2) (* (* (* x sin) sin) x))
4.7b
(* (* (* x sin) sin) x)
0.5b
(/ (cos (* 2 x)) (* (pow cos 2) (* (* (* x sin) sin) x)))
0.2b
(* (* x sin) sin)

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

13.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* (* x sin) sin) x)))
12.0ms
(* (pow cos 2) (* (* (* x sin) sin) x))
5.0ms
(* (* (* x sin) sin) x)

series115.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

50.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* (* x sin) sin) x)))
32.0ms
(* (pow cos 2) (* (* (* x sin) sin) x))
17.0ms
(* (* (* x sin) sin) x)
15.0ms
(* (* x sin) sin)

simplify2.7s

Counts
33 → 69
Calls

33 calls. Slowest were:

493.0ms
(- (log (cos (* 2 x))) (+ (* (log cos) 2) (log (* (* (* x sin) sin) x))))
308.0ms
(- (log (cos (* 2 x))) (+ (log (pow cos 2)) (log (* (* (* x sin) sin) x))))
226.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (pow x 2) (pow sin 2))))

prune773.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 7.6b

localize9.0ms

Local error

Found 4 expressions with local error:

9.1b
(* cos (* (* (* x sin) sin) x))
4.7b
(* (* (* x sin) sin) x)
4.0b
(* cos (* cos (* (* (* x sin) sin) x)))
0.5b
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))

rewrite36.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

12.0ms
(* cos (* cos (* (* (* x sin) sin) x)))
12.0ms
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))
6.0ms
(* cos (* (* (* x sin) sin) x))

series134.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

50.0ms
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))
36.0ms
(* cos (* (* (* x sin) sin) x))
32.0ms
(* cos (* cos (* (* (* x sin) sin) x)))
16.0ms
(* (* (* x sin) sin) x)

simplify1.6s

Counts
26 → 59
Calls

26 calls. Slowest were:

192.0ms
(- (+ (/ 1 (* (pow x 2) (* (pow sin 2) (pow cos 2)))) (* 2/3 (/ (pow x 2) (* (pow sin 2) (pow cos 2))))) (* 2 (/ 1 (* (pow sin 2) (pow cos 2)))))
184.0ms
(/ (* (* (cos (* 2 x)) (cos (* 2 x))) (cos (* 2 x))) (* (* (* cos (* cos (* (* (* x sin) sin) x))) (* cos (* cos (* (* (* x sin) sin) x)))) (* cos (* cos (* (* (* x sin) sin) x)))))
179.0ms
(/ (* (cos x) (cos x)) (* cos (* cos (* (* (* x sin) sin) x))))

prune600.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 3.2b

localize12.0ms

Local error

Found 4 expressions with local error:

7.4b
(* cos (* (* x sin) sin))
4.2b
(* (* cos (* (* x sin) sin)) x)
4.0b
(* cos (* (* cos (* (* x sin) sin)) x))
0.5b
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

11.0ms
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))
11.0ms
(* cos (* (* cos (* (* x sin) sin)) x))
6.0ms
(* (* cos (* (* x sin) sin)) x)

series147.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

48.0ms
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))
35.0ms
(* (* cos (* (* x sin) sin)) x)
32.0ms
(* cos (* (* cos (* (* x sin) sin)) x))
31.0ms
(* cos (* (* x sin) sin))

simplify1.7s

Counts
24 → 59
Calls

24 calls. Slowest were:

244.0ms
(/ (* (cos x) (cos x)) (* cos (* (* cos (* (* x sin) sin)) x)))
184.0ms
(- (+ (/ 1 (* (pow x 2) (* (pow sin 2) (pow cos 2)))) (* 2/3 (/ (pow x 2) (* (pow sin 2) (pow cos 2))))) (* 2 (/ 1 (* (pow sin 2) (pow cos 2)))))
159.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (pow x 2) (pow sin 2))))

prune412.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 2.2b

regimes550.0ms

Accuracy

7% (4.2b remaining)

Error of 8.0b against oracle of 3.8b and baseline of 8.3b

bsearch6.0ms

end0.0ms

sample4.1s

Algorithm
intervals