
(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 9 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 (* (tan x) (tan eps)))) (* (tan x) (/ (+ t_0 (/ 1.0 (/ (tan x) (tan eps)))) (- 1.0 t_0)))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return tan(x) * ((t_0 + (1.0 / (tan(x) / tan(eps)))) / (1.0 - t_0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = tan(x) * tan(eps)
code = tan(x) * ((t_0 + (1.0d0 / (tan(x) / tan(eps)))) / (1.0d0 - t_0))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
return Math.tan(x) * ((t_0 + (1.0 / (Math.tan(x) / Math.tan(eps)))) / (1.0 - t_0));
}
def code(x, eps): t_0 = math.tan(x) * math.tan(eps) return math.tan(x) * ((t_0 + (1.0 / (math.tan(x) / math.tan(eps)))) / (1.0 - t_0))
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(tan(x) * Float64(Float64(t_0 + Float64(1.0 / Float64(tan(x) / tan(eps)))) / Float64(1.0 - t_0))) end
function tmp = code(x, eps) t_0 = tan(x) * tan(eps); tmp = tan(x) * ((t_0 + (1.0 / (tan(x) / tan(eps)))) / (1.0 - t_0)); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[Tan[x], $MachinePrecision] * N[(N[(t$95$0 + N[(1.0 / N[(N[Tan[x], $MachinePrecision] / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\tan x \cdot \frac{t\_0 + \frac{1}{\frac{\tan x}{\tan \varepsilon}}}{1 - t\_0}
\end{array}
\end{array}
Initial program 62.7%
tan-sumN/A
tan-quotN/A
clear-numN/A
frac-subN/A
/-lowering-/.f64N/A
Applied egg-rr62.0%
Taylor expanded in x around inf
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
Simplified99.4%
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr99.4%
un-div-invN/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (let* ((t_0 (* (tan x) (tan eps)))) (* (tan x) (/ (+ t_0 (* (tan eps) (/ 1.0 (tan x)))) (- 1.0 t_0)))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return tan(x) * ((t_0 + (tan(eps) * (1.0 / tan(x)))) / (1.0 - t_0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = tan(x) * tan(eps)
code = tan(x) * ((t_0 + (tan(eps) * (1.0d0 / tan(x)))) / (1.0d0 - t_0))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
return Math.tan(x) * ((t_0 + (Math.tan(eps) * (1.0 / Math.tan(x)))) / (1.0 - t_0));
}
def code(x, eps): t_0 = math.tan(x) * math.tan(eps) return math.tan(x) * ((t_0 + (math.tan(eps) * (1.0 / math.tan(x)))) / (1.0 - t_0))
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(tan(x) * Float64(Float64(t_0 + Float64(tan(eps) * Float64(1.0 / tan(x)))) / Float64(1.0 - t_0))) end
function tmp = code(x, eps) t_0 = tan(x) * tan(eps); tmp = tan(x) * ((t_0 + (tan(eps) * (1.0 / tan(x)))) / (1.0 - t_0)); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[Tan[x], $MachinePrecision] * N[(N[(t$95$0 + N[(N[Tan[eps], $MachinePrecision] * N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\tan x \cdot \frac{t\_0 + \tan \varepsilon \cdot \frac{1}{\tan x}}{1 - t\_0}
\end{array}
\end{array}
Initial program 62.7%
tan-sumN/A
tan-quotN/A
clear-numN/A
frac-subN/A
/-lowering-/.f64N/A
Applied egg-rr62.0%
Taylor expanded in x around inf
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
Simplified99.4%
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (/ (tan x) (/ (- 1.0 (* (tan x) (tan eps))) (* (tan eps) (+ (tan x) (/ 1.0 (tan x)))))))
double code(double x, double eps) {
return tan(x) / ((1.0 - (tan(x) * tan(eps))) / (tan(eps) * (tan(x) + (1.0 / tan(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(eps) * (tan(x) + (1.0d0 / tan(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(eps) * (Math.tan(x) + (1.0 / Math.tan(x)))));
}
def code(x, eps): return math.tan(x) / ((1.0 - (math.tan(x) * math.tan(eps))) / (math.tan(eps) * (math.tan(x) + (1.0 / math.tan(x)))))
function code(x, eps) return Float64(tan(x) / Float64(Float64(1.0 - Float64(tan(x) * tan(eps))) / Float64(tan(eps) * Float64(tan(x) + Float64(1.0 / tan(x)))))) end
function tmp = code(x, eps) tmp = tan(x) / ((1.0 - (tan(x) * tan(eps))) / (tan(eps) * (tan(x) + (1.0 / tan(x))))); end
code[x_, eps_] := N[(N[Tan[x], $MachinePrecision] / N[(N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Tan[eps], $MachinePrecision] * N[(N[Tan[x], $MachinePrecision] + N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan x}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan \varepsilon \cdot \left(\tan x + \frac{1}{\tan x}\right)}}
\end{array}
Initial program 62.7%
tan-sumN/A
tan-quotN/A
clear-numN/A
frac-subN/A
/-lowering-/.f64N/A
Applied egg-rr62.0%
Taylor expanded in x around inf
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
Simplified99.4%
un-div-invN/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr99.4%
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
Applied egg-rr99.3%
(FPCore (x eps) :precision binary64 (+ (* eps (+ 1.0 (* (* eps eps) 0.3333333333333333))) (* x (* eps (+ eps (* x (+ 1.0 (* (* eps eps) 1.3333333333333333))))))))
double code(double x, double eps) {
return (eps * (1.0 + ((eps * eps) * 0.3333333333333333))) + (x * (eps * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * (1.0d0 + ((eps * eps) * 0.3333333333333333d0))) + (x * (eps * (eps + (x * (1.0d0 + ((eps * eps) * 1.3333333333333333d0))))))
end function
public static double code(double x, double eps) {
return (eps * (1.0 + ((eps * eps) * 0.3333333333333333))) + (x * (eps * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))));
}
def code(x, eps): return (eps * (1.0 + ((eps * eps) * 0.3333333333333333))) + (x * (eps * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))))
function code(x, eps) return Float64(Float64(eps * Float64(1.0 + Float64(Float64(eps * eps) * 0.3333333333333333))) + Float64(x * Float64(eps * Float64(eps + Float64(x * Float64(1.0 + Float64(Float64(eps * eps) * 1.3333333333333333))))))) end
function tmp = code(x, eps) tmp = (eps * (1.0 + ((eps * eps) * 0.3333333333333333))) + (x * (eps * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333)))))); end
code[x_, eps_] := N[(N[(eps * N[(1.0 + N[(N[(eps * eps), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(eps * N[(eps + N[(x * N[(1.0 + N[(N[(eps * eps), $MachinePrecision] * 1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + \left(\varepsilon \cdot \varepsilon\right) \cdot 0.3333333333333333\right) + x \cdot \left(\varepsilon \cdot \left(\varepsilon + x \cdot \left(1 + \left(\varepsilon \cdot \varepsilon\right) \cdot 1.3333333333333333\right)\right)\right)
\end{array}
Initial program 62.7%
Taylor expanded in eps around 0
Simplified99.0%
Taylor expanded in x around 0
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6498.4%
Simplified98.4%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
unpow2N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.5%
Simplified98.5%
(FPCore (x eps) :precision binary64 (* eps (+ (+ 1.0 (* (* eps eps) 0.3333333333333333)) (* x (+ eps (* x (+ 1.0 (* (* eps eps) 1.3333333333333333))))))))
double code(double x, double eps) {
return eps * ((1.0 + ((eps * eps) * 0.3333333333333333)) + (x * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((1.0d0 + ((eps * eps) * 0.3333333333333333d0)) + (x * (eps + (x * (1.0d0 + ((eps * eps) * 1.3333333333333333d0))))))
end function
public static double code(double x, double eps) {
return eps * ((1.0 + ((eps * eps) * 0.3333333333333333)) + (x * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))));
}
def code(x, eps): return eps * ((1.0 + ((eps * eps) * 0.3333333333333333)) + (x * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333))))))
function code(x, eps) return Float64(eps * Float64(Float64(1.0 + Float64(Float64(eps * eps) * 0.3333333333333333)) + Float64(x * Float64(eps + Float64(x * Float64(1.0 + Float64(Float64(eps * eps) * 1.3333333333333333))))))) end
function tmp = code(x, eps) tmp = eps * ((1.0 + ((eps * eps) * 0.3333333333333333)) + (x * (eps + (x * (1.0 + ((eps * eps) * 1.3333333333333333)))))); end
code[x_, eps_] := N[(eps * N[(N[(1.0 + N[(N[(eps * eps), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + N[(x * N[(eps + N[(x * N[(1.0 + N[(N[(eps * eps), $MachinePrecision] * 1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\left(1 + \left(\varepsilon \cdot \varepsilon\right) \cdot 0.3333333333333333\right) + x \cdot \left(\varepsilon + x \cdot \left(1 + \left(\varepsilon \cdot \varepsilon\right) \cdot 1.3333333333333333\right)\right)\right)
\end{array}
Initial program 62.7%
Taylor expanded in eps around 0
Simplified99.0%
Taylor expanded in x around 0
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x eps) :precision binary64 (+ eps (* x (* eps (+ eps (* x (+ 1.0 (* eps (* eps 1.3333333333333333)))))))))
double code(double x, double eps) {
return eps + (x * (eps * (eps + (x * (1.0 + (eps * (eps * 1.3333333333333333)))))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps + (x * (eps * (eps + (x * (1.0d0 + (eps * (eps * 1.3333333333333333d0)))))))
end function
public static double code(double x, double eps) {
return eps + (x * (eps * (eps + (x * (1.0 + (eps * (eps * 1.3333333333333333)))))));
}
def code(x, eps): return eps + (x * (eps * (eps + (x * (1.0 + (eps * (eps * 1.3333333333333333)))))))
function code(x, eps) return Float64(eps + Float64(x * Float64(eps * Float64(eps + Float64(x * Float64(1.0 + Float64(eps * Float64(eps * 1.3333333333333333)))))))) end
function tmp = code(x, eps) tmp = eps + (x * (eps * (eps + (x * (1.0 + (eps * (eps * 1.3333333333333333))))))); end
code[x_, eps_] := N[(eps + N[(x * N[(eps * N[(eps + N[(x * N[(1.0 + N[(eps * N[(eps * 1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon + x \cdot \left(\varepsilon \cdot \left(\varepsilon + x \cdot \left(1 + \varepsilon \cdot \left(\varepsilon \cdot 1.3333333333333333\right)\right)\right)\right)
\end{array}
Initial program 62.7%
Taylor expanded in eps around 0
Simplified99.0%
Taylor expanded in x around 0
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6498.4%
Simplified98.4%
Taylor expanded in eps around 0
Simplified98.3%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
unpow2N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6498.3%
Simplified98.3%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (* x (+ x (* eps (+ 1.0 (* 1.3333333333333333 (* x x)))))))))
double code(double x, double eps) {
return eps * (1.0 + (x * (x + (eps * (1.0 + (1.3333333333333333 * (x * x)))))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + (x * (x + (eps * (1.0d0 + (1.3333333333333333d0 * (x * x)))))))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (x * (x + (eps * (1.0 + (1.3333333333333333 * (x * x)))))));
}
def code(x, eps): return eps * (1.0 + (x * (x + (eps * (1.0 + (1.3333333333333333 * (x * x)))))))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64(x * Float64(x + Float64(eps * Float64(1.0 + Float64(1.3333333333333333 * Float64(x * x)))))))) end
function tmp = code(x, eps) tmp = eps * (1.0 + (x * (x + (eps * (1.0 + (1.3333333333333333 * (x * x))))))); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(x * N[(x + N[(eps * N[(1.0 + N[(1.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + x \cdot \left(x + \varepsilon \cdot \left(1 + 1.3333333333333333 \cdot \left(x \cdot x\right)\right)\right)\right)
\end{array}
Initial program 62.7%
Taylor expanded in eps around 0
Simplified99.0%
Taylor expanded in x around 0
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6498.4%
Simplified98.4%
Taylor expanded in eps around 0
Simplified98.3%
Taylor expanded in eps around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (* eps (+ 1.0 (* x x))))
double code(double x, double eps) {
return eps * (1.0 + (x * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (1.0d0 + (x * x))
end function
public static double code(double x, double eps) {
return eps * (1.0 + (x * x));
}
def code(x, eps): return eps * (1.0 + (x * x))
function code(x, eps) return Float64(eps * Float64(1.0 + Float64(x * x))) end
function tmp = code(x, eps) tmp = eps * (1.0 + (x * x)); end
code[x_, eps_] := N[(eps * N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(1 + x \cdot x\right)
\end{array}
Initial program 62.7%
Taylor expanded in eps around 0
Simplified99.0%
Taylor expanded in x around 0
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
unpow2N/A
distribute-lft-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f6498.4%
Simplified98.4%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6498.3%
Simplified98.3%
Final simplification98.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 62.7%
Taylor expanded in x around 0
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6497.7%
Simplified97.7%
Taylor expanded in eps around 0
Simplified97.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 2024288
(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)))