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

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. Taylor expanded around -inf 0.4

    \[\leadsto \color{blue}{\frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}} + 1}}\]
  3. Final simplification0.4

    \[\leadsto \frac{1 - \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}{1 + \frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}}}\]

Reproduce

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

Details

Time bar (total: 18.2s)Debug log

sample241.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)

simplify418.0ms

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

prune18.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

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))))

rewrite20.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
log1p-expm1-u
expm1-log1p-u
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 → 97
Calls
4 calls:
Slowest
6.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
5.0ms
(* (tan x) (tan x))
4.0ms
(* (tan x) (tan x))
1.0ms
(- 1 (* (tan x) (tan x)))

series184.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
77.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
56.0ms
(* (tan x) (tan x))
26.0ms
(* (tan x) (tan x))
24.0ms
(- 1 (* (tan x) (tan x)))

simplify2.4s

Counts
72 → 109
Calls
72 calls:
Slowest
550.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)))))
480.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
227.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
182.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
83.0ms
(- (pow 1 3) (pow (* (tan x) (tan x)) 3))

prune1.0s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 0.0b

localize48.0ms

Local error

Found 4 expressions with local error:

0.5b
(pow (* (tan x) (tan x)) 3)
0.3b
(fma (tan x) (tan x) -1)
0.3b
(* (tan x) (tan x))
0.3b
(* (tan x) (tan x))

rewrite24.0ms

Algorithm
rewrite-expression-head
Rules
20×pow1
12×tan-quot
11×add-exp-log
11×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
associate-*l*
associate-*r*
pow-pow
add-log-exp
log1p-expm1-u
expm1-log1p-u
cbrt-unprod
pow-prod-up
associate-*r/
prod-exp
associate-*l/
pow-prod-down
pow-plus
frac-times
pow2
cube-div
rem-cube-cbrt
*-commutative
pow-exp
fma-udef
cube-prod
unpow3
unpow-prod-down
pow-to-exp
cube-mult
Counts
4 → 86
Calls
4 calls:
Slowest
8.0ms
(* (tan x) (tan x))
8.0ms
(* (tan x) (tan x))
7.0ms
(pow (* (tan x) (tan x)) 3)
0.0ms
(fma (tan x) (tan x) -1)

series161.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
67.0ms
(pow (* (tan x) (tan x)) 3)
33.0ms
(* (tan x) (tan x))
31.0ms
(fma (tan x) (tan x) -1)
30.0ms
(* (tan x) (tan x))

simplify512.0ms

Counts
56 → 98
Calls
56 calls:
Slowest
48.0ms
(pow (* (sin x) (tan x)) 3)
47.0ms
(pow (* (tan x) (sin x)) 3)
45.0ms
(- (+ (pow x 2) (* 2/3 (pow x 4))) 1)
38.0ms
(- (/ (pow (sin x) 2) (pow (cos x) 2)) 1)
33.0ms
(- (/ (pow (sin x) 2) (pow (cos x) 2)) 1)

prune1.4s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize35.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)

rewrite5.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
log1p-expm1-u
pow-exp
add-cbrt-cube
pow-pow
pow-to-exp
expm1-log1p-u
Counts
4 → 64
Calls
4 calls:
Slowest
1.0ms
(pow (cos x) 2)
1.0ms
(pow (sin x) 2)
1.0ms
(pow (cos x) 2)
1.0ms
(pow (sin x) 2)

series84.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
30.0ms
(pow (sin x) 2)
25.0ms
(pow (sin x) 2)
17.0ms
(pow (cos x) 2)
11.0ms
(pow (cos x) 2)

simplify303.0ms

Counts
32 → 76
Calls
32 calls:
Slowest
67.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
58.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
45.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))
36.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))
16.0ms
(pow (* (cbrt (sin x)) (cbrt (sin x))) 2)

prune850.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize8.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)))

rewrite26.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
log1p-expm1-u
expm1-log1p-u
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 → 93
Calls
4 calls:
Slowest
8.0ms
(* (tan x) (tan x))
8.0ms
(* (tan x) (tan x))
6.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
2.0ms
(- 1 (* (tan x) (tan x)))

series171.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
76.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
39.0ms
(* (tan x) (tan x))
31.0ms
(- 1 (* (tan x) (tan x)))
25.0ms
(* (tan x) (tan x))

simplify1.8s

Counts
62 → 105
Calls
62 calls:
Slowest
469.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
249.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
239.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
72.0ms
(- (+ (* 2/3 (pow x 4)) 1) (* 2 (pow x 2)))
58.0ms
(- 1 (/ (pow (sin x) 2) (pow (cos x) 2)))

prune1.2s

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 0.0b

regimes487.0ms

Accuracy

0% (0.3b remaining)

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

bsearch3.0ms

end0.0ms

sample6.8s

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)