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

Error

Bits error versus x

Derivation

  1. Initial program 0.3

    \[\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\]
  2. Simplified0.3

    \[\leadsto \color{blue}{\frac{1 - \tan x \cdot \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*}}\]
  3. Using strategy rm
  4. Applied expm1-log1p-u0.4

    \[\leadsto \color{blue}{(e^{\log_* (1 + \frac{1 - \tan x \cdot \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*})} - 1)^*}\]
  5. Final simplification0.4

    \[\leadsto (e^{\log_* (1 + \frac{1 - \tan x \cdot \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*})} - 1)^*\]

Reproduce

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

Details

Time bar (total: 19.6s)Debug log

sample219.0ms

Algorithm
intervals
Results
51.0ms45×body1280valid
27.0ms143×body80valid
26.0ms31×body640valid
15.0ms25×body320valid
5.0ms12×body160valid

simplify102.0ms

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

prune20.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

localize33.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (tan x) (tan x))
0.2b
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
0.2b
(- 1 (* (tan x) (tan x)))
0.1b
(fma (tan x) (tan x) 1)

rewrite25.0ms

Algorithm
rewrite-expression-head
Rules
14×add-cube-cbrt
14×*-un-lft-identity
14×add-sqr-sqrt
times-frac
pow1
add-exp-log
add-cbrt-cube
add-log-exp
log1p-expm1-u
tan-quot
expm1-log1p-u
associate-/l*
associate-*l*
associate-*r*
associate-/r*
associate-/l/
flip--
flip3--
div-inv
fma-udef
cbrt-unprod
pow-prod-up
*-commutative
associate-*r/
prod-exp
associate-*l/
pow-prod-down
div-exp
div-sub
pow-plus
frac-2neg
sub-neg
clear-num
cbrt-undiv
frac-times
pow2
Counts
4 → 80
Calls
4 calls:
Slowest
10.0ms
(* (tan x) (tan x))
7.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
2.0ms
(- 1 (* (tan x) (tan x)))
0.0ms
(fma (tan x) (tan x) 1)

series241.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
89.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
79.0ms
(* (tan x) (tan x))
49.0ms
(fma (tan x) (tan x) 1)
24.0ms
(- 1 (* (tan x) (tan x)))

simplify1.5s

Counts
55 → 92
Calls
55 calls:
Slowest
233.0ms
(/ (* (* (- 1 (* (tan x) (tan x))) (- 1 (* (tan x) (tan x)))) (- 1 (* (tan x) (tan x)))) (* (* (fma (tan x) (tan x) 1) (fma (tan x) (tan x) 1)) (fma (tan x) (tan x) 1)))
198.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
190.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
61.0ms
(- (+ (* 2/3 (pow x 4)) 1) (* 2 (pow x 2)))
60.0ms
(- 1 (+ (pow x 2) (* 2/3 (pow x 4))))

prune901.0ms

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 0.0b

localize13.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (tan x) (tan x))
0.2b
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
0.2b
(log1p (/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1)))
0.2b
(- 1 (* (tan x) (tan x)))

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
14×add-cube-cbrt
14×*-un-lft-identity
14×add-sqr-sqrt
times-frac
pow1
add-exp-log
add-cbrt-cube
expm1-log1p-u
add-log-exp
log1p-expm1-u
tan-quot
associate-/l*
associate-*l*
associate-*r*
associate-/r*
associate-/l/
flip--
flip3--
div-inv
cbrt-unprod
pow-prod-up
*-commutative
associate-*r/
log1p-expm1
prod-exp
associate-*l/
pow-prod-down
div-exp
div-sub
pow-plus
frac-2neg
sub-neg
clear-num
log1p-udef
cbrt-undiv
frac-times
pow2
Counts
4 → 81
Calls
4 calls:
Slowest
8.0ms
(* (tan x) (tan x))
8.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
2.0ms
(- 1 (* (tan x) (tan x)))
1.0ms
(log1p (/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1)))

series381.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
196.0ms
(log1p (/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1)))
119.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
42.0ms
(* (tan x) (tan x))
23.0ms
(- 1 (* (tan x) (tan x)))

simplify2.0s

