
(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 12 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 (+ (- (/ (tan x) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (/ (sin eps) (* (cos eps) (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))))))
double code(double x, double eps) {
return ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - tan(x)) + (sin(eps) / (cos(eps) * (1.0 - ((sin(x) * tan(eps)) / cos(x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((tan(x) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)) + (sin(eps) / (cos(eps) * (1.0d0 - ((sin(x) * tan(eps)) / cos(x)))))
end function
public static double code(double x, double eps) {
return ((Math.tan(x) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x)) + (Math.sin(eps) / (Math.cos(eps) * (1.0 - ((Math.sin(x) * Math.tan(eps)) / Math.cos(x)))));
}
def code(x, eps): return ((math.tan(x) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x)) + (math.sin(eps) / (math.cos(eps) * (1.0 - ((math.sin(x) * math.tan(eps)) / math.cos(x)))))
function code(x, eps) return Float64(Float64(Float64(tan(x) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)) + Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))))) end
function tmp = code(x, eps) tmp = ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - tan(x)) + (sin(eps) / (cos(eps) * (1.0 - ((sin(x) * tan(eps)) / cos(x))))); end
code[x_, eps_] := N[(N[(N[(N[Tan[x], $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right) + \frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right)}
\end{array}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
Taylor expanded in x around inf 67.5%
associate--l+79.3%
times-frac79.3%
associate-/r*79.4%
times-frac79.4%
Simplified79.4%
tan-quot77.7%
sub-neg77.7%
tan-quot79.4%
tan-quot79.4%
tan-quot79.4%
Applied egg-rr79.4%
sub-neg79.4%
*-commutative79.4%
Simplified79.4%
tan-quot79.5%
associate-*r/79.5%
Applied egg-rr79.5%
Final simplification79.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps))))
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(- (/ (tan x) (- 1.0 (* (tan x) (tan eps)))) (tan x)))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
return (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - tan(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = sin(eps) / cos(eps)
code = (t_0 / (1.0d0 - (t_0 * (sin(x) / cos(x))))) + ((tan(x) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x))
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) / Math.cos(eps);
return (t_0 / (1.0 - (t_0 * (Math.sin(x) / Math.cos(x))))) + ((Math.tan(x) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x));
}
def code(x, eps): t_0 = math.sin(eps) / math.cos(eps) return (t_0 / (1.0 - (t_0 * (math.sin(x) / math.cos(x))))) + ((math.tan(x) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x))
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) return Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(Float64(tan(x) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x))) end
function tmp = code(x, eps) t_0 = sin(eps) / cos(eps); tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - tan(x)); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / N[(1.0 - N[(t$95$0 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\frac{t\_0}{1 - t\_0 \cdot \frac{\sin x}{\cos x}} + \left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right)
\end{array}
\end{array}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
Taylor expanded in x around inf 67.5%
associate--l+79.3%
times-frac79.3%
associate-/r*79.4%
times-frac79.4%
Simplified79.4%
tan-quot77.7%
sub-neg77.7%
tan-quot79.4%
tan-quot79.4%
tan-quot79.4%
Applied egg-rr79.4%
sub-neg79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in eps around inf 79.5%
associate-/r*79.4%
times-frac79.4%
Simplified79.4%
Final simplification79.4%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- 1.0 (* (tan x) (tan eps))))) (+ (- (/ (tan x) t_0) (tan x)) (pow (cbrt (/ (tan eps) t_0)) 3.0))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
return ((tan(x) / t_0) - tan(x)) + pow(cbrt((tan(eps) / t_0)), 3.0);
}
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(x) * Math.tan(eps));
return ((Math.tan(x) / t_0) - Math.tan(x)) + Math.pow(Math.cbrt((Math.tan(eps) / t_0)), 3.0);
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) return Float64(Float64(Float64(tan(x) / t_0) - tan(x)) + (cbrt(Float64(tan(eps) / t_0)) ^ 3.0)) end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
\left(\frac{\tan x}{t\_0} - \tan x\right) + {\left(\sqrt[3]{\frac{\tan \varepsilon}{t\_0}}\right)}^{3}
\end{array}
\end{array}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
Taylor expanded in x around inf 67.5%
associate--l+79.3%
times-frac79.3%
associate-/r*79.4%
times-frac79.4%
Simplified79.4%
tan-quot77.7%
sub-neg77.7%
tan-quot79.4%
tan-quot79.4%
tan-quot79.4%
Applied egg-rr79.4%
sub-neg79.4%
*-commutative79.4%
Simplified79.4%
add-cube-cbrt78.3%
pow378.3%
associate-/r*78.3%
tan-quot78.3%
tan-quot78.3%
tan-quot78.3%
Applied egg-rr78.3%
Final simplification78.3%
(FPCore (x eps) :precision binary64 (- (/ (- (- (tan x)) (tan eps)) (fma (tan x) (tan eps) -1.0)) (tan x)))
double code(double x, double eps) {
return ((-tan(x) - tan(eps)) / fma(tan(x), tan(eps), -1.0)) - tan(x);
}
function code(x, eps) return Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / fma(tan(x), tan(eps), -1.0)) - tan(x)) end
code[x_, eps_] := N[(N[(N[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-\tan x\right) - \tan \varepsilon}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)} - \tan x
\end{array}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
frac-2neg67.8%
distribute-frac-neg67.8%
sub-neg67.8%
distribute-neg-in67.8%
metadata-eval67.8%
distribute-lft-neg-in67.8%
add-sqr-sqrt33.7%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod22.0%
add-sqr-sqrt44.5%
distribute-lft-neg-in44.5%
add-sqr-sqrt22.5%
Applied egg-rr67.8%
distribute-neg-frac67.8%
+-commutative67.8%
fma-def67.8%
Simplified67.8%
Final simplification67.8%
(FPCore (x eps) :precision binary64 (- (/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x)))
double code(double x, double eps) {
return ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / 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) / (1.0d0 / 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) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
def code(x, eps): return ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x)
function code(x, eps) return Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)) end
function tmp = code(x, eps) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / 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[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x
\end{array}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
tan-quot67.8%
clear-num67.8%
un-div-inv67.8%
clear-num67.8%
tan-quot67.8%
Applied egg-rr67.8%
Final simplification67.8%
(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}
Initial program 42.9%
tan-sum67.8%
div-inv67.7%
*-un-lft-identity67.7%
prod-diff67.7%
*-commutative67.7%
*-un-lft-identity67.7%
*-commutative67.7%
*-un-lft-identity67.7%
Applied egg-rr67.7%
+-commutative67.7%
fma-udef67.7%
associate-+r+67.7%
unsub-neg67.7%
Simplified67.8%
Final simplification67.8%
(FPCore (x eps) :precision binary64 (fma eps (pow (tan x) 2.0) eps))
double code(double x, double eps) {
return fma(eps, pow(tan(x), 2.0), eps);
}
function code(x, eps) return fma(eps, (tan(x) ^ 2.0), eps) end
code[x_, eps_] := N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)
\end{array}
Initial program 42.9%
Taylor expanded in eps around 0 49.4%
cancel-sign-sub-inv49.4%
metadata-eval49.4%
*-lft-identity49.4%
Simplified49.4%
distribute-rgt-in49.5%
*-un-lft-identity49.5%
unpow249.5%
unpow249.5%
frac-times49.4%
tan-quot49.5%
tan-quot49.5%
pow249.5%
Applied egg-rr49.5%
+-commutative49.5%
*-commutative49.5%
fma-def49.5%
Simplified49.5%
Final simplification49.5%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (pow (tan x) 2.0))))
double code(double x, double eps) {
return eps * (1.0 + pow(tan(x), 2.0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + (tan(x) ** 2.0d0))
end function
public static double code(double x, double eps) {
return eps * (1.0 + Math.pow(Math.tan(x), 2.0));
}
def code(x, eps): return eps * (1.0 + math.pow(math.tan(x), 2.0))
function code(x, eps) return Float64(eps * Float64(1.0 + (tan(x) ^ 2.0))) end
function tmp = code(x, eps) tmp = eps * (1.0 + (tan(x) ^ 2.0)); end
code[x_, eps_] := N[(eps * N[(1.0 + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + {\tan x}^{2}\right)
\end{array}
Initial program 42.9%
Taylor expanded in eps around 0 49.4%
cancel-sign-sub-inv49.4%
metadata-eval49.4%
*-lft-identity49.4%
Simplified49.4%
*-un-lft-identity49.4%
unpow249.4%
unpow249.4%
frac-times49.4%
tan-quot49.4%
tan-quot49.4%
pow249.4%
Applied egg-rr49.4%
*-lft-identity49.4%
Simplified49.4%
Final simplification49.4%
(FPCore (x eps) :precision binary64 (+ eps (* eps (pow (tan x) 2.0))))
double code(double x, double eps) {
return eps + (eps * pow(tan(x), 2.0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps + (eps * (tan(x) ** 2.0d0))
end function
public static double code(double x, double eps) {
return eps + (eps * Math.pow(Math.tan(x), 2.0));
}
def code(x, eps): return eps + (eps * math.pow(math.tan(x), 2.0))
function code(x, eps) return Float64(eps + Float64(eps * (tan(x) ^ 2.0))) end
function tmp = code(x, eps) tmp = eps + (eps * (tan(x) ^ 2.0)); end
code[x_, eps_] := N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon + \varepsilon \cdot {\tan x}^{2}
\end{array}
Initial program 42.9%
Taylor expanded in eps around 0 49.4%
cancel-sign-sub-inv49.4%
metadata-eval49.4%
*-lft-identity49.4%
Simplified49.4%
distribute-rgt-in49.5%
*-un-lft-identity49.5%
unpow249.5%
unpow249.5%
frac-times49.4%
tan-quot49.5%
tan-quot49.5%
pow249.5%
Applied egg-rr49.5%
Final simplification49.5%
(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 42.9%
Taylor expanded in x around 0 56.4%
tan-quot56.5%
expm1-log1p-u51.3%
expm1-udef27.3%
Applied egg-rr27.3%
expm1-def51.3%
expm1-log1p56.5%
Simplified56.5%
Final simplification56.5%
(FPCore (x eps) :precision binary64 (/ 1.0 (+ (* eps -0.3333333333333333) (/ 1.0 eps))))
double code(double x, double eps) {
return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0 / ((eps * (-0.3333333333333333d0)) + (1.0d0 / eps))
end function
public static double code(double x, double eps) {
return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps));
}
def code(x, eps): return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps))
function code(x, eps) return Float64(1.0 / Float64(Float64(eps * -0.3333333333333333) + Float64(1.0 / eps))) end
function tmp = code(x, eps) tmp = 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps)); end
code[x_, eps_] := N[(1.0 / N[(N[(eps * -0.3333333333333333), $MachinePrecision] + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\varepsilon \cdot -0.3333333333333333 + \frac{1}{\varepsilon}}
\end{array}
Initial program 42.9%
Taylor expanded in x around 0 56.4%
tan-quot56.5%
add-cbrt-cube41.7%
pow1/326.3%
pow326.3%
Applied egg-rr26.3%
unpow1/341.7%
rem-cbrt-cube56.5%
tan-quot56.4%
clear-num56.3%
clear-num56.3%
tan-quot56.4%
Applied egg-rr56.4%
Taylor expanded in eps around 0 29.7%
Final simplification29.7%
(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 42.9%
Taylor expanded in x around 0 56.4%
Taylor expanded in eps around 0 29.4%
Final simplification29.4%
(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 2024033
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:precision binary64
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))