
(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 12 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 (fma (+ (tan y) (tan z)) (log1p (expm1 (/ 1.0 (- 1.0 (* (tan y) (tan z)))))) (- (tan a)))))
double code(double x, double y, double z, double a) {
return x + fma((tan(y) + tan(z)), log1p(expm1((1.0 / (1.0 - (tan(y) * tan(z)))))), -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), log1p(expm1(Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))))), Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[Log[1 + N[(Exp[N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{1 - \tan y \cdot \tan z}\right)\right), -\tan a\right)
\end{array}
Initial program 74.4%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
log1p-expm1-u99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (or (<= (tan a) -2e-11) (not (<= (tan a) 0.04)))
(+ x (fma t_0 1.0 (- (tan a))))
(+ x (/ t_0 (- 1.0 (* (tan y) (tan z))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if ((tan(a) <= -2e-11) || !(tan(a) <= 0.04)) {
tmp = x + fma(t_0, 1.0, -tan(a));
} else {
tmp = x + (t_0 / (1.0 - (tan(y) * tan(z))));
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if ((tan(a) <= -2e-11) || !(tan(a) <= 0.04)) tmp = Float64(x + fma(t_0, 1.0, Float64(-tan(a)))); else tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z))))); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[Tan[a], $MachinePrecision], -2e-11], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.04]], $MachinePrecision]], N[(x + N[(t$95$0 * 1.0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -2 \cdot 10^{-11} \lor \neg \left(\tan a \leq 0.04\right):\\
\;\;\;\;x + \mathsf{fma}\left(t_0, 1, -\tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t_0}{1 - \tan y \cdot \tan z}\\
\end{array}
\end{array}
if (tan.f64 a) < -1.99999999999999988e-11 or 0.0400000000000000008 < (tan.f64 a) Initial program 77.7%
tan-sum99.6%
div-inv99.6%
fma-neg99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 78.1%
if -1.99999999999999988e-11 < (tan.f64 a) < 0.0400000000000000008Initial program 71.0%
+-commutative71.0%
associate-+l-71.0%
Applied egg-rr71.0%
Taylor expanded in a around 0 71.0%
neg-mul-171.0%
Simplified71.0%
sub-neg71.0%
remove-double-neg71.0%
Applied egg-rr71.0%
tan-sum98.2%
div-inv98.1%
Applied egg-rr98.1%
associate-*r/98.2%
*-rgt-identity98.2%
Simplified98.2%
Final simplification87.9%
(FPCore (x y z a) :precision binary64 (+ x (fma (+ (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 + fma((tan(y) + tan(z)), (1.0 / (1.0 - (tan(y) * tan(z)))), -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + 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] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\tan a\right)
\end{array}
Initial program 74.4%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.7%
(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.4%
tan-sum61.1%
div-inv61.1%
Applied egg-rr99.7%
associate-*r/61.1%
*-rgt-identity61.1%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.01) (not (<= (tan a) 5e-19))) (- x (/ (sin a) (cos a))) (+ (tan (+ y z)) (- x a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.01) || !(tan(a) <= 5e-19)) {
tmp = x - (sin(a) / cos(a));
} else {
tmp = tan((y + z)) + (x - 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) <= (-0.01d0)) .or. (.not. (tan(a) <= 5d-19))) then
tmp = x - (sin(a) / cos(a))
else
tmp = tan((y + z)) + (x - 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) <= -0.01) || !(Math.tan(a) <= 5e-19)) {
tmp = x - (Math.sin(a) / Math.cos(a));
} else {
tmp = Math.tan((y + z)) + (x - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.01) or not (math.tan(a) <= 5e-19): tmp = x - (math.sin(a) / math.cos(a)) else: tmp = math.tan((y + z)) + (x - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.01) || !(tan(a) <= 5e-19)) tmp = Float64(x - Float64(sin(a) / cos(a))); else tmp = Float64(tan(Float64(y + z)) + Float64(x - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.01) || ~((tan(a) <= 5e-19))) tmp = x - (sin(a) / cos(a)); else tmp = tan((y + z)) + (x - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.01], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 5e-19]], $MachinePrecision]], N[(x - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.01 \lor \neg \left(\tan a \leq 5 \cdot 10^{-19}\right):\\
\;\;\;\;x - \frac{\sin a}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\tan \left(y + z\right) + \left(x - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0100000000000000002 or 5.0000000000000004e-19 < (tan.f64 a) Initial program 75.1%
+-commutative75.1%
associate-+l-75.0%
Applied egg-rr75.0%
Taylor expanded in y around 0 55.9%
Taylor expanded in z around 0 36.2%
if -0.0100000000000000002 < (tan.f64 a) < 5.0000000000000004e-19Initial program 73.7%
+-commutative73.7%
associate-+l-73.7%
Applied egg-rr73.7%
Taylor expanded in a around 0 73.7%
neg-mul-173.7%
unsub-neg73.7%
Simplified73.7%
Final simplification54.2%
(FPCore (x y z a) :precision binary64 (+ x (fma (+ (tan y) (tan z)) 1.0 (- (tan a)))))
double code(double x, double y, double z, double a) {
return x + fma((tan(y) + tan(z)), 1.0, -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), 1.0, Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * 1.0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, 1, -\tan a\right)
\end{array}
Initial program 74.4%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 74.7%
Final simplification74.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (or (<= t_0 -5e-11) (not (<= t_0 0.002)))
(+ x t_0)
(+ z (- x (tan a))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if ((t_0 <= -5e-11) || !(t_0 <= 0.002)) {
tmp = x + t_0;
} else {
tmp = z + (x - 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) :: t_0
real(8) :: tmp
t_0 = tan((y + z))
if ((t_0 <= (-5d-11)) .or. (.not. (t_0 <= 0.002d0))) then
tmp = x + t_0
else
tmp = z + (x - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if ((t_0 <= -5e-11) || !(t_0 <= 0.002)) {
tmp = x + t_0;
} else {
tmp = z + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if (t_0 <= -5e-11) or not (t_0 <= 0.002): tmp = x + t_0 else: tmp = z + (x - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if ((t_0 <= -5e-11) || !(t_0 <= 0.002)) tmp = Float64(x + t_0); else tmp = Float64(z + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if ((t_0 <= -5e-11) || ~((t_0 <= 0.002))) tmp = x + t_0; else tmp = z + (x - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-11], N[Not[LessEqual[t$95$0, 0.002]], $MachinePrecision]], N[(x + t$95$0), $MachinePrecision], N[(z + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-11} \lor \neg \left(t_0 \leq 0.002\right):\\
\;\;\;\;x + t_0\\
\mathbf{else}:\\
\;\;\;\;z + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -5.00000000000000018e-11 or 2e-3 < (tan.f64 (+.f64 y z)) Initial program 68.9%
+-commutative68.9%
associate-+l-68.8%
Applied egg-rr68.8%
Taylor expanded in a around 0 44.1%
neg-mul-144.1%
Simplified44.1%
sub-neg44.1%
remove-double-neg44.1%
Applied egg-rr44.1%
if -5.00000000000000018e-11 < (tan.f64 (+.f64 y z)) < 2e-3Initial program 99.9%
+-commutative99.9%
associate-+l-99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 99.2%
Taylor expanded in z around 0 99.2%
Final simplification54.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (tan (+ y z)))))
(if (<= (+ y z) -5e-11)
t_0
(if (<= (+ y z) 0.002) (+ z (- x (tan a))) (fabs t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = x + tan((y + z));
double tmp;
if ((y + z) <= -5e-11) {
tmp = t_0;
} else if ((y + z) <= 0.002) {
tmp = z + (x - tan(a));
} else {
tmp = fabs(t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = x + tan((y + z))
if ((y + z) <= (-5d-11)) then
tmp = t_0
else if ((y + z) <= 0.002d0) then
tmp = z + (x - tan(a))
else
tmp = abs(t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x + Math.tan((y + z));
double tmp;
if ((y + z) <= -5e-11) {
tmp = t_0;
} else if ((y + z) <= 0.002) {
tmp = z + (x - Math.tan(a));
} else {
tmp = Math.abs(t_0);
}
return tmp;
}
def code(x, y, z, a): t_0 = x + math.tan((y + z)) tmp = 0 if (y + z) <= -5e-11: tmp = t_0 elif (y + z) <= 0.002: tmp = z + (x - math.tan(a)) else: tmp = math.fabs(t_0) return tmp
function code(x, y, z, a) t_0 = Float64(x + tan(Float64(y + z))) tmp = 0.0 if (Float64(y + z) <= -5e-11) tmp = t_0; elseif (Float64(y + z) <= 0.002) tmp = Float64(z + Float64(x - tan(a))); else tmp = abs(t_0); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x + tan((y + z)); tmp = 0.0; if ((y + z) <= -5e-11) tmp = t_0; elseif ((y + z) <= 0.002) tmp = z + (x - tan(a)); else tmp = abs(t_0); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y + z), $MachinePrecision], -5e-11], t$95$0, If[LessEqual[N[(y + z), $MachinePrecision], 0.002], N[(z + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \tan \left(y + z\right)\\
\mathbf{if}\;y + z \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y + z \leq 0.002:\\
\;\;\;\;z + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left|t_0\right|\\
\end{array}
\end{array}
if (+.f64 y z) < -5.00000000000000018e-11Initial program 65.6%
+-commutative65.6%
associate-+l-65.5%
Applied egg-rr65.5%
Taylor expanded in a around 0 42.8%
neg-mul-142.8%
Simplified42.8%
sub-neg42.8%
remove-double-neg42.8%
Applied egg-rr42.8%
if -5.00000000000000018e-11 < (+.f64 y z) < 2e-3Initial program 99.9%
+-commutative99.9%
associate-+l-99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 99.2%
Taylor expanded in z around 0 99.2%
if 2e-3 < (+.f64 y z) Initial program 73.0%
+-commutative73.0%
associate-+l-72.9%
Applied egg-rr72.9%
Taylor expanded in a around 0 45.7%
neg-mul-145.7%
Simplified45.7%
add-sqr-sqrt45.5%
sqrt-unprod45.9%
pow245.9%
sub-neg45.9%
remove-double-neg45.9%
Applied egg-rr45.9%
unpow245.9%
rem-sqrt-square45.9%
+-commutative45.9%
Simplified45.9%
Final simplification54.0%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -5e-11) (+ x (tan (+ y z))) (+ (tan z) (- x (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -5e-11) {
tmp = x + tan((y + z));
} else {
tmp = tan(z) + (x - 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-11)) then
tmp = x + tan((y + z))
else
tmp = tan(z) + (x - 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-11) {
tmp = x + Math.tan((y + z));
} else {
tmp = Math.tan(z) + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -5e-11: tmp = x + math.tan((y + z)) else: tmp = math.tan(z) + (x - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -5e-11) tmp = Float64(x + tan(Float64(y + z))); else tmp = Float64(tan(z) + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -5e-11) tmp = x + tan((y + z)); else tmp = tan(z) + (x - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -5e-11], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -5 \cdot 10^{-11}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;\tan z + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -5.00000000000000018e-11Initial program 65.6%
+-commutative65.6%
associate-+l-65.5%
Applied egg-rr65.5%
Taylor expanded in a around 0 42.8%
neg-mul-142.8%
Simplified42.8%
sub-neg42.8%
remove-double-neg42.8%
Applied egg-rr42.8%
if -5.00000000000000018e-11 < (+.f64 y z) Initial program 81.9%
+-commutative81.9%
associate-+l-81.8%
Applied egg-rr81.8%
Taylor expanded in y around 0 64.2%
tan-quot64.1%
expm1-log1p-u57.6%
expm1-udef57.6%
Applied egg-rr57.6%
expm1-def57.6%
expm1-log1p64.1%
Simplified64.1%
Final simplification54.4%
(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.4%
Final simplification74.4%
(FPCore (x y z a) :precision binary64 (+ x (tan (+ y z))))
double code(double x, double y, double z, double a) {
return x + tan((y + 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((y + z))
end function
public static double code(double x, double y, double z, double a) {
return x + Math.tan((y + z));
}
def code(x, y, z, a): return x + math.tan((y + z))
function code(x, y, z, a) return Float64(x + tan(Float64(y + z))) end
function tmp = code(x, y, z, a) tmp = x + tan((y + z)); end
code[x_, y_, z_, a_] := N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \tan \left(y + z\right)
\end{array}
Initial program 74.4%
+-commutative74.4%
associate-+l-74.4%
Applied egg-rr74.4%
Taylor expanded in a around 0 47.7%
neg-mul-147.7%
Simplified47.7%
sub-neg47.7%
remove-double-neg47.7%
Applied egg-rr47.7%
Final simplification47.7%
(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.4%
Taylor expanded in x around inf 30.8%
Final simplification30.8%
herbie shell --seed 2024014
(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))))