| Alternative 1 | |
|---|---|
| Error | 14.7 |
| Cost | 33216 |
\[\begin{array}{l}
t_0 := \tan^{-1} \left(N + 1\right)\\
\left(t_0 + \frac{\tan^{-1} N}{-2}\right) + \left(t_0 - \left(t_0 + \frac{\tan^{-1} N}{2}\right)\right)
\end{array}
\]
(FPCore (N) :precision binary64 (- (atan (+ N 1.0)) (atan N)))
(FPCore (N) :precision binary64 (let* ((t_0 (atan (+ N 1.0))) (t_1 (/ (atan N) -4.0))) (- (/ t_0 8.0) (+ t_1 (+ (+ (* (atan N) 1.5) (* t_0 -0.875)) t_1)))))
double code(double N) {
return atan((N + 1.0)) - atan(N);
}
double code(double N) {
double t_0 = atan((N + 1.0));
double t_1 = atan(N) / -4.0;
return (t_0 / 8.0) - (t_1 + (((atan(N) * 1.5) + (t_0 * -0.875)) + t_1));
}
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
t_0 = atan((n + 1.0d0))
t_1 = atan(n) / (-4.0d0)
code = (t_0 / 8.0d0) - (t_1 + (((atan(n) * 1.5d0) + (t_0 * (-0.875d0))) + t_1))
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 = Math.atan((N + 1.0));
double t_1 = Math.atan(N) / -4.0;
return (t_0 / 8.0) - (t_1 + (((Math.atan(N) * 1.5) + (t_0 * -0.875)) + t_1));
}
def code(N): return math.atan((N + 1.0)) - math.atan(N)
def code(N): t_0 = math.atan((N + 1.0)) t_1 = math.atan(N) / -4.0 return (t_0 / 8.0) - (t_1 + (((math.atan(N) * 1.5) + (t_0 * -0.875)) + t_1))
function code(N) return Float64(atan(Float64(N + 1.0)) - atan(N)) end
function code(N) t_0 = atan(Float64(N + 1.0)) t_1 = Float64(atan(N) / -4.0) return Float64(Float64(t_0 / 8.0) - Float64(t_1 + Float64(Float64(Float64(atan(N) * 1.5) + Float64(t_0 * -0.875)) + t_1))) end
function tmp = code(N) tmp = atan((N + 1.0)) - atan(N); end
function tmp = code(N) t_0 = atan((N + 1.0)); t_1 = atan(N) / -4.0; tmp = (t_0 / 8.0) - (t_1 + (((atan(N) * 1.5) + (t_0 * -0.875)) + t_1)); end
code[N_] := N[(N[ArcTan[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[ArcTan[N], $MachinePrecision]), $MachinePrecision]
code[N_] := Block[{t$95$0 = N[ArcTan[N[(N + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcTan[N], $MachinePrecision] / -4.0), $MachinePrecision]}, N[(N[(t$95$0 / 8.0), $MachinePrecision] - N[(t$95$1 + N[(N[(N[(N[ArcTan[N], $MachinePrecision] * 1.5), $MachinePrecision] + N[(t$95$0 * -0.875), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
\begin{array}{l}
t_0 := \tan^{-1} \left(N + 1\right)\\
t_1 := \frac{\tan^{-1} N}{-4}\\
\frac{t_0}{8} - \left(t_1 + \left(\left(\tan^{-1} N \cdot 1.5 + t_0 \cdot -0.875\right) + t_1\right)\right)
\end{array}
Results
| Original | 14.7 |
|---|---|
| Target | 0.4 |
| Herbie | 14.7 |
Initial program 14.7
Applied egg-rr14.7
Applied egg-rr14.8
Simplified14.7
[Start]14.8 | \[ \left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) + \left(\left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) - \left(\tan^{-1} N \cdot 2 + \tan^{-1} \left(N + 1\right) \cdot -0.5\right)\right)
\] |
|---|---|
rational_best-simplify-3 [=>]14.8 | \[ \color{blue}{\left(\left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) - \left(\tan^{-1} N \cdot 2 + \tan^{-1} \left(N + 1\right) \cdot -0.5\right)\right) + \left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right)}
\] |
rational_best-simplify-3 [=>]14.8 | \[ \left(\left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) - \left(\tan^{-1} N \cdot 2 + \tan^{-1} \left(N + 1\right) \cdot -0.5\right)\right) + \color{blue}{\left(\frac{\tan^{-1} N}{2} + \frac{\tan^{-1} \left(N + 1\right)}{4}\right)}
\] |
rational_best-simplify-47 [=>]14.7 | \[ \color{blue}{\frac{\tan^{-1} \left(N + 1\right)}{4} + \left(\frac{\tan^{-1} N}{2} + \left(\left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) - \left(\tan^{-1} N \cdot 2 + \tan^{-1} \left(N + 1\right) \cdot -0.5\right)\right)\right)}
\] |
rational_best-simplify-3 [=>]14.7 | \[ \frac{\tan^{-1} \left(N + 1\right)}{4} + \left(\frac{\tan^{-1} N}{2} + \left(\left(\frac{\tan^{-1} \left(N + 1\right)}{4} + \frac{\tan^{-1} N}{2}\right) - \color{blue}{\left(\tan^{-1} \left(N + 1\right) \cdot -0.5 + \tan^{-1} N \cdot 2\right)}\right)\right)
\] |
Applied egg-rr14.7
Simplified14.7
[Start]14.7 | \[ \frac{\tan^{-1} \left(N + 1\right)}{8} - \left(\frac{\tan^{-1} N}{-2} - \left(\frac{\tan^{-1} \left(N + 1\right)}{8} - \left(\tan^{-1} N \cdot 1.5 - \left(0 - \tan^{-1} \left(N + 1\right) \cdot -0.75\right)\right)\right)\right)
\] |
|---|---|
rational_best-simplify-51 [=>]14.7 | \[ \frac{\tan^{-1} \left(N + 1\right)}{8} - \color{blue}{\left(\left(\tan^{-1} N \cdot 1.5 - \left(0 - \tan^{-1} \left(N + 1\right) \cdot -0.75\right)\right) - \left(\frac{\tan^{-1} \left(N + 1\right)}{8} - \frac{\tan^{-1} N}{-2}\right)\right)}
\] |
rational_best-simplify-15 [=>]14.7 | \[ \frac{\tan^{-1} \left(N + 1\right)}{8} - \left(\left(\tan^{-1} N \cdot 1.5 - \color{blue}{\left(-\tan^{-1} \left(N + 1\right) \cdot -0.75\right)}\right) - \left(\frac{\tan^{-1} \left(N + 1\right)}{8} - \frac{\tan^{-1} N}{-2}\right)\right)
\] |
rational_best-simplify-59 [<=]14.7 | \[ \frac{\tan^{-1} \left(N + 1\right)}{8} - \left(\color{blue}{\left(\tan^{-1} \left(N + 1\right) \cdot -0.75 + \tan^{-1} N \cdot 1.5\right)} - \left(\frac{\tan^{-1} \left(N + 1\right)}{8} - \frac{\tan^{-1} N}{-2}\right)\right)
\] |
Applied egg-rr14.7
Final simplification14.7
| Alternative 1 | |
|---|---|
| Error | 14.7 |
| Cost | 33216 |
| Alternative 2 | |
|---|---|
| Error | 14.7 |
| Cost | 26688 |
| Alternative 3 | |
|---|---|
| Error | 14.7 |
| Cost | 19904 |
| Alternative 4 | |
|---|---|
| Error | 14.7 |
| Cost | 19904 |
| Alternative 5 | |
|---|---|
| Error | 14.7 |
| Cost | 13120 |
herbie shell --seed 2023099
(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)))