| Alternative 1 | |
|---|---|
| Error | 14.9 |
| Cost | 13376 |
\[\left(\tan^{-1} \left(1 + N\right) - \left(\tan^{-1} N - -1\right)\right) + 1
\]
(FPCore (N) :precision binary64 (- (atan (+ N 1.0)) (atan N)))
(FPCore (N)
:precision binary64
(let* ((t_0 (+ 1.0 (atan N)))
(t_1 (* t_0 t_0))
(t_2 (/ (/ 1.0 t_0) t_1))
(t_3 (* t_0 (* t_0 t_1))))
(+
(- (atan (+ 1.0 N)) (* (* t_3 t_3) (/ (* (/ 1.0 t_2) (* t_2 t_2)) t_3)))
1.0)))double code(double N) {
return atan((N + 1.0)) - atan(N);
}
double code(double N) {
double t_0 = 1.0 + atan(N);
double t_1 = t_0 * t_0;
double t_2 = (1.0 / t_0) / t_1;
double t_3 = t_0 * (t_0 * t_1);
return (atan((1.0 + N)) - ((t_3 * t_3) * (((1.0 / t_2) * (t_2 * t_2)) / t_3))) + 1.0;
}
real(8) function code(n)
real(8), intent (in) :: n
code = atan((n + 1.0d0)) - atan(n)
end function
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
t_0 = 1.0d0 + atan(n)
t_1 = t_0 * t_0
t_2 = (1.0d0 / t_0) / t_1
t_3 = t_0 * (t_0 * t_1)
code = (atan((1.0d0 + n)) - ((t_3 * t_3) * (((1.0d0 / t_2) * (t_2 * t_2)) / t_3))) + 1.0d0
end function
public static double code(double N) {
return Math.atan((N + 1.0)) - Math.atan(N);
}
public static double code(double N) {
double t_0 = 1.0 + Math.atan(N);
double t_1 = t_0 * t_0;
double t_2 = (1.0 / t_0) / t_1;
double t_3 = t_0 * (t_0 * t_1);
return (Math.atan((1.0 + N)) - ((t_3 * t_3) * (((1.0 / t_2) * (t_2 * t_2)) / t_3))) + 1.0;
}
def code(N): return math.atan((N + 1.0)) - math.atan(N)
def code(N): t_0 = 1.0 + math.atan(N) t_1 = t_0 * t_0 t_2 = (1.0 / t_0) / t_1 t_3 = t_0 * (t_0 * t_1) return (math.atan((1.0 + N)) - ((t_3 * t_3) * (((1.0 / t_2) * (t_2 * t_2)) / t_3))) + 1.0
function code(N) return Float64(atan(Float64(N + 1.0)) - atan(N)) end
function code(N) t_0 = Float64(1.0 + atan(N)) t_1 = Float64(t_0 * t_0) t_2 = Float64(Float64(1.0 / t_0) / t_1) t_3 = Float64(t_0 * Float64(t_0 * t_1)) return Float64(Float64(atan(Float64(1.0 + N)) - Float64(Float64(t_3 * t_3) * Float64(Float64(Float64(1.0 / t_2) * Float64(t_2 * t_2)) / t_3))) + 1.0) end
function tmp = code(N) tmp = atan((N + 1.0)) - atan(N); end
function tmp = code(N) t_0 = 1.0 + atan(N); t_1 = t_0 * t_0; t_2 = (1.0 / t_0) / t_1; t_3 = t_0 * (t_0 * t_1); tmp = (atan((1.0 + N)) - ((t_3 * t_3) * (((1.0 / t_2) * (t_2 * t_2)) / t_3))) + 1.0; end
code[N_] := N[(N[ArcTan[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[ArcTan[N], $MachinePrecision]), $MachinePrecision]
code[N_] := Block[{t$95$0 = N[(1.0 + N[ArcTan[N], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[ArcTan[N[(1.0 + N), $MachinePrecision]], $MachinePrecision] - N[(N[(t$95$3 * t$95$3), $MachinePrecision] * N[(N[(N[(1.0 / t$95$2), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
\begin{array}{l}
t_0 := 1 + \tan^{-1} N\\
t_1 := t_0 \cdot t_0\\
t_2 := \frac{\frac{1}{t_0}}{t_1}\\
t_3 := t_0 \cdot \left(t_0 \cdot t_1\right)\\
\left(\tan^{-1} \left(1 + N\right) - \left(t_3 \cdot t_3\right) \cdot \frac{\frac{1}{t_2} \cdot \left(t_2 \cdot t_2\right)}{t_3}\right) + 1
\end{array}
Results
| Original | 14.9 |
|---|---|
| Target | 0.3 |
| Herbie | 14.9 |
Initial program 14.9
Applied egg-rr31.4
Applied egg-rr14.9
Applied egg-rr14.9
Applied egg-rr14.9
Final simplification14.9
| Alternative 1 | |
|---|---|
| Error | 14.9 |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Error | 14.9 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 14.9 |
| Cost | 13120 |
herbie shell --seed 2023077
(FPCore (N)
:name "2atan (example 3.5)"
:precision binary64
:herbie-target
(atan (/ 1.0 (+ 1.0 (* N (+ N 1.0)))))
(- (atan (+ N 1.0)) (atan N)))