| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32512 |
(FPCore (x) :precision binary64 (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))
(FPCore (x) :precision binary64 (/ (fma (tan x) (tan x) -1.0) (- -1.0 (pow (tan x) 2.0))))
double code(double x) {
return (1.0 - (tan(x) * tan(x))) / (1.0 + (tan(x) * tan(x)));
}
double code(double x) {
return fma(tan(x), tan(x), -1.0) / (-1.0 - pow(tan(x), 2.0));
}
function code(x) return Float64(Float64(1.0 - Float64(tan(x) * tan(x))) / Float64(1.0 + Float64(tan(x) * tan(x)))) end
function code(x) return Float64(fma(tan(x), tan(x), -1.0) / Float64(-1.0 - (tan(x) ^ 2.0))) end
code[x_] := N[(N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + -1.0), $MachinePrecision] / N[(-1.0 - N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\frac{\mathsf{fma}\left(\tan x, \tan x, -1\right)}{-1 - {\tan x}^{2}}
Initial program 99.5%
Applied egg-rr99.4%
[Start]99.5 | \[ \frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\] |
|---|---|
div-sub [=>]99.4 | \[ \color{blue}{\frac{1}{1 + \tan x \cdot \tan x} - \frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}}
\] |
sub-neg [=>]99.4 | \[ \color{blue}{\frac{1}{1 + \tan x \cdot \tan x} + \left(-\frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\right)}
\] |
+-commutative [=>]99.4 | \[ \frac{1}{\color{blue}{\tan x \cdot \tan x + 1}} + \left(-\frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\right)
\] |
fma-def [=>]99.4 | \[ \frac{1}{\color{blue}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}} + \left(-\frac{\tan x \cdot \tan x}{1 + \tan x \cdot \tan x}\right)
\] |
pow2 [=>]99.4 | \[ \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} + \left(-\frac{\color{blue}{{\tan x}^{2}}}{1 + \tan x \cdot \tan x}\right)
\] |
+-commutative [=>]99.4 | \[ \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} + \left(-\frac{{\tan x}^{2}}{\color{blue}{\tan x \cdot \tan x + 1}}\right)
\] |
fma-def [=>]99.4 | \[ \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} + \left(-\frac{{\tan x}^{2}}{\color{blue}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}\right)
\] |
Simplified99.5%
[Start]99.4 | \[ \frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} + \left(-\frac{{\tan x}^{2}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}\right)
\] |
|---|---|
sub-neg [<=]99.4 | \[ \color{blue}{\frac{1}{\mathsf{fma}\left(\tan x, \tan x, 1\right)} - \frac{{\tan x}^{2}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}
\] |
div-sub [<=]99.5 | \[ \color{blue}{\frac{1 - {\tan x}^{2}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}}
\] |
Applied egg-rr99.4%
[Start]99.5 | \[ \frac{1 - {\tan x}^{2}}{\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
|---|---|
frac-2neg [=>]99.5 | \[ \color{blue}{\frac{-\left(1 - {\tan x}^{2}\right)}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}}
\] |
div-inv [=>]99.4 | \[ \color{blue}{\left(-\left(1 - {\tan x}^{2}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}}
\] |
neg-sub0 [=>]99.4 | \[ \color{blue}{\left(0 - \left(1 - {\tan x}^{2}\right)\right)} \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
metadata-eval [<=]99.4 | \[ \left(\color{blue}{\log 1} - \left(1 - {\tan x}^{2}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
associate--r- [=>]99.4 | \[ \color{blue}{\left(\left(\log 1 - 1\right) + {\tan x}^{2}\right)} \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
metadata-eval [=>]99.4 | \[ \left(\left(\color{blue}{0} - 1\right) + {\tan x}^{2}\right) \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
metadata-eval [=>]99.4 | \[ \left(\color{blue}{-1} + {\tan x}^{2}\right) \cdot \frac{1}{-\mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
neg-sub0 [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\color{blue}{0 - \mathsf{fma}\left(\tan x, \tan x, 1\right)}}
\] |
metadata-eval [<=]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\color{blue}{\log 1} - \mathsf{fma}\left(\tan x, \tan x, 1\right)}
\] |
fma-udef [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\log 1 - \color{blue}{\left(\tan x \cdot \tan x + 1\right)}}
\] |
unpow2 [<=]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\log 1 - \left(\color{blue}{{\tan x}^{2}} + 1\right)}
\] |
+-commutative [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\log 1 - \color{blue}{\left(1 + {\tan x}^{2}\right)}}
\] |
associate--r+ [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\color{blue}{\left(\log 1 - 1\right) - {\tan x}^{2}}}
\] |
metadata-eval [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\left(\color{blue}{0} - 1\right) - {\tan x}^{2}}
\] |
metadata-eval [=>]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{\color{blue}{-1} - {\tan x}^{2}}
\] |
Simplified99.5%
[Start]99.4 | \[ \left(-1 + {\tan x}^{2}\right) \cdot \frac{1}{-1 - {\tan x}^{2}}
\] |
|---|---|
*-commutative [=>]99.4 | \[ \color{blue}{\frac{1}{-1 - {\tan x}^{2}} \cdot \left(-1 + {\tan x}^{2}\right)}
\] |
associate-*l/ [=>]99.5 | \[ \color{blue}{\frac{1 \cdot \left(-1 + {\tan x}^{2}\right)}{-1 - {\tan x}^{2}}}
\] |
+-commutative [=>]99.5 | \[ \frac{1 \cdot \color{blue}{\left({\tan x}^{2} + -1\right)}}{-1 - {\tan x}^{2}}
\] |
metadata-eval [<=]99.5 | \[ \frac{1 \cdot \left({\tan x}^{2} + \color{blue}{\left(-1\right)}\right)}{-1 - {\tan x}^{2}}
\] |
sub-neg [<=]99.5 | \[ \frac{1 \cdot \color{blue}{\left({\tan x}^{2} - 1\right)}}{-1 - {\tan x}^{2}}
\] |
*-lft-identity [=>]99.5 | \[ \frac{\color{blue}{{\tan x}^{2} - 1}}{-1 - {\tan x}^{2}}
\] |
unpow2 [=>]99.5 | \[ \frac{\color{blue}{\tan x \cdot \tan x} - 1}{-1 - {\tan x}^{2}}
\] |
fma-neg [=>]99.5 | \[ \frac{\color{blue}{\mathsf{fma}\left(\tan x, \tan x, -1\right)}}{-1 - {\tan x}^{2}}
\] |
metadata-eval [=>]99.5 | \[ \frac{\mathsf{fma}\left(\tan x, \tan x, \color{blue}{-1}\right)}{-1 - {\tan x}^{2}}
\] |
Final simplification99.5%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32512 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 26176 |
| Alternative 3 | |
|---|---|
| Accuracy | 59.7% |
| Cost | 25920 |
| Alternative 4 | |
|---|---|
| Accuracy | 59.7% |
| Cost | 13312 |
| Alternative 5 | |
|---|---|
| Accuracy | 58.9% |
| Cost | 13184 |
| Alternative 6 | |
|---|---|
| Accuracy | 59.7% |
| Cost | 13056 |
| Alternative 7 | |
|---|---|
| Accuracy | 55.5% |
| Cost | 7104 |
| Alternative 8 | |
|---|---|
| Accuracy | 55.5% |
| Cost | 64 |
herbie shell --seed 2023126
(FPCore (x)
:name "Trigonometry B"
:precision binary64
(/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))