Average Error: 0.3 → 0.4
Time: 20.2s
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}}{\log_* (1 + (e^{{\left(\cos x\right)}^{2}} - 1)^*)}}{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. Initial simplification0.3

    \[\leadsto \frac{1 - \tan x \cdot \tan x}{(\left(\tan x\right) \cdot \left(\tan x\right) + 1)_*}\]
  3. 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}}\]
  4. Using strategy rm
  5. Applied log1p-expm1-u0.4

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

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

Reproduce

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

Details

Time bar (total: 9.8s)Debug log

start491.0ms

Algorithm
intervals

setup84.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.2b

localize19.0ms

Local error

Found 4 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

5.0ms
(* (tan x) (tan x))
4.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
1.0ms
(- 1 (* (tan x) (tan x)))

series208.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

105.0ms
(/ (- 1 (* (tan x) (tan x))) (fma (tan x) (tan x) 1))
38.0ms
(* (tan x) (tan x))
32.0ms
(- 1 (* (tan x) (tan x)))
31.0ms
(fma (tan x) (tan x) 1)

simplify1.7s

Counts
55 → 92
Calls

55 calls. Slowest were:

324.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)))
264.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
220.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))

prune1.4s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

1.0ms
(pow (cos x) 2)
1.0ms
(pow (sin x) 2)
1.0ms
(pow (cos x) 2)

series72.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

25.0ms
(pow (sin x) 2)
19.0ms
(pow (sin x) 2)
15.0ms
(pow (cos x) 2)
13.0ms
(pow (cos x) 2)

simplify345.0ms

Counts
32 → 76
Calls

32 calls. Slowest were:

80.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
57.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))
49.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))

prune1.0s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

0.7b
(expm1 (pow (cos x) 2))
0.2b
(pow (cos x) 2)
0.2b
(pow (cos x) 2)
0.2b
(pow (sin x) 2)

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

1.0ms
(pow (sin x) 2)
1.0ms
(pow (cos x) 2)
1.0ms
(pow (cos x) 2)

series159.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

92.0ms
(expm1 (pow (cos x) 2))
25.0ms
(pow (sin x) 2)
23.0ms
(pow (cos x) 2)
19.0ms
(pow (cos x) 2)

simplify462.0ms

Counts
28 → 71
Calls

28 calls. Slowest were:

230.0ms
(- (+ (* 5/6 (* (pow x 4) E)) E) (+ (* (pow x 2) E) 1))
71.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
35.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))

prune1.2s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

4.0ms
(* (tan x) (tan x))
2.0ms
(/ 1 (/ (fma (tan x) (tan x) 1) (- 1 (* (tan x) (tan x)))))
1.0ms
(- 1 (* (tan x) (tan x)))

series210.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

93.0ms
(/ 1 (/ (fma (tan x) (tan x) 1) (- 1 (* (tan x) (tan x)))))
52.0ms
(fma (tan x) (tan x) 1)
42.0ms
(* (tan x) (tan x))
23.0ms
(- 1 (* (tan x) (tan x)))

simplify1.0s

Counts
44 → 92
Calls

44 calls. Slowest were:

213.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
205.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))
96.0ms
(+ (* 1 1) (+ (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))

prune1.1s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes212.0ms

Accuracy

0% (0.3b remaining)

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

bsearch2.0ms