Average Error: 28.2 → 8.4
Time: 20.7s
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}\;x \le -61357.354317215366 \lor \neg \left(x \le -9.238259325850402 \cdot 10^{-152}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(\left(cos \cdot \left(sin \cdot x\right)\right) \cdot sin\right)\right) \cdot cos}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot x\right) \cdot \frac{2}{3}}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\right)} + \left(\frac{\frac{1}{x \cdot x}}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\right)} + \frac{-2}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\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 x < -61357.354317215366 or -9.238259325850402e-152 < x

    1. Initial program 28.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 unpow228.3

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

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

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

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

      \[\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.3

      \[\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 -61357.354317215366 < x < -9.238259325850402e-152

    1. Initial program 27.4

      \[\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 unpow227.4

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{cos \cdot \left(cos \cdot \left(\color{blue}{\left(\left(x \cdot sin\right) \cdot sin\right)} \cdot x\right)\right)}\]
    8. Taylor expanded around 0 27.7

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{2} \cdot \left({sin}^{2} \cdot {cos}^{2}\right)} + \frac{2}{3} \cdot \frac{{x}^{2}}{{sin}^{2} \cdot {cos}^{2}}\right) - 2 \cdot \frac{1}{{sin}^{2} \cdot {cos}^{2}}}\]
    9. Simplified9.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -61357.354317215366 \lor \neg \left(x \le -9.238259325850402 \cdot 10^{-152}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(\left(cos \cdot \left(sin \cdot x\right)\right) \cdot sin\right)\right) \cdot cos}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot x\right) \cdot \frac{2}{3}}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\right)} + \left(\frac{\frac{1}{x \cdot x}}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\right)} + \frac{-2}{\left(sin \cdot cos\right) \cdot \left(sin \cdot cos\right)}\right)\\ \end{array}\]

Reproduce

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

sample188.0ms

Algorithm
intervals

simplify180.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 26.9b

localize24.0ms

Local error

Found 4 expressions with local error:

20.1b
(* (pow cos 2) (* (* x (pow sin 2)) x))
5.9b
(* x (pow sin 2))
3.4b
(* (* x (pow sin 2)) x)
0.9b
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 60
Calls

4 calls. Slowest were:

11.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x)))
10.0ms
(* (pow cos 2) (* (* x (pow sin 2)) x))
4.0ms
(* (* x (pow sin 2)) x)

series122.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify2.7s

Counts
35 → 72
Calls

35 calls. Slowest were:

434.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)))
252.0ms
(- (log (cos (* 2 x))) (log (* (pow cos 2) (* (* x (pow sin 2)) x))))
201.0ms
(/ (* (* (cos (* 2 x)) (cos (* 2 x))) (cos (* 2 x))) (* (* (* (pow cos 2) (* (* x (pow sin 2)) x)) (* (pow cos 2) (* (* x (pow sin 2)) x))) (* (pow cos 2) (* (* x (pow sin 2)) x))))

prune817.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 12.5b

localize8.0ms

Local error

Found 4 expressions with local error:

7.7b
(* cos (* cos (* (* x (pow sin 2)) x)))
5.9b
(* x (pow sin 2))
5.1b
(* cos (* (* x (pow sin 2)) x))
3.4b
(* (* x (pow sin 2)) x)

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
4 → 39
Calls

4 calls. Slowest were:

10.0ms
(* cos (* cos (* (* x (pow sin 2)) x)))
9.0ms
(* cos (* (* x (pow sin 2)) x))
7.0ms
(* (* x (pow sin 2)) x)

series120.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

41.0ms
(* cos (* (* x (pow sin 2)) x))
37.0ms
(* cos (* cos (* (* x (pow sin 2)) x)))
25.0ms
(* x (pow sin 2))
17.0ms
(* (* x (pow sin 2)) x)

simplify551.0ms

Counts
16 → 51
Calls

16 calls. Slowest were:

134.0ms
(* (pow x 2) (* (pow sin 2) (pow cos 2)))
105.0ms
(* (pow x 2) (* (pow sin 2) (pow cos 2)))
103.0ms
(* (pow x 2) (* (pow sin 2) (pow cos 2)))

prune675.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 9.1b

localize31.0ms

Local error

Found 4 expressions with local error:

7.7b
(* cos (* cos (* (* (* x sin) sin) x)))
5.1b
(* cos (* (* (* x sin) sin) x))
3.4b
(* (* (* x sin) sin) x)
0.9b
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))

rewrite61.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

26.0ms
(* cos (* cos (* (* (* x sin) sin) x)))
21.0ms
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))
7.0ms
(* cos (* (* (* x sin) sin) x))

series203.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(/ (cos (* 2 x)) (* cos (* cos (* (* (* x sin) sin) x))))
62.0ms
(* cos (* (* (* x sin) sin) x))
40.0ms
(* cos (* cos (* (* (* x sin) sin) x)))
30.0ms
(* (* (* x sin) sin) x)

simplify2.0s

Counts
26 → 59
Calls

26 calls. Slowest were:

248.0ms
(/ (* (cos x) (cos x)) (* cos (* cos (* (* (* x sin) sin) x))))
233.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (pow x 2) (pow sin 2))))
233.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (pow x 2) (pow sin 2))))

prune747.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 7.0b

localize23.0ms

Local error

Found 4 expressions with local error:

7.7b
(* cos (* (* cos (* (* x sin) sin)) x))
7.1b
(* cos (* (* x sin) sin))
3.4b
(* (* cos (* (* x sin) sin)) x)
0.9b
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))

rewrite73.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

28.0ms
(* cos (* (* cos (* (* x sin) sin)) x))
25.0ms
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))
14.0ms
(* (* cos (* (* x sin) sin)) x)

series217.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

87.0ms
(/ (cos (* 2 x)) (* cos (* (* cos (* (* x sin) sin)) x)))
59.0ms
(* (* cos (* (* x sin) sin)) x)
38.0ms
(* cos (* (* cos (* (* x sin) sin)) x))
34.0ms
(* cos (* (* x sin) sin))

simplify2.4s

Counts
24 → 59
Calls

24 calls. Slowest were:

332.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)))))
328.0ms
(/ (* (cos x) (cos x)) (* cos (* (* cos (* (* x sin) sin)) x)))
239.0ms
(/ (cos (* 2 x)) (* (pow cos 2) (* (pow x 2) (pow sin 2))))

prune727.0ms

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 5.8b

regimes621.0ms

Accuracy

-4.2% (4.5b remaining)

Error of 8.4b against oracle of 3.9b and baseline of 8.3b

bsearch864.0ms

end0.0ms

sample5.6s

Algorithm
intervals