
(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 14 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 (/ (pow (sin x) 2.0) (cos x))))
(/
(*
eps
(+
(+
(cos x)
(*
(pow eps 2.0)
(-
(+
(* (cos x) 0.3333333333333333)
(*
(pow eps 2.0)
(-
(+
(* (cos x) 0.13333333333333333)
(*
(* eps eps)
(-
(* (cos x) 0.05396825396825397)
(* -0.05396825396825397 t_0))))
(* t_0 -0.13333333333333333))))
(* t_0 -0.3333333333333333))))
(/ (/ (- 1.0 (cos (* x 2.0))) 2.0) (cos x))))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0) / cos(x);
return (eps * ((cos(x) + (pow(eps, 2.0) * (((cos(x) * 0.3333333333333333) + (pow(eps, 2.0) * (((cos(x) * 0.13333333333333333) + ((eps * eps) * ((cos(x) * 0.05396825396825397) - (-0.05396825396825397 * t_0)))) - (t_0 * -0.13333333333333333)))) - (t_0 * -0.3333333333333333)))) + (((1.0 - cos((x * 2.0))) / 2.0) / cos(x)))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = (sin(x) ** 2.0d0) / cos(x)
code = (eps * ((cos(x) + ((eps ** 2.0d0) * (((cos(x) * 0.3333333333333333d0) + ((eps ** 2.0d0) * (((cos(x) * 0.13333333333333333d0) + ((eps * eps) * ((cos(x) * 0.05396825396825397d0) - ((-0.05396825396825397d0) * t_0)))) - (t_0 * (-0.13333333333333333d0))))) - (t_0 * (-0.3333333333333333d0))))) + (((1.0d0 - cos((x * 2.0d0))) / 2.0d0) / cos(x)))) / (cos(x) * (1.0d0 - (tan(x) * tan(eps))))
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0) / Math.cos(x);
return (eps * ((Math.cos(x) + (Math.pow(eps, 2.0) * (((Math.cos(x) * 0.3333333333333333) + (Math.pow(eps, 2.0) * (((Math.cos(x) * 0.13333333333333333) + ((eps * eps) * ((Math.cos(x) * 0.05396825396825397) - (-0.05396825396825397 * t_0)))) - (t_0 * -0.13333333333333333)))) - (t_0 * -0.3333333333333333)))) + (((1.0 - Math.cos((x * 2.0))) / 2.0) / Math.cos(x)))) / (Math.cos(x) * (1.0 - (Math.tan(x) * Math.tan(eps))));
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) / math.cos(x) return (eps * ((math.cos(x) + (math.pow(eps, 2.0) * (((math.cos(x) * 0.3333333333333333) + (math.pow(eps, 2.0) * (((math.cos(x) * 0.13333333333333333) + ((eps * eps) * ((math.cos(x) * 0.05396825396825397) - (-0.05396825396825397 * t_0)))) - (t_0 * -0.13333333333333333)))) - (t_0 * -0.3333333333333333)))) + (((1.0 - math.cos((x * 2.0))) / 2.0) / math.cos(x)))) / (math.cos(x) * (1.0 - (math.tan(x) * math.tan(eps))))
function code(x, eps) t_0 = Float64((sin(x) ^ 2.0) / cos(x)) return Float64(Float64(eps * Float64(Float64(cos(x) + Float64((eps ^ 2.0) * Float64(Float64(Float64(cos(x) * 0.3333333333333333) + Float64((eps ^ 2.0) * Float64(Float64(Float64(cos(x) * 0.13333333333333333) + Float64(Float64(eps * eps) * Float64(Float64(cos(x) * 0.05396825396825397) - Float64(-0.05396825396825397 * t_0)))) - Float64(t_0 * -0.13333333333333333)))) - Float64(t_0 * -0.3333333333333333)))) + Float64(Float64(Float64(1.0 - cos(Float64(x * 2.0))) / 2.0) / cos(x)))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))) end
function tmp = code(x, eps) t_0 = (sin(x) ^ 2.0) / cos(x); tmp = (eps * ((cos(x) + ((eps ^ 2.0) * (((cos(x) * 0.3333333333333333) + ((eps ^ 2.0) * (((cos(x) * 0.13333333333333333) + ((eps * eps) * ((cos(x) * 0.05396825396825397) - (-0.05396825396825397 * t_0)))) - (t_0 * -0.13333333333333333)))) - (t_0 * -0.3333333333333333)))) + (((1.0 - cos((x * 2.0))) / 2.0) / cos(x)))) / (cos(x) * (1.0 - (tan(x) * tan(eps)))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * N[(N[(N[Cos[x], $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[(N[Cos[x], $MachinePrecision] * 0.13333333333333333), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * 0.05396825396825397), $MachinePrecision] - N[(-0.05396825396825397 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * -0.13333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 - N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{\cos x}\\
\frac{\varepsilon \cdot \left(\left(\cos x + {\varepsilon}^{2} \cdot \left(\left(\cos x \cdot 0.3333333333333333 + {\varepsilon}^{2} \cdot \left(\left(\cos x \cdot 0.13333333333333333 + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\cos x \cdot 0.05396825396825397 - -0.05396825396825397 \cdot t\_0\right)\right) - t\_0 \cdot -0.13333333333333333\right)\right) - t\_0 \cdot -0.3333333333333333\right)\right) + \frac{\frac{1 - \cos \left(x \cdot 2\right)}{2}}{\cos x}\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}
\end{array}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 99.6%
unpow299.6%
Applied egg-rr99.6%
unpow299.6%
sin-mult99.6%
Applied egg-rr99.6%
+-inverses99.6%
cos-099.6%
count-299.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (pow (sin x) 2.0) (cos x))))
(/
(*
eps
(+
t_0
(+
(cos x)
(*
(pow eps 2.0)
(-
(+
(* (cos x) 0.3333333333333333)
(* (pow eps 2.0) (* 0.13333333333333333 (+ (cos x) t_0))))
(* t_0 -0.3333333333333333))))))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0) / cos(x);
return (eps * (t_0 + (cos(x) + (pow(eps, 2.0) * (((cos(x) * 0.3333333333333333) + (pow(eps, 2.0) * (0.13333333333333333 * (cos(x) + t_0)))) - (t_0 * -0.3333333333333333)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = (sin(x) ** 2.0d0) / cos(x)
code = (eps * (t_0 + (cos(x) + ((eps ** 2.0d0) * (((cos(x) * 0.3333333333333333d0) + ((eps ** 2.0d0) * (0.13333333333333333d0 * (cos(x) + t_0)))) - (t_0 * (-0.3333333333333333d0))))))) / (cos(x) * (1.0d0 - (tan(x) * tan(eps))))
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0) / Math.cos(x);
return (eps * (t_0 + (Math.cos(x) + (Math.pow(eps, 2.0) * (((Math.cos(x) * 0.3333333333333333) + (Math.pow(eps, 2.0) * (0.13333333333333333 * (Math.cos(x) + t_0)))) - (t_0 * -0.3333333333333333)))))) / (Math.cos(x) * (1.0 - (Math.tan(x) * Math.tan(eps))));
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) / math.cos(x) return (eps * (t_0 + (math.cos(x) + (math.pow(eps, 2.0) * (((math.cos(x) * 0.3333333333333333) + (math.pow(eps, 2.0) * (0.13333333333333333 * (math.cos(x) + t_0)))) - (t_0 * -0.3333333333333333)))))) / (math.cos(x) * (1.0 - (math.tan(x) * math.tan(eps))))
function code(x, eps) t_0 = Float64((sin(x) ^ 2.0) / cos(x)) return Float64(Float64(eps * Float64(t_0 + Float64(cos(x) + Float64((eps ^ 2.0) * Float64(Float64(Float64(cos(x) * 0.3333333333333333) + Float64((eps ^ 2.0) * Float64(0.13333333333333333 * Float64(cos(x) + t_0)))) - Float64(t_0 * -0.3333333333333333)))))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))) end
function tmp = code(x, eps) t_0 = (sin(x) ^ 2.0) / cos(x); tmp = (eps * (t_0 + (cos(x) + ((eps ^ 2.0) * (((cos(x) * 0.3333333333333333) + ((eps ^ 2.0) * (0.13333333333333333 * (cos(x) + t_0)))) - (t_0 * -0.3333333333333333)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps)))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * N[(t$95$0 + N[(N[Cos[x], $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(0.13333333333333333 * N[(N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{\cos x}\\
\frac{\varepsilon \cdot \left(t\_0 + \left(\cos x + {\varepsilon}^{2} \cdot \left(\left(\cos x \cdot 0.3333333333333333 + {\varepsilon}^{2} \cdot \left(0.13333333333333333 \cdot \left(\cos x + t\_0\right)\right)\right) - t\_0 \cdot -0.3333333333333333\right)\right)\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}
\end{array}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 99.6%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
distribute-lft-out99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (pow (sin x) 2.0) (cos x))))
(/
(*
eps
(+
t_0
(+
(cos x)
(*
(pow eps 2.0)
(-
(+
(* (cos x) 0.3333333333333333)
(*
(pow eps 2.0)
(+ 0.13333333333333333 (* (pow eps 2.0) 0.05396825396825397))))
(* t_0 -0.3333333333333333))))))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0) / cos(x);
return (eps * (t_0 + (cos(x) + (pow(eps, 2.0) * (((cos(x) * 0.3333333333333333) + (pow(eps, 2.0) * (0.13333333333333333 + (pow(eps, 2.0) * 0.05396825396825397)))) - (t_0 * -0.3333333333333333)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = (sin(x) ** 2.0d0) / cos(x)
code = (eps * (t_0 + (cos(x) + ((eps ** 2.0d0) * (((cos(x) * 0.3333333333333333d0) + ((eps ** 2.0d0) * (0.13333333333333333d0 + ((eps ** 2.0d0) * 0.05396825396825397d0)))) - (t_0 * (-0.3333333333333333d0))))))) / (cos(x) * (1.0d0 - (tan(x) * tan(eps))))
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0) / Math.cos(x);
return (eps * (t_0 + (Math.cos(x) + (Math.pow(eps, 2.0) * (((Math.cos(x) * 0.3333333333333333) + (Math.pow(eps, 2.0) * (0.13333333333333333 + (Math.pow(eps, 2.0) * 0.05396825396825397)))) - (t_0 * -0.3333333333333333)))))) / (Math.cos(x) * (1.0 - (Math.tan(x) * Math.tan(eps))));
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) / math.cos(x) return (eps * (t_0 + (math.cos(x) + (math.pow(eps, 2.0) * (((math.cos(x) * 0.3333333333333333) + (math.pow(eps, 2.0) * (0.13333333333333333 + (math.pow(eps, 2.0) * 0.05396825396825397)))) - (t_0 * -0.3333333333333333)))))) / (math.cos(x) * (1.0 - (math.tan(x) * math.tan(eps))))
function code(x, eps) t_0 = Float64((sin(x) ^ 2.0) / cos(x)) return Float64(Float64(eps * Float64(t_0 + Float64(cos(x) + Float64((eps ^ 2.0) * Float64(Float64(Float64(cos(x) * 0.3333333333333333) + Float64((eps ^ 2.0) * Float64(0.13333333333333333 + Float64((eps ^ 2.0) * 0.05396825396825397)))) - Float64(t_0 * -0.3333333333333333)))))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))) end
function tmp = code(x, eps) t_0 = (sin(x) ^ 2.0) / cos(x); tmp = (eps * (t_0 + (cos(x) + ((eps ^ 2.0) * (((cos(x) * 0.3333333333333333) + ((eps ^ 2.0) * (0.13333333333333333 + ((eps ^ 2.0) * 0.05396825396825397)))) - (t_0 * -0.3333333333333333)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps)))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * N[(t$95$0 + N[(N[Cos[x], $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(0.13333333333333333 + N[(N[Power[eps, 2.0], $MachinePrecision] * 0.05396825396825397), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{\cos x}\\
\frac{\varepsilon \cdot \left(t\_0 + \left(\cos x + {\varepsilon}^{2} \cdot \left(\left(\cos x \cdot 0.3333333333333333 + {\varepsilon}^{2} \cdot \left(0.13333333333333333 + {\varepsilon}^{2} \cdot 0.05396825396825397\right)\right) - t\_0 \cdot -0.3333333333333333\right)\right)\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}
\end{array}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 99.6%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (pow (sin x) 2.0) (cos x))))
(/
(*
eps
(+
t_0
(+ (cos x) (* (pow eps 2.0) (* 0.3333333333333333 (+ (cos x) t_0))))))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0) / cos(x);
return (eps * (t_0 + (cos(x) + (pow(eps, 2.0) * (0.3333333333333333 * (cos(x) + t_0)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = (sin(x) ** 2.0d0) / cos(x)
code = (eps * (t_0 + (cos(x) + ((eps ** 2.0d0) * (0.3333333333333333d0 * (cos(x) + t_0)))))) / (cos(x) * (1.0d0 - (tan(x) * tan(eps))))
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0) / Math.cos(x);
return (eps * (t_0 + (Math.cos(x) + (Math.pow(eps, 2.0) * (0.3333333333333333 * (Math.cos(x) + t_0)))))) / (Math.cos(x) * (1.0 - (Math.tan(x) * Math.tan(eps))));
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) / math.cos(x) return (eps * (t_0 + (math.cos(x) + (math.pow(eps, 2.0) * (0.3333333333333333 * (math.cos(x) + t_0)))))) / (math.cos(x) * (1.0 - (math.tan(x) * math.tan(eps))))
function code(x, eps) t_0 = Float64((sin(x) ^ 2.0) / cos(x)) return Float64(Float64(eps * Float64(t_0 + Float64(cos(x) + Float64((eps ^ 2.0) * Float64(0.3333333333333333 * Float64(cos(x) + t_0)))))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))) end
function tmp = code(x, eps) t_0 = (sin(x) ^ 2.0) / cos(x); tmp = (eps * (t_0 + (cos(x) + ((eps ^ 2.0) * (0.3333333333333333 * (cos(x) + t_0)))))) / (cos(x) * (1.0 - (tan(x) * tan(eps)))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * N[(t$95$0 + N[(N[Cos[x], $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(0.3333333333333333 * N[(N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{\cos x}\\
\frac{\varepsilon \cdot \left(t\_0 + \left(\cos x + {\varepsilon}^{2} \cdot \left(0.3333333333333333 \cdot \left(\cos x + t\_0\right)\right)\right)\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}
\end{array}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 99.6%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
distribute-lft-out99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(/
(*
eps
(+
(/ (pow (sin x) 2.0) (cos x))
(+
(cos x)
(*
(pow eps 2.0)
(+
0.3333333333333333
(*
(pow eps 2.0)
(+ 0.13333333333333333 (* (pow eps 2.0) 0.05396825396825397))))))))
(* (cos x) (- 1.0 (* (tan x) (tan eps))))))
double code(double x, double eps) {
return (eps * ((pow(sin(x), 2.0) / cos(x)) + (cos(x) + (pow(eps, 2.0) * (0.3333333333333333 + (pow(eps, 2.0) * (0.13333333333333333 + (pow(eps, 2.0) * 0.05396825396825397)))))))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * (((sin(x) ** 2.0d0) / cos(x)) + (cos(x) + ((eps ** 2.0d0) * (0.3333333333333333d0 + ((eps ** 2.0d0) * (0.13333333333333333d0 + ((eps ** 2.0d0) * 0.05396825396825397d0)))))))) / (cos(x) * (1.0d0 - (tan(x) * tan(eps))))
end function
public static double code(double x, double eps) {
return (eps * ((Math.pow(Math.sin(x), 2.0) / Math.cos(x)) + (Math.cos(x) + (Math.pow(eps, 2.0) * (0.3333333333333333 + (Math.pow(eps, 2.0) * (0.13333333333333333 + (Math.pow(eps, 2.0) * 0.05396825396825397)))))))) / (Math.cos(x) * (1.0 - (Math.tan(x) * Math.tan(eps))));
}
def code(x, eps): return (eps * ((math.pow(math.sin(x), 2.0) / math.cos(x)) + (math.cos(x) + (math.pow(eps, 2.0) * (0.3333333333333333 + (math.pow(eps, 2.0) * (0.13333333333333333 + (math.pow(eps, 2.0) * 0.05396825396825397)))))))) / (math.cos(x) * (1.0 - (math.tan(x) * math.tan(eps))))
function code(x, eps) return Float64(Float64(eps * Float64(Float64((sin(x) ^ 2.0) / cos(x)) + Float64(cos(x) + Float64((eps ^ 2.0) * Float64(0.3333333333333333 + Float64((eps ^ 2.0) * Float64(0.13333333333333333 + Float64((eps ^ 2.0) * 0.05396825396825397)))))))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))) end
function tmp = code(x, eps) tmp = (eps * (((sin(x) ^ 2.0) / cos(x)) + (cos(x) + ((eps ^ 2.0) * (0.3333333333333333 + ((eps ^ 2.0) * (0.13333333333333333 + ((eps ^ 2.0) * 0.05396825396825397)))))))) / (cos(x) * (1.0 - (tan(x) * tan(eps)))); end
code[x_, eps_] := N[(N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(0.13333333333333333 + N[(N[Power[eps, 2.0], $MachinePrecision] * 0.05396825396825397), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon \cdot \left(\frac{{\sin x}^{2}}{\cos x} + \left(\cos x + {\varepsilon}^{2} \cdot \left(0.3333333333333333 + {\varepsilon}^{2} \cdot \left(0.13333333333333333 + {\varepsilon}^{2} \cdot 0.05396825396825397\right)\right)\right)\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 99.6%
Taylor expanded in x around 0 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (/ (* eps (+ (cos x) (/ (pow (sin x) 2.0) (cos x)))) (- (cos x) (* eps (sin x)))))
double code(double x, double eps) {
return (eps * (cos(x) + (pow(sin(x), 2.0) / cos(x)))) / (cos(x) - (eps * sin(x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * (cos(x) + ((sin(x) ** 2.0d0) / cos(x)))) / (cos(x) - (eps * sin(x)))
end function
public static double code(double x, double eps) {
return (eps * (Math.cos(x) + (Math.pow(Math.sin(x), 2.0) / Math.cos(x)))) / (Math.cos(x) - (eps * Math.sin(x)));
}
def code(x, eps): return (eps * (math.cos(x) + (math.pow(math.sin(x), 2.0) / math.cos(x)))) / (math.cos(x) - (eps * math.sin(x)))
function code(x, eps) return Float64(Float64(eps * Float64(cos(x) + Float64((sin(x) ^ 2.0) / cos(x)))) / Float64(cos(x) - Float64(eps * sin(x)))) end
function tmp = code(x, eps) tmp = (eps * (cos(x) + ((sin(x) ^ 2.0) / cos(x)))) / (cos(x) - (eps * sin(x))); end
code[x_, eps_] := N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{\cos x - \varepsilon \cdot \sin x}
\end{array}
Initial program 61.1%
tan-sum61.2%
tan-quot61.2%
frac-sub61.3%
Applied egg-rr61.3%
Taylor expanded in eps around 0 98.9%
cancel-sign-sub-inv98.9%
metadata-eval98.9%
*-lft-identity98.9%
Simplified98.9%
Taylor expanded in eps around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
*-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (* eps (+ (/ (pow (sin x) 2.0) (log (exp (pow (cos x) 2.0)))) 1.0)))
double code(double x, double eps) {
return eps * ((pow(sin(x), 2.0) / log(exp(pow(cos(x), 2.0)))) + 1.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (((sin(x) ** 2.0d0) / log(exp((cos(x) ** 2.0d0)))) + 1.0d0)
end function
public static double code(double x, double eps) {
return eps * ((Math.pow(Math.sin(x), 2.0) / Math.log(Math.exp(Math.pow(Math.cos(x), 2.0)))) + 1.0);
}
def code(x, eps): return eps * ((math.pow(math.sin(x), 2.0) / math.log(math.exp(math.pow(math.cos(x), 2.0)))) + 1.0)
function code(x, eps) return Float64(eps * Float64(Float64((sin(x) ^ 2.0) / log(exp((cos(x) ^ 2.0)))) + 1.0)) end
function tmp = code(x, eps) tmp = eps * (((sin(x) ^ 2.0) / log(exp((cos(x) ^ 2.0)))) + 1.0); end
code[x_, eps_] := N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Log[N[Exp[N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\frac{{\sin x}^{2}}{\log \left(e^{{\cos x}^{2}}\right)} + 1\right)
\end{array}
Initial program 61.1%
Taylor expanded in eps around 0 98.5%
sub-neg98.5%
mul-1-neg98.5%
remove-double-neg98.5%
Simplified98.5%
add-log-exp98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x eps) :precision binary64 (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0)))
double code(double x, double eps) {
return eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
end function
public static double code(double x, double eps) {
return eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
}
def code(x, eps): return eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0)
function code(x, eps) return Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)) end
function tmp = code(x, eps) tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); end
code[x_, eps_] := N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)
\end{array}
Initial program 61.1%
Taylor expanded in eps around 0 98.5%
sub-neg98.5%
mul-1-neg98.5%
remove-double-neg98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x eps) :precision binary64 (* eps (+ (pow (/ (sin x) (cos x)) 2.0) 1.0)))
double code(double x, double eps) {
return eps * (pow((sin(x) / cos(x)), 2.0) + 1.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (((sin(x) / cos(x)) ** 2.0d0) + 1.0d0)
end function
public static double code(double x, double eps) {
return eps * (Math.pow((Math.sin(x) / Math.cos(x)), 2.0) + 1.0);
}
def code(x, eps): return eps * (math.pow((math.sin(x) / math.cos(x)), 2.0) + 1.0)
function code(x, eps) return Float64(eps * Float64((Float64(sin(x) / cos(x)) ^ 2.0) + 1.0)) end
function tmp = code(x, eps) tmp = eps * (((sin(x) / cos(x)) ^ 2.0) + 1.0); end
code[x_, eps_] := N[(eps * N[(N[Power[N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left({\left(\frac{\sin x}{\cos x}\right)}^{2} + 1\right)
\end{array}
Initial program 61.1%
tan-quot61.1%
frac-2neg61.1%
Applied egg-rr61.1%
Taylor expanded in eps around 0 98.5%
sub-neg98.5%
mul-1-neg98.5%
remove-double-neg98.5%
unpow298.5%
unpow298.5%
times-frac98.5%
remove-double-neg98.5%
distribute-frac-neg298.5%
distribute-frac-neg98.5%
remove-double-neg98.5%
distribute-frac-neg298.5%
distribute-frac-neg98.5%
unpow298.5%
distribute-frac-neg98.5%
distribute-frac-neg298.5%
remove-double-neg98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x eps) :precision binary64 (+ (* eps (+ (* (pow eps 2.0) 0.3333333333333333) 1.0)) (* x (* eps (+ eps x)))))
double code(double x, double eps) {
return (eps * ((pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * (eps + x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * (((eps ** 2.0d0) * 0.3333333333333333d0) + 1.0d0)) + (x * (eps * (eps + x)))
end function
public static double code(double x, double eps) {
return (eps * ((Math.pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * (eps + x)));
}
def code(x, eps): return (eps * ((math.pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * (eps + x)))
function code(x, eps) return Float64(Float64(eps * Float64(Float64((eps ^ 2.0) * 0.3333333333333333) + 1.0)) + Float64(x * Float64(eps * Float64(eps + x)))) end
function tmp = code(x, eps) tmp = (eps * (((eps ^ 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * (eps + x))); end
code[x_, eps_] := N[(N[(eps * N[(N[(N[Power[eps, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x * N[(eps * N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left({\varepsilon}^{2} \cdot 0.3333333333333333 + 1\right) + x \cdot \left(\varepsilon \cdot \left(\varepsilon + x\right)\right)
\end{array}
Initial program 61.1%
Taylor expanded in eps around 0 99.4%
Simplified99.4%
Taylor expanded in x around 0 98.1%
Taylor expanded in eps around 0 98.1%
Final simplification98.1%
(FPCore (x eps) :precision binary64 (+ (* eps (+ (* (pow eps 2.0) 0.3333333333333333) 1.0)) (* x (* eps x))))
double code(double x, double eps) {
return (eps * ((pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * (((eps ** 2.0d0) * 0.3333333333333333d0) + 1.0d0)) + (x * (eps * x))
end function
public static double code(double x, double eps) {
return (eps * ((Math.pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * x));
}
def code(x, eps): return (eps * ((math.pow(eps, 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * x))
function code(x, eps) return Float64(Float64(eps * Float64(Float64((eps ^ 2.0) * 0.3333333333333333) + 1.0)) + Float64(x * Float64(eps * x))) end
function tmp = code(x, eps) tmp = (eps * (((eps ^ 2.0) * 0.3333333333333333) + 1.0)) + (x * (eps * x)); end
code[x_, eps_] := N[(N[(eps * N[(N[(N[Power[eps, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x * N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left({\varepsilon}^{2} \cdot 0.3333333333333333 + 1\right) + x \cdot \left(\varepsilon \cdot x\right)
\end{array}
Initial program 61.1%
Taylor expanded in eps around 0 99.4%
Simplified99.4%
Taylor expanded in x around 0 98.1%
Taylor expanded in eps around 0 98.0%
Final simplification98.0%
(FPCore (x eps) :precision binary64 (+ eps (* eps (pow x 2.0))))
double code(double x, double eps) {
return eps + (eps * pow(x, 2.0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps + (eps * (x ** 2.0d0))
end function
public static double code(double x, double eps) {
return eps + (eps * Math.pow(x, 2.0));
}
def code(x, eps): return eps + (eps * math.pow(x, 2.0))
function code(x, eps) return Float64(eps + Float64(eps * (x ^ 2.0))) end
function tmp = code(x, eps) tmp = eps + (eps * (x ^ 2.0)); end
code[x_, eps_] := N[(eps + N[(eps * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon + \varepsilon \cdot {x}^{2}
\end{array}
Initial program 61.1%
Taylor expanded in eps around 0 98.5%
sub-neg98.5%
mul-1-neg98.5%
remove-double-neg98.5%
Simplified98.5%
Taylor expanded in x around 0 98.0%
(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 61.1%
Taylor expanded in x around 0 97.8%
tan-quot97.8%
*-un-lft-identity97.8%
Applied egg-rr97.8%
*-lft-identity97.8%
Simplified97.8%
(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 61.1%
Taylor expanded in x around 0 97.8%
Taylor expanded in eps around 0 97.6%
(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}
herbie shell --seed 2024157
(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)))))
(- (tan (+ x eps)) (tan x)))