
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin x) (cos x)))
(t_1 (- 1.0 (* (sin x) (/ (sin eps) (* (cos eps) (cos x)))))))
(+ (/ (/ (sin eps) (cos eps)) t_1) (- (/ t_0 t_1) t_0))))
double code(double x, double eps) {
double t_0 = sin(x) / cos(x);
double t_1 = 1.0 - (sin(x) * (sin(eps) / (cos(eps) * cos(x))));
return ((sin(eps) / cos(eps)) / t_1) + ((t_0 / t_1) - t_0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
t_0 = sin(x) / cos(x)
t_1 = 1.0d0 - (sin(x) * (sin(eps) / (cos(eps) * cos(x))))
code = ((sin(eps) / cos(eps)) / t_1) + ((t_0 / t_1) - t_0)
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) / Math.cos(x);
double t_1 = 1.0 - (Math.sin(x) * (Math.sin(eps) / (Math.cos(eps) * Math.cos(x))));
return ((Math.sin(eps) / Math.cos(eps)) / t_1) + ((t_0 / t_1) - t_0);
}
def code(x, eps): t_0 = math.sin(x) / math.cos(x) t_1 = 1.0 - (math.sin(x) * (math.sin(eps) / (math.cos(eps) * math.cos(x)))) return ((math.sin(eps) / math.cos(eps)) / t_1) + ((t_0 / t_1) - t_0)
function code(x, eps) t_0 = Float64(sin(x) / cos(x)) t_1 = Float64(1.0 - Float64(sin(x) * Float64(sin(eps) / Float64(cos(eps) * cos(x))))) return Float64(Float64(Float64(sin(eps) / cos(eps)) / t_1) + Float64(Float64(t_0 / t_1) - t_0)) end
function tmp = code(x, eps) t_0 = sin(x) / cos(x); t_1 = 1.0 - (sin(x) * (sin(eps) / (cos(eps) * cos(x)))); tmp = ((sin(eps) / cos(eps)) / t_1) + ((t_0 / t_1) - t_0); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Sin[x], $MachinePrecision] * N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(t$95$0 / t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
t_1 := 1 - \sin x \cdot \frac{\sin \varepsilon}{\cos \varepsilon \cdot \cos x}\\
\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{t\_1} + \left(\frac{t\_0}{t\_1} - t\_0\right)
\end{array}
\end{array}
Initial program 60.3%
tan-sum60.6%
div-inv60.5%
fmm-def60.6%
Applied egg-rr60.6%
Taylor expanded in x around inf 60.6%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
*-commutative99.1%
associate-/l*99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- 1.0 (* (/ (sin eps) (cos x)) (/ (sin x) (cos eps)))))) (+ (* (tan x) (+ (/ 1.0 t_0) -1.0)) (/ (tan eps) t_0))))
double code(double x, double eps) {
double t_0 = 1.0 - ((sin(eps) / cos(x)) * (sin(x) / cos(eps)));
return (tan(x) * ((1.0 / t_0) + -1.0)) + (tan(eps) / t_0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = 1.0d0 - ((sin(eps) / cos(x)) * (sin(x) / cos(eps)))
code = (tan(x) * ((1.0d0 / t_0) + (-1.0d0))) + (tan(eps) / t_0)
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - ((Math.sin(eps) / Math.cos(x)) * (Math.sin(x) / Math.cos(eps)));
return (Math.tan(x) * ((1.0 / t_0) + -1.0)) + (Math.tan(eps) / t_0);
}
def code(x, eps): t_0 = 1.0 - ((math.sin(eps) / math.cos(x)) * (math.sin(x) / math.cos(eps))) return (math.tan(x) * ((1.0 / t_0) + -1.0)) + (math.tan(eps) / t_0)
function code(x, eps) t_0 = Float64(1.0 - Float64(Float64(sin(eps) / cos(x)) * Float64(sin(x) / cos(eps)))) return Float64(Float64(tan(x) * Float64(Float64(1.0 / t_0) + -1.0)) + Float64(tan(eps) / t_0)) end
function tmp = code(x, eps) t_0 = 1.0 - ((sin(eps) / cos(x)) * (sin(x) / cos(eps))); tmp = (tan(x) * ((1.0 / t_0) + -1.0)) + (tan(eps) / t_0); end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{\sin \varepsilon}{\cos x} \cdot \frac{\sin x}{\cos \varepsilon}\\
\tan x \cdot \left(\frac{1}{t\_0} + -1\right) + \frac{\tan \varepsilon}{t\_0}
\end{array}
\end{array}
Initial program 60.3%
tan-sum60.6%
div-inv60.5%
fmm-def60.6%
Applied egg-rr60.6%
Taylor expanded in x around inf 60.6%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
*-commutative99.1%
associate-/l*99.1%
Simplified99.1%
tan-quot99.0%
associate-+r-60.5%
Applied egg-rr60.6%
associate-+r-99.1%
+-commutative99.1%
Simplified99.1%
(FPCore (x eps) :precision binary64 (let* ((t_0 (pow (tan x) 2.0))) (* eps (+ 1.0 (+ t_0 (* eps (* (sin x) (/ (+ 1.0 t_0) (cos x)))))))))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
return eps * (1.0 + (t_0 + (eps * (sin(x) * ((1.0 + t_0) / cos(x))))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = tan(x) ** 2.0d0
code = eps * (1.0d0 + (t_0 + (eps * (sin(x) * ((1.0d0 + t_0) / cos(x))))))
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.tan(x), 2.0);
return eps * (1.0 + (t_0 + (eps * (Math.sin(x) * ((1.0 + t_0) / Math.cos(x))))));
}
def code(x, eps): t_0 = math.pow(math.tan(x), 2.0) return eps * (1.0 + (t_0 + (eps * (math.sin(x) * ((1.0 + t_0) / math.cos(x))))))
function code(x, eps) t_0 = tan(x) ^ 2.0 return Float64(eps * Float64(1.0 + Float64(t_0 + Float64(eps * Float64(sin(x) * Float64(Float64(1.0 + t_0) / cos(x))))))) end
function tmp = code(x, eps) t_0 = tan(x) ^ 2.0; tmp = eps * (1.0 + (t_0 + (eps * (sin(x) * ((1.0 + t_0) / cos(x)))))); end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(eps * N[(1.0 + N[(t$95$0 + N[(eps * N[(N[Sin[x], $MachinePrecision] * N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\varepsilon \cdot \left(1 + \left(t\_0 + \varepsilon \cdot \left(\sin x \cdot \frac{1 + t\_0}{\cos x}\right)\right)\right)
\end{array}
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
sub-neg98.6%
Applied egg-rr98.6%
Final simplification98.6%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (log (exp (cos x))) 2.0)))))
double code(double x, double eps) {
return eps * (1.0 + (pow(sin(x), 2.0) / pow(log(exp(cos(x))), 2.0)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (log(exp(cos(x))) ** 2.0d0)))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.log(Math.exp(Math.cos(x))), 2.0)));
}
def code(x, eps): return eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.log(math.exp(math.cos(x))), 2.0)))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (log(exp(cos(x))) ^ 2.0)))) end
function tmp = code(x, eps) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (log(exp(cos(x))) ^ 2.0))); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Log[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\log \left(e^{\cos x}\right)}^{2}}\right)
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 98.3%
*-commutative98.3%
Simplified98.3%
add-log-exp98.3%
Applied egg-rr98.3%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (* eps (exp (log1p (* (pow (sin x) 2.0) (pow (cos x) -2.0))))))
double code(double x, double eps) {
return eps * exp(log1p((pow(sin(x), 2.0) * pow(cos(x), -2.0))));
}
public static double code(double x, double eps) {
return eps * Math.exp(Math.log1p((Math.pow(Math.sin(x), 2.0) * Math.pow(Math.cos(x), -2.0))));
}
def code(x, eps): return eps * math.exp(math.log1p((math.pow(math.sin(x), 2.0) * math.pow(math.cos(x), -2.0))))
function code(x, eps) return Float64(eps * exp(log1p(Float64((sin(x) ^ 2.0) * (cos(x) ^ -2.0))))) end
code[x_, eps_] := N[(eps * N[Exp[N[Log[1 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot e^{\mathsf{log1p}\left({\sin x}^{2} \cdot {\cos x}^{-2}\right)}
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 98.3%
*-commutative98.3%
Simplified98.3%
add-exp-log98.3%
log1p-define98.3%
pow198.3%
div-inv98.3%
pow198.3%
pow-flip98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (/ (pow (sin x) 2.0) (/ (+ 1.0 (cos (* x 2.0))) 2.0)))))
double code(double x, double eps) {
return eps * (1.0 + (pow(sin(x), 2.0) / ((1.0 + cos((x * 2.0))) / 2.0)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + ((sin(x) ** 2.0d0) / ((1.0d0 + cos((x * 2.0d0))) / 2.0d0)))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / ((1.0 + Math.cos((x * 2.0))) / 2.0)));
}
def code(x, eps): return eps * (1.0 + (math.pow(math.sin(x), 2.0) / ((1.0 + math.cos((x * 2.0))) / 2.0)))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / Float64(Float64(1.0 + cos(Float64(x * 2.0))) / 2.0)))) end
function tmp = code(x, eps) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / ((1.0 + cos((x * 2.0))) / 2.0))); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(1.0 + N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{\frac{1 + \cos \left(x \cdot 2\right)}{2}}\right)
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 98.3%
*-commutative98.3%
Simplified98.3%
unpow298.3%
cos-mult98.3%
Applied egg-rr98.3%
+-commutative98.3%
+-inverses98.3%
cos-098.3%
count-298.3%
*-commutative98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (* eps (+ -1.0 (+ 2.0 (/ (pow (sin x) 2.0) (- 1.0 (pow x 2.0)))))))
double code(double x, double eps) {
return eps * (-1.0 + (2.0 + (pow(sin(x), 2.0) / (1.0 - pow(x, 2.0)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((-1.0d0) + (2.0d0 + ((sin(x) ** 2.0d0) / (1.0d0 - (x ** 2.0d0)))))
end function
public static double code(double x, double eps) {
return eps * (-1.0 + (2.0 + (Math.pow(Math.sin(x), 2.0) / (1.0 - Math.pow(x, 2.0)))));
}
def code(x, eps): return eps * (-1.0 + (2.0 + (math.pow(math.sin(x), 2.0) / (1.0 - math.pow(x, 2.0)))))
function code(x, eps) return Float64(eps * Float64(-1.0 + Float64(2.0 + Float64((sin(x) ^ 2.0) / Float64(1.0 - (x ^ 2.0)))))) end
function tmp = code(x, eps) tmp = eps * (-1.0 + (2.0 + ((sin(x) ^ 2.0) / (1.0 - (x ^ 2.0))))); end
code[x_, eps_] := N[(eps * N[(-1.0 + N[(2.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(1.0 - N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-1 + \left(2 + \frac{{\sin x}^{2}}{1 - {x}^{2}}\right)\right)
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 98.3%
*-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 97.4%
mul-1-neg97.4%
unsub-neg97.4%
Simplified97.4%
expm1-log1p-u97.4%
expm1-undefine97.4%
Applied egg-rr97.4%
sub-neg97.4%
log1p-undefine97.4%
rem-exp-log97.4%
associate-+r+97.4%
metadata-eval97.4%
metadata-eval97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (/ (pow (sin x) 2.0) (- 1.0 (* x x))))))
double code(double x, double eps) {
return eps * (1.0 + (pow(sin(x), 2.0) / (1.0 - (x * x))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (1.0d0 - (x * x))))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / (1.0 - (x * x))));
}
def code(x, eps): return eps * (1.0 + (math.pow(math.sin(x), 2.0) / (1.0 - (x * x))))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / Float64(1.0 - Float64(x * x))))) end
function tmp = code(x, eps) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (1.0 - (x * x)))); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{1 - x \cdot x}\right)
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 98.3%
*-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 97.4%
mul-1-neg97.4%
unsub-neg97.4%
Simplified97.4%
unpow297.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x eps) :precision binary64 (tan eps))
double code(double x, double eps) {
return tan(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan(eps)
end function
public static double code(double x, double eps) {
return Math.tan(eps);
}
def code(x, eps): return math.tan(eps)
function code(x, eps) return tan(eps) end
function tmp = code(x, eps) tmp = tan(eps); end
code[x_, eps_] := N[Tan[eps], $MachinePrecision]
\begin{array}{l}
\\
\tan \varepsilon
\end{array}
Initial program 60.3%
Taylor expanded in x around 0 97.4%
tan-quot97.4%
*-un-lft-identity97.4%
Applied egg-rr97.4%
*-lft-identity97.4%
Simplified97.4%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (* x (+ eps x)))))
double code(double x, double eps) {
return eps * (1.0 + (x * (eps + x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + (x * (eps + x)))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (x * (eps + x)));
}
def code(x, eps): return eps * (1.0 + (x * (eps + x)))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64(x * Float64(eps + x)))) end
function tmp = code(x, eps) tmp = eps * (1.0 + (x * (eps + x))); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(x * N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + x \cdot \left(\varepsilon + x\right)\right)
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in x around 0 97.3%
+-commutative97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 60.3%
Taylor expanded in eps around 0 98.6%
associate--l+98.6%
associate-/l*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in x around 0 97.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (* (cos x) (cos (+ x eps)))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * cos((x + eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / (cos(x) * cos((x + eps)))
end function
public static double code(double x, double eps) {
return Math.sin(eps) / (Math.cos(x) * Math.cos((x + eps)));
}
def code(x, eps): return math.sin(eps) / (math.cos(x) * math.cos((x + eps)))
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * cos(Float64(x + eps)))) end
function tmp = code(x, eps) tmp = sin(eps) / (cos(x) * cos((x + eps))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}
\end{array}
(FPCore (x eps) :precision binary64 (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)))
double code(double x, double eps) {
return ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
end function
public static double code(double x, double eps) {
return ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
}
def code(x, eps): return ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x)
function code(x, eps) return Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)) end
function tmp = code(x, eps) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); end
code[x_, eps_] := N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x
\end{array}
(FPCore (x eps) :precision binary64 (+ eps (* (* eps (tan x)) (tan x))))
double code(double x, double eps) {
return eps + ((eps * tan(x)) * tan(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps + ((eps * tan(x)) * tan(x))
end function
public static double code(double x, double eps) {
return eps + ((eps * Math.tan(x)) * Math.tan(x));
}
def code(x, eps): return eps + ((eps * math.tan(x)) * math.tan(x))
function code(x, eps) return Float64(eps + Float64(Float64(eps * tan(x)) * tan(x))) end
function tmp = code(x, eps) tmp = eps + ((eps * tan(x)) * tan(x)); end
code[x_, eps_] := N[(eps + N[(N[(eps * N[Tan[x], $MachinePrecision]), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon + \left(\varepsilon \cdot \tan x\right) \cdot \tan x
\end{array}
herbie shell --seed 2024169
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:precision binary64
:pre (and (and (and (<= -10000.0 x) (<= x 10000.0)) (< (* 1e-16 (fabs x)) eps)) (< eps (fabs x)))
:alt
(! :herbie-platform default (/ (sin eps) (* (cos x) (cos (+ x eps)))))
:alt
(! :herbie-platform default (- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x)))
:alt
(! :herbie-platform default (+ eps (* eps (tan x) (tan x))))
(- (tan (+ x eps)) (tan x)))