
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (- (* (+ (tan y) (tan z)) (/ -1.0 (+ -1.0 (* (tan y) (tan z))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) * (-1.0 / (-1.0 + (tan(y) * tan(z))))) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(y) + tan(z)) * ((-1.0d0) / ((-1.0d0) + (tan(y) * tan(z))))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(y) + Math.tan(z)) * (-1.0 / (-1.0 + (Math.tan(y) * Math.tan(z))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) * (-1.0 / (-1.0 + (math.tan(y) * math.tan(z))))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(-1.0 / Float64(-1.0 + Float64(tan(y) * tan(z))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) * (-1.0 / (-1.0 + (tan(y) * tan(z))))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) \cdot \frac{-1}{-1 + \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 74.5%
tan-sum99.8%
div-inv99.8%
fmm-def99.8%
Applied egg-rr99.8%
fmm-undef99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))) (t_1 (+ (tan y) (tan z))))
(if (<= (tan a) -0.02)
(fma t_1 1.0 t_0)
(if (<= (tan a) 1e-12)
(- x (+ a (* t_1 (/ 1.0 (+ -1.0 (* (tan y) (tan z)))))))
(fma (sin (+ y z)) (/ 1.0 (cos (+ y z))) t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double t_1 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.02) {
tmp = fma(t_1, 1.0, t_0);
} else if (tan(a) <= 1e-12) {
tmp = x - (a + (t_1 * (1.0 / (-1.0 + (tan(y) * tan(z))))));
} else {
tmp = fma(sin((y + z)), (1.0 / cos((y + z))), t_0);
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x - tan(a)) t_1 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.02) tmp = fma(t_1, 1.0, t_0); elseif (tan(a) <= 1e-12) tmp = Float64(x - Float64(a + Float64(t_1 * Float64(1.0 / Float64(-1.0 + Float64(tan(y) * tan(z))))))); else tmp = fma(sin(Float64(y + z)), Float64(1.0 / cos(Float64(y + z))), t_0); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], N[(t$95$1 * 1.0 + t$95$0), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-12], N[(x - N[(a + N[(t$95$1 * N[(1.0 / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
t_1 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, t\_0\right)\\
\mathbf{elif}\;\tan a \leq 10^{-12}:\\
\;\;\;\;x - \left(a + t\_1 \cdot \frac{1}{-1 + \tan y \cdot \tan z}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, t\_0\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004Initial program 79.0%
+-commutative79.0%
associate-+l-78.7%
tan-sum99.5%
div-inv99.5%
fmm-def99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 79.5%
if -0.0200000000000000004 < (tan.f64 a) < 9.9999999999999998e-13Initial program 74.0%
Taylor expanded in a around 0 74.0%
tan-sum99.7%
div-inv99.8%
fmm-def99.7%
Applied egg-rr99.7%
fmm-undef99.8%
Simplified99.8%
if 9.9999999999999998e-13 < (tan.f64 a) Initial program 70.8%
+-commutative70.8%
associate-+l-70.8%
tan-quot70.8%
div-inv70.8%
fmm-def70.9%
Applied egg-rr70.9%
Final simplification87.3%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))) (t_1 (+ (tan y) (tan z))))
(if (<= (tan a) -0.02)
(fma t_1 1.0 t_0)
(if (<= (tan a) 1e-12)
(- x (+ a (/ t_1 (+ -1.0 (* (tan y) (tan z))))))
(fma (sin (+ y z)) (/ 1.0 (cos (+ y z))) t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double t_1 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.02) {
tmp = fma(t_1, 1.0, t_0);
} else if (tan(a) <= 1e-12) {
tmp = x - (a + (t_1 / (-1.0 + (tan(y) * tan(z)))));
} else {
tmp = fma(sin((y + z)), (1.0 / cos((y + z))), t_0);
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x - tan(a)) t_1 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.02) tmp = fma(t_1, 1.0, t_0); elseif (tan(a) <= 1e-12) tmp = Float64(x - Float64(a + Float64(t_1 / Float64(-1.0 + Float64(tan(y) * tan(z)))))); else tmp = fma(sin(Float64(y + z)), Float64(1.0 / cos(Float64(y + z))), t_0); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], N[(t$95$1 * 1.0 + t$95$0), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-12], N[(x - N[(a + N[(t$95$1 / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
t_1 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, t\_0\right)\\
\mathbf{elif}\;\tan a \leq 10^{-12}:\\
\;\;\;\;x - \left(a + \frac{t\_1}{-1 + \tan y \cdot \tan z}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \left(y + z\right), \frac{1}{\cos \left(y + z\right)}, t\_0\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004Initial program 79.0%
+-commutative79.0%
associate-+l-78.7%
tan-sum99.5%
div-inv99.5%
fmm-def99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 79.5%
if -0.0200000000000000004 < (tan.f64 a) < 9.9999999999999998e-13Initial program 74.0%
Taylor expanded in a around 0 74.0%
tan-sum99.7%
div-inv99.8%
fmm-def99.7%
Applied egg-rr99.7%
fmm-undef99.8%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if 9.9999999999999998e-13 < (tan.f64 a) Initial program 70.8%
+-commutative70.8%
associate-+l-70.8%
tan-quot70.8%
div-inv70.8%
fmm-def70.9%
Applied egg-rr70.9%
Final simplification87.3%
(FPCore (x y z a) :precision binary64 (- x (+ (tan a) (/ (+ (tan y) (tan z)) (+ -1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) + ((tan(y) + tan(z)) / (-1.0 + (tan(y) * tan(z)))));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x - (tan(a) + ((tan(y) + tan(z)) / ((-1.0d0) + (tan(y) * tan(z)))))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) + ((Math.tan(y) + Math.tan(z)) / (-1.0 + (Math.tan(y) * Math.tan(z)))));
}
def code(x, y, z, a): return x - (math.tan(a) + ((math.tan(y) + math.tan(z)) / (-1.0 + (math.tan(y) * math.tan(z)))))
function code(x, y, z, a) return Float64(x - Float64(tan(a) + Float64(Float64(tan(y) + tan(z)) / Float64(-1.0 + Float64(tan(y) * tan(z)))))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) + ((tan(y) + tan(z)) / (-1.0 + (tan(y) * tan(z))))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a + \frac{\tan y + \tan z}{-1 + \tan y \cdot \tan z}\right)
\end{array}
Initial program 74.5%
+-commutative74.5%
sub-neg74.5%
associate-+l+74.4%
tan-sum99.7%
div-inv99.7%
fma-define99.7%
neg-mul-199.7%
fma-define99.7%
Applied egg-rr99.7%
fma-undefine99.7%
fma-undefine99.7%
neg-mul-199.7%
associate-+r+99.8%
sub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -5e-5) (not (<= (tan a) 5e-54))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -5e-5) || !(tan(a) <= 5e-54)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((tan(a) <= (-5d-5)) .or. (.not. (tan(a) <= 5d-54))) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -5e-5) || !(Math.tan(a) <= 5e-54)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -5e-5) or not (math.tan(a) <= 5e-54): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -5e-5) || !(tan(a) <= 5e-54)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -5e-5) || ~((tan(a) <= 5e-54))) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -5e-5], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 5e-54]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-5} \lor \neg \left(\tan a \leq 5 \cdot 10^{-54}\right):\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000024e-5 or 5.00000000000000015e-54 < (tan.f64 a) Initial program 74.1%
Taylor expanded in y around inf 57.2%
if -5.00000000000000024e-5 < (tan.f64 a) < 5.00000000000000015e-54Initial program 75.0%
Taylor expanded in a around 0 75.0%
Final simplification65.5%
(FPCore (x y z a) :precision binary64 (fma (+ (tan y) (tan z)) 1.0 (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((tan(y) + tan(z)), 1.0, (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(tan(y) + tan(z)), 1.0, Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * 1.0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\tan y + \tan z, 1, x - \tan a\right)
\end{array}
Initial program 74.5%
+-commutative74.5%
associate-+l-74.4%
tan-sum99.7%
div-inv99.7%
fmm-def99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 75.1%
Final simplification75.1%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-13) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-13) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(z) - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-5d-13)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-13) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-13: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-13) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-13) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-13], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-13}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -4.9999999999999999e-13Initial program 70.2%
Taylor expanded in y around inf 46.7%
if -4.9999999999999999e-13 < (+.f64 y z) Initial program 77.4%
Taylor expanded in y around 0 63.8%
(FPCore (x y z a) :precision binary64 (if (<= a -1.9) (pow (cbrt x) 3.0) (if (<= a 195000000.0) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.9) {
tmp = pow(cbrt(x), 3.0);
} else if (a <= 195000000.0) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.9) {
tmp = Math.pow(Math.cbrt(x), 3.0);
} else if (a <= 195000000.0) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -1.9) tmp = cbrt(x) ^ 3.0; elseif (a <= 195000000.0) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = x; end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.9], N[Power[N[Power[x, 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[a, 195000000.0], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9:\\
\;\;\;\;{\left(\sqrt[3]{x}\right)}^{3}\\
\mathbf{elif}\;a \leq 195000000:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.8999999999999999Initial program 76.5%
add-cube-cbrt75.4%
pow375.4%
+-commutative75.4%
associate-+l-75.3%
Applied egg-rr75.3%
Taylor expanded in x around inf 23.5%
if -1.8999999999999999 < a < 1.95e8Initial program 74.6%
Taylor expanded in a around 0 73.3%
if 1.95e8 < a Initial program 71.4%
Taylor expanded in x around inf 23.1%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 74.5%
(FPCore (x y z a)
:precision binary64
(if (<= a -9.5e-27)
x
(if (<= a -1.55e-214)
(+ x (- (tan z) a))
(if (<= a 195000000.0) (+ x (- (tan y) a)) x))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -9.5e-27) {
tmp = x;
} else if (a <= -1.55e-214) {
tmp = x + (tan(z) - a);
} else if (a <= 195000000.0) {
tmp = x + (tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-9.5d-27)) then
tmp = x
else if (a <= (-1.55d-214)) then
tmp = x + (tan(z) - a)
else if (a <= 195000000.0d0) then
tmp = x + (tan(y) - a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -9.5e-27) {
tmp = x;
} else if (a <= -1.55e-214) {
tmp = x + (Math.tan(z) - a);
} else if (a <= 195000000.0) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -9.5e-27: tmp = x elif a <= -1.55e-214: tmp = x + (math.tan(z) - a) elif a <= 195000000.0: tmp = x + (math.tan(y) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -9.5e-27) tmp = x; elseif (a <= -1.55e-214) tmp = Float64(x + Float64(tan(z) - a)); elseif (a <= 195000000.0) tmp = Float64(x + Float64(tan(y) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -9.5e-27) tmp = x; elseif (a <= -1.55e-214) tmp = x + (tan(z) - a); elseif (a <= 195000000.0) tmp = x + (tan(y) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -9.5e-27], x, If[LessEqual[a, -1.55e-214], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 195000000.0], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.5 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1.55 \cdot 10^{-214}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{elif}\;a \leq 195000000:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -9.50000000000000037e-27 or 1.95e8 < a Initial program 73.7%
Taylor expanded in x around inf 23.5%
if -9.50000000000000037e-27 < a < -1.55000000000000002e-214Initial program 81.4%
Taylor expanded in a around 0 81.4%
Taylor expanded in y around 0 59.2%
if -1.55000000000000002e-214 < a < 1.95e8Initial program 73.5%
Taylor expanded in a around 0 71.6%
Taylor expanded in y around inf 58.9%
(FPCore (x y z a) :precision binary64 (if (<= a -1.6) x (if (<= a 195000000.0) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.6) {
tmp = x;
} else if (a <= 195000000.0) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-1.6d0)) then
tmp = x
else if (a <= 195000000.0d0) then
tmp = x + (tan((y + z)) - a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.6) {
tmp = x;
} else if (a <= 195000000.0) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.6: tmp = x elif a <= 195000000.0: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.6) tmp = x; elseif (a <= 195000000.0) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.6) tmp = x; elseif (a <= 195000000.0) tmp = x + (tan((y + z)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.6], x, If[LessEqual[a, 195000000.0], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 195000000:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.6000000000000001 or 1.95e8 < a Initial program 74.4%
Taylor expanded in x around inf 23.3%
if -1.6000000000000001 < a < 1.95e8Initial program 74.6%
Taylor expanded in a around 0 73.3%
(FPCore (x y z a) :precision binary64 (if (<= a -1.65) x (if (<= a 195000000.0) (+ x (- (tan y) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.65) {
tmp = x;
} else if (a <= 195000000.0) {
tmp = x + (tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-1.65d0)) then
tmp = x
else if (a <= 195000000.0d0) then
tmp = x + (tan(y) - a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.65) {
tmp = x;
} else if (a <= 195000000.0) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.65: tmp = x elif a <= 195000000.0: tmp = x + (math.tan(y) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.65) tmp = x; elseif (a <= 195000000.0) tmp = Float64(x + Float64(tan(y) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.65) tmp = x; elseif (a <= 195000000.0) tmp = x + (tan(y) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.65], x, If[LessEqual[a, 195000000.0], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 195000000:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.6499999999999999 or 1.95e8 < a Initial program 74.4%
Taylor expanded in x around inf 23.3%
if -1.6499999999999999 < a < 1.95e8Initial program 74.6%
Taylor expanded in a around 0 73.3%
Taylor expanded in y around inf 59.3%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 74.5%
Taylor expanded in x around inf 33.1%
(FPCore (x y z a) :precision binary64 a)
double code(double x, double y, double z, double a) {
return a;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = a
end function
public static double code(double x, double y, double z, double a) {
return a;
}
def code(x, y, z, a): return a
function code(x, y, z, a) return a end
function tmp = code(x, y, z, a) tmp = a; end
code[x_, y_, z_, a_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 74.5%
Taylor expanded in a around 0 38.6%
Taylor expanded in a around inf 3.4%
neg-mul-13.4%
Simplified3.4%
add-sqr-sqrt2.4%
sqrt-unprod4.5%
sqr-neg4.5%
sqrt-unprod2.4%
add-sqr-sqrt3.3%
*-un-lft-identity3.3%
Applied egg-rr3.3%
*-lft-identity3.3%
Simplified3.3%
herbie shell --seed 2024165
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
(+ x (- (tan (+ y z)) (tan a))))