Average Error: 0.3 → 0.4
Time: 20.0s
Precision: 64
Internal Precision: 128
\[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
\[\frac{1}{\tan x \cdot \tan x + 1} \cdot \left(1 - \tan x \cdot \tan x\right)\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.3

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  2. Using strategy rm
  3. Applied div-inv0.4

    \[\leadsto \color{blue}{\left(1 - \tan x \cdot \tan x\right) \cdot \frac{1}{1 + \tan x \cdot \tan x}}\]
  4. Final simplification0.4

    \[\leadsto \frac{1}{\tan x \cdot \tan x + 1} \cdot \left(1 - \tan x \cdot \tan x\right)\]

Reproduce

herbie shell --seed 2019016 
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))

Details

Time bar (total: 18.8s)Debug log

sample308.0ms

Algorithm
intervals
Results
256×(pre true 80)
140×(body real 80)
53×(body real 1280)
36×(body real 640)
19×(body real 320)
(body real 160)

simplify266.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
266.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.4b

localize19.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (tan x) (tan x))
0.3b
(* (tan x) (tan x))
0.2b
(- 1 (* (tan x) (tan x)))
0.2b
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))

rewrite74.0ms

Algorithm
rewrite-expression-head
Rules
16×add-cube-cbrt
16×*-un-lft-identity
16×add-sqr-sqrt
14×pow1
10×add-exp-log
10×add-cbrt-cube
times-frac
tan-quot
associate-*l*
associate-*r*
add-log-exp
associate-/l*
associate-/r*
associate-/l/
flip--
cbrt-unprod
pow-prod-up
*-commutative
associate-/r/
associate-*r/
prod-exp
associate-*l/
pow-prod-down
flip3--
pow-plus
frac-times
pow2
div-inv
flip-+
div-exp
div-sub
flip3-+
frac-2neg
sub-neg
clear-num
cbrt-undiv
Counts
4 → 89
Calls
4 calls:
Slowest
47.0ms
(* (tan x) (tan x))
11.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
6.0ms
(* (tan x) (tan x))
3.0ms
(- 1 (* (tan x) (tan x)))

series504.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
319.0ms
(* (tan x) (tan x))
75.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
75.0ms
(* (tan x) (tan x))
34.0ms
(- 1 (* (tan x) (tan x)))

simplify1.8s

Counts
72 → 101
Calls
72 calls:
Slowest
351.0ms
(/ (* (* (- 1 (* (tan x) (tan x))) (- 1 (* (tan x) (tan x)))) (- 1 (* (tan x) (tan x)))) (* (* (+ 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))) (+ 1 (* (tan x) (tan x)))))
276.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
206.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
179.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
74.0ms
(- 1 (+ (pow x 2) (* 2/3 (pow x 4))))

prune911.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 0.0b

localize30.0ms

Local error

Found 4 expressions with local error:

0.3b
(pow (cos x) 2)
0.3b
(pow (cos x) 2)
0.3b
(pow (sin x) 2)
0.3b
(pow (sin x) 2)

rewrite9.0ms

Algorithm
rewrite-expression-head
Rules
12×unpow-prod-down
add-cube-cbrt
add-exp-log
*-un-lft-identity
pow1
add-sqr-sqrt
add-log-exp
unpow2
pow-exp
add-cbrt-cube
pow-pow
pow-to-exp
Counts
4 → 56
Calls
4 calls:
Slowest
2.0ms
(pow (cos x) 2)
2.0ms
(pow (sin x) 2)
2.0ms
(pow (cos x) 2)
2.0ms
(pow (sin x) 2)

series80.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
25.0ms
(pow (sin x) 2)
19.0ms
(pow (cos x) 2)
19.0ms
(pow (cos x) 2)
16.0ms
(pow (sin x) 2)

simplify305.0ms

Counts
32 → 68
Calls
32 calls:
Slowest
54.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
52.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
42.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))
37.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))
16.0ms
(pow (* (cbrt (sin x)) (cbrt (sin x))) 2)