Counts
56 → 93
Calls
56 calls:
Slowest
266.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
257.0ms
(/ (* (* (- 1 (* (tan x) (tan x))) (- 1 (* (tan x) (tan x)))) (- 1 (* (tan x) (tan x)))) (* (* (fma (tan x) (tan x) 1) (fma (tan x) (tan x) 1)) (fma (tan x) (tan x) 1)))
239.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
193.0ms
(log (- (+ (/ 1 (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1)) 1) (/ (pow (sin x) 2) (* (pow (cos x) 2) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1)))))
167.0ms
(log (- (+ (/ 1 (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1)) 1) (/ (pow (sin x) 2) (* (pow (cos x) 2) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1)))))

prune1.2s

Pruning

14 alts after pruning (13 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.2b
(- 1 (* (tan x) (tan x)))
0.2b
(/ 1 (fma (tan x) (tan x) 1))
0.1b
(* (- 1 (* (tan x) (tan x))) (/ 1 (fma (tan x) (tan x) 1)))

rewrite12.0ms

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

series228.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
113.0ms
(* (- 1 (* (tan x) (tan x))) (/ 1 (fma (tan x) (tan x) 1)))
50.0ms
(/ 1 (fma (tan x) (tan x) 1))
35.0ms
(- 1 (* (tan x) (tan x)))
30.0ms
(* (tan x) (tan x))

simplify3.1s

Counts
49 → 95
Calls
49 calls:
Slowest
484.0ms
(* (+ (* 1 1) (+ (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x))))) (fma (tan x) (tan x) 1))
413.0ms
(* (- (pow 1 3) (pow (* (tan x) (tan x)) 3)) (/ 1 (fma (tan x) (tan x) 1)))
294.0ms
(* (- (pow 1 3) (pow (* (tan x) (tan x)) 3)) 1)
266.0ms
(* (* (* (- 1 (* (tan x) (tan x))) (- 1 (* (tan x) (tan x)))) (- 1 (* (tan x) (tan x)))) (* (* (/ 1 (fma (tan x) (tan x) 1)) (/ 1 (fma (tan x) (tan x) 1))) (/ 1 (fma (tan x) (tan x) 1))))
219.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))

prune912.0ms

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

9.1b
(cbrt (pow (tan x) 6))
0.6b
(pow (tan x) 6)
0.2b
(/ (- 1 (cbrt (pow (tan x) 6))) (fma (tan x) (tan x) 1))
0.2b
(- 1 (cbrt (pow (tan x) 6)))

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
15×add-cube-cbrt
15×*-un-lft-identity
15×add-sqr-sqrt
times-frac
add-exp-log
add-cbrt-cube
unpow-prod-down
cbrt-prod
pow1
add-log-exp
log1p-expm1-u
expm1-log1p-u
associate-/l*
associate-/r*
associate-/l/
flip--
flip3--
div-inv
pow-exp
div-exp
div-sub
pow1/3
frac-2neg
pow-pow
sub-neg
clear-num
cbrt-undiv
pow-to-exp
Counts
4 → 76
Calls
4 calls:
Slowest
7.0ms
(/ (- 1 (cbrt (pow (tan x) 6))) (fma (tan x) (tan x) 1))
2.0ms
(- 1 (cbrt (pow (tan x) 6)))
1.0ms
(pow (tan x) 6)
1.0ms
(cbrt (pow (tan x) 6))

series186.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
87.0ms
(/ (- 1 (cbrt (pow (tan x) 6))) (fma (tan x) (tan x) 1))
40.0ms
(pow (tan x) 6)
33.0ms
(- 1 (cbrt (pow (tan x) 6)))
25.0ms
(cbrt (pow (tan x) 6))

simplify1.3s

Counts
51 → 88
Calls
51 calls:
Slowest
260.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
204.0ms
(/ (* (* (- 1 (cbrt (pow (tan x) 6))) (- 1 (cbrt (pow (tan x) 6)))) (- 1 (cbrt (pow (tan x) 6)))) (* (* (fma (tan x) (tan x) 1) (fma (tan x) (tan x) 1)) (fma (tan x) (tan x) 1)))
194.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
93.0ms
(- 1 (+ (pow x 2) (* 2/3 (pow x 4))))
62.0ms
(- 1 (/ (pow (sin x) 2) (pow (cos x) 2)))

prune914.0ms

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 0.0b

regimes159.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.1s

Algorithm
intervals
Results
2.2s1523×body1280valid
1.6s1167×body640valid
1.3s4354×body80valid
622.0ms632×body320valid
179.0ms324×body160valid