Average Error: 0.3 → 0.4
Time: 20.3s
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 2019004 +o rules:numerics
(FPCore (x)
  :name "Trigonometry B"
  (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x)))))

Details

Time bar (total: 18.9s)Debug log

sample202.0ms

Algorithm
intervals

simplify59.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

58.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))

prune11.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

localize16.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 (* (tan x) (tan x))))
0.2b
(- 1 (* (tan x) (tan x)))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 97
Calls

4 calls. Slowest were:

6.0ms
(* (tan x) (tan x))
4.0ms
(* (tan x) (tan x))
4.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))

series156.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
37.0ms
(* (tan x) (tan x))
28.0ms
(* (tan x) (tan x))
24.0ms
(- 1 (* (tan x) (tan x)))

simplify2.3s

Counts
72 → 109
Calls

72 calls. Slowest were:

576.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)))))
438.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
215.0ms
(/ (- 1 (/ (pow (sin x) 2) (pow (cos x) 2))) (+ (/ (pow (sin x) 2) (pow (cos x) 2)) 1))

prune948.0ms

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 0.0b

localize43.0ms

Local error

Found 4 expressions with local error:

0.4b
(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))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 86
Calls

4 calls. Slowest were:

12.0ms
(* (tan x) (tan x))
8.0ms
(* (tan x) (tan x))
7.0ms
(pow (* (tan x) (tan x)) 3)

series190.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(pow (* (tan x) (tan x)) 3)
54.0ms
(fma (tan x) (tan x) -1)
38.0ms
(* (tan x) (tan x))
28.0ms
(* (tan x) (tan x))

simplify526.0ms

Counts
56 → 98
Calls

56 calls. Slowest were:

56.0ms
(- (+ (pow x 2) (* 2/3 (pow x 4))) 1)
51.0ms
(- (/ (pow (sin x) 2) (pow (cos x) 2)) 1)
39.0ms
(pow (* (tan x) (sin x)) 3)

prune1.4s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 0.0b

localize13.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))) (+ 1 (* (tan x) (tan x))))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 114
Calls

4 calls. Slowest were:

5.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
4.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
4.0ms
(* (tan x) (tan x))

series233.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

89.0ms
(/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))
81.0ms
(log (exp (/ (- 1 (* (tan x) (tan x))) (+ 1 (* (tan x) (tan x))))))
32.0ms
(* (tan x) (tan x))
29.0ms
(* (tan x) (tan x))

simplify3.5s

Counts
92 → 126
Calls

92 calls. Slowest were:

510.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)))))
458.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))
458.0ms
(+ (* 1 1) (- (* (* (tan x) (tan x)) (* (tan x) (tan x))) (* 1 (* (tan x) (tan x)))))

prune1.4s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 0.0b

localize52.0ms

Local error

Found 4 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

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

series86.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

25.0ms
(pow (sin x) 2)
24.0ms
(pow (sin x) 2)
19.0ms
(pow (cos x) 2)
18.0ms
(pow (cos x) 2)

simplify274.0ms

Counts
32 → 76
Calls

32 calls. Slowest were:

51.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
50.0ms
(- (+ (pow x 2) (* 2/45 (pow x 6))) (* 1/3 (pow x 4)))
40.0ms
(- (+ (* 1/3 (pow x 4)) 1) (pow x 2))

prune951.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 0.0b

regimes492.0ms

Accuracy

0% (0.3b remaining)

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

bsearch3.0ms

end0.0ms

sample5.9s

Algorithm
intervals