
(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 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (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 - (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 - (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 - (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(tan(y) * tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (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[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 83.2%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -5e-5)
(+ (tan (+ y z)) (- x (tan a)))
(if (<= (tan a) 5e-15)
(- x (+ a (/ t_0 (+ -1.0 (* (tan y) (tan z))))))
(+ x (fma t_0 1.0 (- (tan a))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -5e-5) {
tmp = tan((y + z)) + (x - tan(a));
} else if (tan(a) <= 5e-15) {
tmp = x - (a + (t_0 / (-1.0 + (tan(y) * tan(z)))));
} else {
tmp = x + fma(t_0, 1.0, -tan(a));
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -5e-5) tmp = Float64(tan(Float64(y + z)) + Float64(x - tan(a))); elseif (tan(a) <= 5e-15) tmp = Float64(x - Float64(a + Float64(t_0 / Float64(-1.0 + Float64(tan(y) * tan(z)))))); else tmp = Float64(x + fma(t_0, 1.0, Float64(-tan(a)))); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -5e-5], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 5e-15], N[(x - N[(a + N[(t$95$0 / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 * 1.0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-5}:\\
\;\;\;\;\tan \left(y + z\right) + \left(x - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-15}:\\
\;\;\;\;x - \left(a + \frac{t\_0}{-1 + \tan y \cdot \tan z}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(t\_0, 1, -\tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000024e-5Initial program 80.9%
+-commutative80.9%
associate-+l-81.0%
Applied egg-rr81.0%
if -5.00000000000000024e-5 < (tan.f64 a) < 4.99999999999999999e-15Initial program 85.2%
Taylor expanded in a around 0 85.2%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 4.99999999999999999e-15 < (tan.f64 a) Initial program 81.9%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 82.5%
Final simplification90.2%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.1) (not (<= (tan a) 0.0004))) (+ x (- (sin y) (tan a))) (- (+ x (tan (+ y z))) a)))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.1) || !(tan(a) <= 0.0004)) {
tmp = x + (sin(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) <= (-0.1d0)) .or. (.not. (tan(a) <= 0.0004d0))) then
tmp = x + (sin(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) <= -0.1) || !(Math.tan(a) <= 0.0004)) {
tmp = x + (Math.sin(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) <= -0.1) or not (math.tan(a) <= 0.0004): tmp = x + (math.sin(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) <= -0.1) || !(tan(a) <= 0.0004)) tmp = Float64(x + Float64(sin(y) - tan(a))); else tmp = Float64(Float64(x + tan(Float64(y + z))) - a); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.1) || ~((tan(a) <= 0.0004))) tmp = x + (sin(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], -0.1], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.0004]], $MachinePrecision]], N[(x + N[(N[Sin[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.1 \lor \neg \left(\tan a \leq 0.0004\right):\\
\;\;\;\;x + \left(\sin y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\end{array}
\end{array}
if (tan.f64 a) < -0.10000000000000001 or 4.00000000000000019e-4 < (tan.f64 a) Initial program 81.0%
tan-quot81.0%
clear-num81.0%
Applied egg-rr81.0%
Taylor expanded in y around 0 59.4%
Taylor expanded in z around 0 44.0%
if -0.10000000000000001 < (tan.f64 a) < 4.00000000000000019e-4Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
Final simplification63.9%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.1)
(+ x (- (sin z) (tan a)))
(if (<= (tan a) 0.0004)
(- (+ x (tan (+ y z))) a)
(+ x (- (sin y) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.1) {
tmp = x + (sin(z) - tan(a));
} else if (tan(a) <= 0.0004) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = x + (sin(y) - 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 (tan(a) <= (-0.1d0)) then
tmp = x + (sin(z) - tan(a))
else if (tan(a) <= 0.0004d0) then
tmp = (x + tan((y + z))) - a
else
tmp = x + (sin(y) - tan(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.1) {
tmp = x + (Math.sin(z) - Math.tan(a));
} else if (Math.tan(a) <= 0.0004) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = x + (Math.sin(y) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.1: tmp = x + (math.sin(z) - math.tan(a)) elif math.tan(a) <= 0.0004: tmp = (x + math.tan((y + z))) - a else: tmp = x + (math.sin(y) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.1) tmp = Float64(x + Float64(sin(z) - tan(a))); elseif (tan(a) <= 0.0004) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = Float64(x + Float64(sin(y) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -0.1) tmp = x + (sin(z) - tan(a)); elseif (tan(a) <= 0.0004) tmp = (x + tan((y + z))) - a; else tmp = x + (sin(y) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.1], N[(x + N[(N[Sin[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 0.0004], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], N[(x + N[(N[Sin[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.1:\\
\;\;\;\;x + \left(\sin z - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 0.0004:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\sin y - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.10000000000000001Initial program 80.3%
tan-quot80.4%
clear-num80.4%
Applied egg-rr80.4%
Taylor expanded in z around 0 63.1%
Taylor expanded in y around 0 42.9%
if -0.10000000000000001 < (tan.f64 a) < 4.00000000000000019e-4Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
if 4.00000000000000019e-4 < (tan.f64 a) Initial program 81.6%
tan-quot81.6%
clear-num81.6%
Applied egg-rr81.6%
Taylor expanded in y around 0 58.0%
Taylor expanded in z around 0 46.0%
(FPCore (x y z a) :precision binary64 (+ x (- (/ 1.0 (/ (cos (+ y z)) (sin (+ y z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((1.0 / (cos((y + z)) / sin((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 + ((1.0d0 / (cos((y + z)) / sin((y + z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((1.0 / (Math.cos((y + z)) / Math.sin((y + z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + ((1.0 / (math.cos((y + z)) / math.sin((y + z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(y + z)) / sin(Float64(y + z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((1.0 / (cos((y + z)) / sin((y + z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(1.0 / N[(N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{1}{\frac{\cos \left(y + z\right)}{\sin \left(y + z\right)}} - \tan a\right)
\end{array}
Initial program 83.2%
tan-quot83.2%
clear-num83.2%
Applied egg-rr83.2%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - (sin(a) / cos(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)) - (sin(a) / cos(a)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - (Math.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - (math.sin(a) / math.cos(a)))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - (sin(a) / cos(a))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 83.2%
Taylor expanded in a around inf 83.2%
(FPCore (x y z a) :precision binary64 (if (<= a -1.65) (exp (log x)) (if (<= a 1.56) (- (+ x (tan (+ y z))) a) (cbrt (pow (/ 1.0 x) -3.0)))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.65) {
tmp = exp(log(x));
} else if (a <= 1.56) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = cbrt(pow((1.0 / x), -3.0));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.65) {
tmp = Math.exp(Math.log(x));
} else if (a <= 1.56) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = Math.cbrt(Math.pow((1.0 / x), -3.0));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -1.65) tmp = exp(log(x)); elseif (a <= 1.56) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = cbrt((Float64(1.0 / x) ^ -3.0)); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.65], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[a, 1.56], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], N[Power[N[Power[N[(1.0 / x), $MachinePrecision], -3.0], $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{1}{x}\right)}^{-3}}\\
\end{array}
\end{array}
if a < -1.6499999999999999Initial program 77.8%
add-cbrt-cube77.4%
pow377.3%
+-commutative77.3%
associate-+l-77.4%
Applied egg-rr77.4%
add-exp-log70.0%
log-pow69.8%
associate--r-69.8%
tan-sum87.3%
+-commutative87.3%
tan-sum69.8%
sub-neg69.8%
add-sqr-sqrt39.3%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod9.7%
add-sqr-sqrt19.0%
Applied egg-rr19.0%
Taylor expanded in x around inf 22.0%
*-un-lft-identity22.0%
*-commutative22.0%
exp-to-pow22.0%
Applied egg-rr22.0%
*-lft-identity22.0%
unpow1/322.0%
rem-exp-log22.0%
log-rec22.0%
exp-prod22.0%
*-commutative22.0%
exp-prod22.0%
*-commutative22.0%
associate-*r*22.0%
metadata-eval22.0%
neg-mul-122.0%
associate-*r*22.0%
metadata-eval22.0%
*-lft-identity22.0%
Simplified22.0%
if -1.6499999999999999 < a < 1.5600000000000001Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
if 1.5600000000000001 < a Initial program 84.6%
add-cbrt-cube84.3%
pow384.4%
+-commutative84.4%
associate-+l-84.4%
Applied egg-rr84.4%
add-exp-log72.9%
log-pow72.8%
associate--r-72.7%
tan-sum87.4%
+-commutative87.4%
tan-sum72.7%
sub-neg72.7%
add-sqr-sqrt39.2%
sqrt-unprod49.2%
sqr-neg49.2%
sqrt-unprod10.0%
add-sqr-sqrt20.5%
Applied egg-rr20.5%
Taylor expanded in x around inf 21.4%
*-commutative21.4%
exp-to-pow21.4%
Applied egg-rr21.4%
(FPCore (x y z a) :precision binary64 (if (<= a -1.9) (exp (log x)) (if (<= a 1.56) (- (+ x (tan (+ y z))) a) (pow (sqrt x) 2.0))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.9) {
tmp = exp(log(x));
} else if (a <= 1.56) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = pow(sqrt(x), 2.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) :: tmp
if (a <= (-1.9d0)) then
tmp = exp(log(x))
else if (a <= 1.56d0) then
tmp = (x + tan((y + z))) - a
else
tmp = sqrt(x) ** 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.9) {
tmp = Math.exp(Math.log(x));
} else if (a <= 1.56) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = Math.pow(Math.sqrt(x), 2.0);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.9: tmp = math.exp(math.log(x)) elif a <= 1.56: tmp = (x + math.tan((y + z))) - a else: tmp = math.pow(math.sqrt(x), 2.0) return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.9) tmp = exp(log(x)); elseif (a <= 1.56) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = sqrt(x) ^ 2.0; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.9) tmp = exp(log(x)); elseif (a <= 1.56) tmp = (x + tan((y + z))) - a; else tmp = sqrt(x) ^ 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.9], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[a, 1.56], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], N[Power[N[Sqrt[x], $MachinePrecision], 2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{x}\right)}^{2}\\
\end{array}
\end{array}
if a < -1.8999999999999999Initial program 77.8%
add-cbrt-cube77.4%
pow377.3%
+-commutative77.3%
associate-+l-77.4%
Applied egg-rr77.4%
add-exp-log70.0%
log-pow69.8%
associate--r-69.8%
tan-sum87.3%
+-commutative87.3%
tan-sum69.8%
sub-neg69.8%
add-sqr-sqrt39.3%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod9.7%
add-sqr-sqrt19.0%
Applied egg-rr19.0%
Taylor expanded in x around inf 22.0%
*-un-lft-identity22.0%
*-commutative22.0%
exp-to-pow22.0%
Applied egg-rr22.0%
*-lft-identity22.0%
unpow1/322.0%
rem-exp-log22.0%
log-rec22.0%
exp-prod22.0%
*-commutative22.0%
exp-prod22.0%
*-commutative22.0%
associate-*r*22.0%
metadata-eval22.0%
neg-mul-122.0%
associate-*r*22.0%
metadata-eval22.0%
*-lft-identity22.0%
Simplified22.0%
if -1.8999999999999999 < a < 1.5600000000000001Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
if 1.5600000000000001 < a Initial program 84.6%
add-sqr-sqrt72.9%
pow272.9%
+-commutative72.9%
associate-+l-73.0%
Applied egg-rr73.0%
Taylor expanded in x around inf 21.4%
(FPCore (x y z a) :precision binary64 (if (<= a -2.2) (exp (log x)) (if (<= a 1.46) (- (+ x (tan (+ y z))) a) (cbrt (pow x 3.0)))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2) {
tmp = exp(log(x));
} else if (a <= 1.46) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = cbrt(pow(x, 3.0));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2) {
tmp = Math.exp(Math.log(x));
} else if (a <= 1.46) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = Math.cbrt(Math.pow(x, 3.0));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -2.2) tmp = exp(log(x)); elseif (a <= 1.46) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = cbrt((x ^ 3.0)); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -2.2], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[a, 1.46], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], N[Power[N[Power[x, 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;a \leq 1.46:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x}^{3}}\\
\end{array}
\end{array}
if a < -2.2000000000000002Initial program 77.8%
add-cbrt-cube77.4%
pow377.3%
+-commutative77.3%
associate-+l-77.4%
Applied egg-rr77.4%
add-exp-log70.0%
log-pow69.8%
associate--r-69.8%
tan-sum87.3%
+-commutative87.3%
tan-sum69.8%
sub-neg69.8%
add-sqr-sqrt39.3%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod9.7%
add-sqr-sqrt19.0%
Applied egg-rr19.0%
Taylor expanded in x around inf 22.0%
*-un-lft-identity22.0%
*-commutative22.0%
exp-to-pow22.0%
Applied egg-rr22.0%
*-lft-identity22.0%
unpow1/322.0%
rem-exp-log22.0%
log-rec22.0%
exp-prod22.0%
*-commutative22.0%
exp-prod22.0%
*-commutative22.0%
associate-*r*22.0%
metadata-eval22.0%
neg-mul-122.0%
associate-*r*22.0%
metadata-eval22.0%
*-lft-identity22.0%
Simplified22.0%
if -2.2000000000000002 < a < 1.46Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
if 1.46 < a Initial program 84.6%
add-cbrt-cube84.3%
pow384.4%
+-commutative84.4%
associate-+l-84.4%
Applied egg-rr84.4%
Taylor expanded in x around inf 21.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 83.2%
(FPCore (x y z a) :precision binary64 (if (<= a -1.7) (exp (log x)) (if (<= a 1.56) (- (+ x (tan (+ y z))) a) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.7) {
tmp = exp(log(x));
} else if (a <= 1.56) {
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.7d0)) then
tmp = exp(log(x))
else if (a <= 1.56d0) 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.7) {
tmp = Math.exp(Math.log(x));
} else if (a <= 1.56) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.7: tmp = math.exp(math.log(x)) elif a <= 1.56: tmp = (x + math.tan((y + z))) - a else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.7) tmp = exp(log(x)); elseif (a <= 1.56) tmp = Float64(Float64(x + 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.7) tmp = exp(log(x)); elseif (a <= 1.56) tmp = (x + tan((y + z))) - a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.7], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[a, 1.56], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.69999999999999996Initial program 77.8%
add-cbrt-cube77.4%
pow377.3%
+-commutative77.3%
associate-+l-77.4%
Applied egg-rr77.4%
add-exp-log70.0%
log-pow69.8%
associate--r-69.8%
tan-sum87.3%
+-commutative87.3%
tan-sum69.8%
sub-neg69.8%
add-sqr-sqrt39.3%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod9.7%
add-sqr-sqrt19.0%
Applied egg-rr19.0%
Taylor expanded in x around inf 22.0%
*-un-lft-identity22.0%
*-commutative22.0%
exp-to-pow22.0%
Applied egg-rr22.0%
*-lft-identity22.0%
unpow1/322.0%
rem-exp-log22.0%
log-rec22.0%
exp-prod22.0%
*-commutative22.0%
exp-prod22.0%
*-commutative22.0%
associate-*r*22.0%
metadata-eval22.0%
neg-mul-122.0%
associate-*r*22.0%
metadata-eval22.0%
*-lft-identity22.0%
Simplified22.0%
if -1.69999999999999996 < a < 1.5600000000000001Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
if 1.5600000000000001 < a Initial program 84.6%
Taylor expanded in x around inf 21.4%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.95) (not (<= a 1.56))) x (- (+ x (tan (+ y z))) a)))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.95) || !(a <= 1.56)) {
tmp = x;
} 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 ((a <= (-1.95d0)) .or. (.not. (a <= 1.56d0))) then
tmp = x
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 ((a <= -1.95) || !(a <= 1.56)) {
tmp = x;
} else {
tmp = (x + Math.tan((y + z))) - a;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -1.95) or not (a <= 1.56): tmp = x else: tmp = (x + math.tan((y + z))) - a return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.95) || !(a <= 1.56)) tmp = x; else tmp = Float64(Float64(x + tan(Float64(y + z))) - a); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -1.95) || ~((a <= 1.56))) tmp = x; else tmp = (x + tan((y + z))) - a; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.95], N[Not[LessEqual[a, 1.56]], $MachinePrecision]], x, N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.95 \lor \neg \left(a \leq 1.56\right):\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\end{array}
\end{array}
if a < -1.94999999999999996 or 1.5600000000000001 < a Initial program 81.0%
Taylor expanded in x around inf 21.7%
if -1.94999999999999996 < a < 1.5600000000000001Initial program 85.5%
Taylor expanded in a around 0 85.3%
associate-+r-85.3%
Applied egg-rr85.3%
Final simplification52.3%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.9) (not (<= a 1.56))) x (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.9) || !(a <= 1.56)) {
tmp = x;
} 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 ((a <= (-1.9d0)) .or. (.not. (a <= 1.56d0))) then
tmp = x
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 ((a <= -1.9) || !(a <= 1.56)) {
tmp = x;
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -1.9) or not (a <= 1.56): tmp = x else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.9) || !(a <= 1.56)) tmp = x; 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 ((a <= -1.9) || ~((a <= 1.56))) tmp = x; else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.9], N[Not[LessEqual[a, 1.56]], $MachinePrecision]], x, N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9 \lor \neg \left(a \leq 1.56\right):\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -1.8999999999999999 or 1.5600000000000001 < a Initial program 81.0%
Taylor expanded in x around inf 21.7%
if -1.8999999999999999 < a < 1.5600000000000001Initial program 85.5%
Taylor expanded in a around 0 85.3%
Final simplification52.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 83.2%
Taylor expanded in x around inf 32.8%
herbie shell --seed 2024096
(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))))