| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 52416 |
\[\begin{array}{l}
t_0 := {\left(\left|\tan x\right|\right)}^{2}\\
\frac{1 - \tan x \cdot \tan x}{1 + \frac{1 - t_0}{\frac{1}{t_0} - 1}}
\end{array}
\]
(FPCore (x) :precision binary64 (/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (tan x))) (t_1 (/ 1.0 t_0)) (t_2 (* t_1 (* 1.0 t_0))))
(/
(- 1.0 (* (tan x) (tan x)))
(+ 1.0 (/ (- t_2 (/ (* (tan x) (- (tan x))) -1.0)) (- (* t_1 t_1) t_2))))))double code(double x) {
return (1.0 - (tan(x) * tan(x))) / (1.0 + (tan(x) * tan(x)));
}
double code(double x) {
double t_0 = fabs(tan(x));
double t_1 = 1.0 / t_0;
double t_2 = t_1 * (1.0 * t_0);
return (1.0 - (tan(x) * tan(x))) / (1.0 + ((t_2 - ((tan(x) * -tan(x)) / -1.0)) / ((t_1 * t_1) - t_2)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - (tan(x) * tan(x))) / (1.0d0 + (tan(x) * tan(x)))
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = abs(tan(x))
t_1 = 1.0d0 / t_0
t_2 = t_1 * (1.0d0 * t_0)
code = (1.0d0 - (tan(x) * tan(x))) / (1.0d0 + ((t_2 - ((tan(x) * -tan(x)) / (-1.0d0))) / ((t_1 * t_1) - t_2)))
end function
public static double code(double x) {
return (1.0 - (Math.tan(x) * Math.tan(x))) / (1.0 + (Math.tan(x) * Math.tan(x)));
}
public static double code(double x) {
double t_0 = Math.abs(Math.tan(x));
double t_1 = 1.0 / t_0;
double t_2 = t_1 * (1.0 * t_0);
return (1.0 - (Math.tan(x) * Math.tan(x))) / (1.0 + ((t_2 - ((Math.tan(x) * -Math.tan(x)) / -1.0)) / ((t_1 * t_1) - t_2)));
}
def code(x): return (1.0 - (math.tan(x) * math.tan(x))) / (1.0 + (math.tan(x) * math.tan(x)))
def code(x): t_0 = math.fabs(math.tan(x)) t_1 = 1.0 / t_0 t_2 = t_1 * (1.0 * t_0) return (1.0 - (math.tan(x) * math.tan(x))) / (1.0 + ((t_2 - ((math.tan(x) * -math.tan(x)) / -1.0)) / ((t_1 * t_1) - t_2)))
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) t_0 = abs(tan(x)) t_1 = Float64(1.0 / t_0) t_2 = Float64(t_1 * Float64(1.0 * t_0)) return Float64(Float64(1.0 - Float64(tan(x) * tan(x))) / Float64(1.0 + Float64(Float64(t_2 - Float64(Float64(tan(x) * Float64(-tan(x))) / -1.0)) / Float64(Float64(t_1 * t_1) - t_2)))) end
function tmp = code(x) tmp = (1.0 - (tan(x) * tan(x))) / (1.0 + (tan(x) * tan(x))); end
function tmp = code(x) t_0 = abs(tan(x)); t_1 = 1.0 / t_0; t_2 = t_1 * (1.0 * t_0); tmp = (1.0 - (tan(x) * tan(x))) / (1.0 + ((t_2 - ((tan(x) * -tan(x)) / -1.0)) / ((t_1 * t_1) - t_2))); 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_] := Block[{t$95$0 = N[Abs[N[Tan[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(1.0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(t$95$2 - N[(N[(N[Tan[x], $MachinePrecision] * (-N[Tan[x], $MachinePrecision])), $MachinePrecision] / -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$1 * t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{1 - \tan x \cdot \tan x}{1 + \tan x \cdot \tan x}
\begin{array}{l}
t_0 := \left|\tan x\right|\\
t_1 := \frac{1}{t_0}\\
t_2 := t_1 \cdot \left(1 \cdot t_0\right)\\
\frac{1 - \tan x \cdot \tan x}{1 + \frac{t_2 - \frac{\tan x \cdot \left(-\tan x\right)}{-1}}{t_1 \cdot t_1 - t_2}}
\end{array}
Results
Initial program 0.3
Applied egg-rr0.3
Applied egg-rr0.3
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 52416 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 26304 |
| Alternative 3 | |
|---|---|
| Error | 25.8 |
| Cost | 20416 |
| Alternative 4 | |
|---|---|
| Error | 28.5 |
| Cost | 13248 |
| Alternative 5 | |
|---|---|
| Error | 28.7 |
| Cost | 64 |
herbie shell --seed 2023104
(FPCore (x)
:name "Trigonometry B"
:precision binary64
(/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))