prune821.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (tan x) (tan x))
0.3b
(* (tan x) (tan x))
0.2b
(* (- 1 (* (tan x) (tan x))) (/ 1 (+ 1 (* (tan x) (tan x)))))
0.2b
(- 1 (* (tan x) (tan x)))

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
16×pow1
12×add-exp-log
12×associate-*r*
10×add-cube-cbrt
10×add-cbrt-cube
10×*-un-lft-identity
10×add-sqr-sqrt
associate-*l*
tan-quot
add-log-exp
prod-exp
associate-*l/
frac-times
flip--
cbrt-unprod
*-commutative
associate-*r/
pow-prod-down
flip3--
pow-prod-up
associate-/r/
pow-plus
pow2
div-inv
flip-+
un-div-inv
flip3-+
sub-neg
rec-exp
Counts
4 → 84
Calls
4 calls:
Slowest
4.0ms
(* (- 1 (* (tan x) (tan x))) (/ 1 (+ 1 (* (tan x) (tan x)))))
4.0ms
(* (tan x) (tan x))
4.0ms
(* (tan x) (tan x))
1.0ms
(- 1 (* (tan x) (tan x)))

series195.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
96.0ms
(* (- 1 (* (tan x) (tan x))) (/ 1 (+ 1 (* (tan x) (tan x)))))
36.0ms
(- 1 (* (tan x) (tan x)))
36.0ms
(* (tan x) (tan x))
26.0ms
(* (tan x) (tan x))

simplify3.3s

Counts
62 → 96
Calls
62 calls:
Slowest
524.0ms
(* (- (* 1 1) (* (* (tan x) (tan x)) (* (tan x) (tan x)))) (/ 1 (+ 1 (* (tan x) (tan x)))))
373.0ms
(* (+ (* 1 1) (+ (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x))))) (+ 1 (* (tan x) (tan x))))
313.0ms
(* (- (pow 1 3) (pow (* (tan x) (tan x)) 3)) (/ 1 (+ 1 (* (tan x) (tan x)))))
245.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
245.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))

prune874.0ms

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

0.4b
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
0.3b
(* (tan x) (tan x))
0.3b
(* (tan x) (tan x))
0.2b
(- 1 (* (tan x) (tan x)))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
16×add-cube-cbrt
16×log-pow
16×*-un-lft-identity
16×add-sqr-sqrt
15×exp-prod
15×pow1
times-frac
add-exp-log
tan-quot
add-cbrt-cube
associate-*l*
associate-*r*
add-log-exp
log-prod
cbrt-unprod
pow-prod-up
*-commutative
associate-/r/
associate-*r/
prod-exp
associate-*l/
pow-prod-down
pow-plus
frac-times
pow2
flip--
div-inv
flip-+
rem-log-exp
div-sub
exp-diff
flip3--
flip3-+
sub-neg
log-div
Counts
4 → 85
Calls
4 calls:
Slowest
9.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
8.0ms
(* (tan x) (tan x))
7.0ms
(* (tan x) (tan x))
2.0ms
(- 1 (* (tan x) (tan x)))

series170.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
95.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
26.0ms
(* (tan x) (tan x))
26.0ms
(* (tan x) (tan x))
23.0ms
(- 1 (* (tan x) (tan x)))

simplify1.3s

Counts
62 → 97
Calls
62 calls:
Slowest
241.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
189.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
178.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
71.0ms
(- (+ (* 2/3 (pow x 4)) 1) (* 2 (pow x 2)))
69.0ms
(- 1 (+ (pow x 2) (* 2/3 (pow x 4))))

prune1.1s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 0.0b

regimes260.0ms

Accuracy

0% (0.3b remaining)

Error of 0.4b against oracle of 0.1b and baseline of 0.4b

bsearch1.0ms

end0.0ms

sample6.3s

Algorithm
intervals
Results
8000×(pre true 80)
4290×(body real 80)
1584×(body real 1280)
1190×(body real 640)
617×(body real 320)
319×(body real 160)