
(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
(let* ((t_0 (- 1.0 (* (tan y) (tan z)))))
(+
x
(/
(log (exp (- (* (+ (tan y) (tan z)) (cos a)) (* t_0 (sin a)))))
(* (cos a) t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (tan(y) * tan(z));
return x + (log(exp((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))))) / (cos(a) * t_0));
}
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
t_0 = 1.0d0 - (tan(y) * tan(z))
code = x + (log(exp((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))))) / (cos(a) * t_0))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (Math.tan(y) * Math.tan(z));
return x + (Math.log(Math.exp((((Math.tan(y) + Math.tan(z)) * Math.cos(a)) - (t_0 * Math.sin(a))))) / (Math.cos(a) * t_0));
}
def code(x, y, z, a): t_0 = 1.0 - (math.tan(y) * math.tan(z)) return x + (math.log(math.exp((((math.tan(y) + math.tan(z)) * math.cos(a)) - (t_0 * math.sin(a))))) / (math.cos(a) * t_0))
function code(x, y, z, a) t_0 = Float64(1.0 - Float64(tan(y) * tan(z))) return Float64(x + Float64(log(exp(Float64(Float64(Float64(tan(y) + tan(z)) * cos(a)) - Float64(t_0 * sin(a))))) / Float64(cos(a) * t_0))) end
function tmp = code(x, y, z, a) t_0 = 1.0 - (tan(y) * tan(z)); tmp = x + (log(exp((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))))) / (cos(a) * t_0)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[Log[N[Exp[N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan y \cdot \tan z\\
x + \frac{\log \left(e^{\left(\tan y + \tan z\right) \cdot \cos a - t_0 \cdot \sin a}\right)}{\cos a \cdot t_0}
\end{array}
\end{array}
Initial program 77.1%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan y) (tan z)))))
(+
x
(/ (- (* (+ (tan y) (tan z)) (cos a)) (* t_0 (sin a))) (* (cos a) t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (tan(y) * tan(z));
return x + ((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))) / (cos(a) * t_0));
}
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
t_0 = 1.0d0 - (tan(y) * tan(z))
code = x + ((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))) / (cos(a) * t_0))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (Math.tan(y) * Math.tan(z));
return x + ((((Math.tan(y) + Math.tan(z)) * Math.cos(a)) - (t_0 * Math.sin(a))) / (Math.cos(a) * t_0));
}
def code(x, y, z, a): t_0 = 1.0 - (math.tan(y) * math.tan(z)) return x + ((((math.tan(y) + math.tan(z)) * math.cos(a)) - (t_0 * math.sin(a))) / (math.cos(a) * t_0))
function code(x, y, z, a) t_0 = Float64(1.0 - Float64(tan(y) * tan(z))) return Float64(x + Float64(Float64(Float64(Float64(tan(y) + tan(z)) * cos(a)) - Float64(t_0 * sin(a))) / Float64(cos(a) * t_0))) end
function tmp = code(x, y, z, a) t_0 = 1.0 - (tan(y) * tan(z)); tmp = x + ((((tan(y) + tan(z)) * cos(a)) - (t_0 * sin(a))) / (cos(a) * t_0)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan y \cdot \tan z\\
x + \frac{\left(\tan y + \tan z\right) \cdot \cos a - t_0 \cdot \sin a}{\cos a \cdot t_0}
\end{array}
\end{array}
Initial program 77.1%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.002)
(+ x (- t_0 (/ (sin a) (cos a))))
(if (<= (tan a) 4e-10)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.002) {
tmp = x + (t_0 - (sin(a) / cos(a)));
} else if (tan(a) <= 4e-10) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (t_0 - 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 (tan(a) <= (-0.002d0)) then
tmp = x + (t_0 - (sin(a) / cos(a)))
else if (tan(a) <= 4d-10) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (t_0 - 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 (Math.tan(a) <= -0.002) {
tmp = x + (t_0 - (Math.sin(a) / Math.cos(a)));
} else if (Math.tan(a) <= 4e-10) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.002: tmp = x + (t_0 - (math.sin(a) / math.cos(a))) elif math.tan(a) <= 4e-10: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.002) tmp = Float64(x + Float64(t_0 - Float64(sin(a) / cos(a)))); elseif (tan(a) <= 4e-10) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(t_0 - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.002) tmp = x + (t_0 - (sin(a) / cos(a))); elseif (tan(a) <= 4e-10) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(t$95$0 - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 4e-10], 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] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(t_0 - \frac{\sin a}{\cos a}\right)\\
\mathbf{elif}\;\tan a \leq 4 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 73.8%
Taylor expanded in a around inf 73.9%
if -2e-3 < (tan.f64 a) < 4.00000000000000015e-10Initial program 77.5%
Taylor expanded in a around 0 77.5%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 4.00000000000000015e-10 < (tan.f64 a) Initial program 79.4%
Final simplification87.1%
(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 77.1%
tan-sum47.1%
div-inv47.1%
Applied egg-rr99.6%
associate-*r/47.1%
*-rgt-identity47.1%
Simplified99.7%
Final simplification99.7%
(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 77.1%
Taylor expanded in a around inf 77.1%
Final simplification77.1%
(FPCore (x y z a) :precision binary64 (if (or (<= a -3.5e-48) (not (<= a 2.3e-10))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -3.5e-48) || !(a <= 2.3e-10)) {
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 ((a <= (-3.5d-48)) .or. (.not. (a <= 2.3d-10))) 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 ((a <= -3.5e-48) || !(a <= 2.3e-10)) {
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 (a <= -3.5e-48) or not (a <= 2.3e-10): 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 ((a <= -3.5e-48) || !(a <= 2.3e-10)) 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 ((a <= -3.5e-48) || ~((a <= 2.3e-10))) 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[a, -3.5e-48], N[Not[LessEqual[a, 2.3e-10]], $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}\;a \leq -3.5 \cdot 10^{-48} \lor \neg \left(a \leq 2.3 \cdot 10^{-10}\right):\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -3.49999999999999991e-48 or 2.30000000000000007e-10 < a Initial program 76.2%
add-sqr-sqrt35.2%
sqrt-unprod46.3%
pow246.3%
Applied egg-rr46.3%
Taylor expanded in z around 0 41.3%
sqrt-pow160.6%
tan-quot60.6%
metadata-eval60.6%
pow160.6%
sub-neg60.6%
Applied egg-rr60.6%
sub-neg60.6%
Simplified60.6%
if -3.49999999999999991e-48 < a < 2.30000000000000007e-10Initial program 78.2%
Taylor expanded in a around 0 78.2%
Final simplification68.2%
(FPCore (x y z a) :precision binary64 (if (<= a -11.0) (expm1 (log1p x)) (if (<= a 1.56) (- (+ x (tan (+ y z))) a) (cbrt (pow x 3.0)))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -11.0) {
tmp = expm1(log1p(x));
} else if (a <= 1.56) {
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 <= -11.0) {
tmp = Math.expm1(Math.log1p(x));
} else if (a <= 1.56) {
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 <= -11.0) tmp = expm1(log1p(x)); elseif (a <= 1.56) 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, -11.0], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision], If[LessEqual[a, 1.56], 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 -11:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x}^{3}}\\
\end{array}
\end{array}
if a < -11Initial program 77.7%
Taylor expanded in a around 0 4.8%
expm1-log1p-u4.8%
Applied egg-rr4.8%
Taylor expanded in x around inf 23.0%
if -11 < a < 1.5600000000000001Initial program 78.2%
Taylor expanded in a around 0 76.4%
associate-+r-76.4%
Applied egg-rr76.4%
if 1.5600000000000001 < a Initial program 74.5%
add-cbrt-cube74.0%
pow374.0%
+-commutative74.0%
associate-+l-74.1%
Applied egg-rr74.1%
Taylor expanded in x around inf 23.2%
Final simplification47.9%
(FPCore (x y z a) :precision binary64 (if (<= z 120.0) (+ x (- (tan y) (tan a))) (+ x (+ (tan a) (tan (+ y z))))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 120.0) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(a) + tan((y + z)));
}
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 (z <= 120.0d0) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(a) + tan((y + z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= 120.0) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(a) + Math.tan((y + z)));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= 120.0: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(a) + math.tan((y + z))) return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= 120.0) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(a) + tan(Float64(y + z)))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= 120.0) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan(a) + tan((y + z))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, 120.0], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[a], $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 120:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan a + \tan \left(y + z\right)\right)\\
\end{array}
\end{array}
if z < 120Initial program 84.1%
add-sqr-sqrt42.9%
sqrt-unprod58.5%
pow258.5%
Applied egg-rr58.5%
Taylor expanded in z around 0 53.7%
sqrt-pow174.3%
tan-quot74.3%
metadata-eval74.3%
pow174.3%
sub-neg74.3%
Applied egg-rr74.3%
sub-neg74.3%
Simplified74.3%
if 120 < z Initial program 58.3%
sub-neg58.3%
Applied egg-rr58.3%
rem-square-sqrt28.1%
fabs-sqr28.1%
rem-square-sqrt47.5%
fabs-neg47.5%
rem-square-sqrt19.4%
fabs-sqr19.4%
rem-square-sqrt40.7%
+-commutative40.7%
Simplified40.7%
Final simplification65.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 77.1%
Final simplification77.1%
(FPCore (x y z a) :precision binary64 (if (<= a -11.0) (expm1 (log1p 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 <= -11.0) {
tmp = expm1(log1p(x));
} else if (a <= 1.56) {
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 <= -11.0) {
tmp = Math.expm1(Math.log1p(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 <= -11.0: tmp = math.expm1(math.log1p(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 <= -11.0) tmp = expm1(log1p(x)); elseif (a <= 1.56) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = x; end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -11.0], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $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 -11:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -11Initial program 77.7%
Taylor expanded in a around 0 4.8%
expm1-log1p-u4.8%
Applied egg-rr4.8%
Taylor expanded in x around inf 23.0%
if -11 < a < 1.5600000000000001Initial program 78.2%
Taylor expanded in a around 0 76.4%
associate-+r-76.4%
Applied egg-rr76.4%
if 1.5600000000000001 < a Initial program 74.5%
Taylor expanded in x around inf 23.2%
Final simplification47.9%
(FPCore (x y z a) :precision binary64 (if (<= a -11.0) 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 <= -11.0) {
tmp = 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 <= (-11.0d0)) then
tmp = 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 <= -11.0) {
tmp = 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 <= -11.0: tmp = 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 <= -11.0) tmp = x; elseif (a <= 1.56) 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 <= -11.0) tmp = 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, -11.0], x, If[LessEqual[a, 1.56], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -11:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -11 or 1.5600000000000001 < a Initial program 76.1%
Taylor expanded in x around inf 23.1%
if -11 < a < 1.5600000000000001Initial program 78.2%
Taylor expanded in a around 0 76.4%
Final simplification47.9%
(FPCore (x y z a) :precision binary64 (if (<= a -11.0) 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 <= -11.0) {
tmp = 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 <= (-11.0d0)) then
tmp = 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 <= -11.0) {
tmp = 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 <= -11.0: tmp = 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 <= -11.0) tmp = 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 <= -11.0) tmp = 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, -11.0], x, 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 -11:\\
\;\;\;\;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 < -11 or 1.5600000000000001 < a Initial program 76.1%
Taylor expanded in x around inf 23.1%
if -11 < a < 1.5600000000000001Initial program 78.2%
Taylor expanded in a around 0 76.4%
associate-+r-76.4%
Applied egg-rr76.4%
Final simplification47.9%
(FPCore (x y z a) :precision binary64 (if (<= a -11.0) x (if (<= a 1.56) (+ x (- (tan z) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -11.0) {
tmp = x;
} else if (a <= 1.56) {
tmp = x + (tan(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 <= (-11.0d0)) then
tmp = x
else if (a <= 1.56d0) then
tmp = x + (tan(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 <= -11.0) {
tmp = x;
} else if (a <= 1.56) {
tmp = x + (Math.tan(z) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -11.0: tmp = x elif a <= 1.56: tmp = x + (math.tan(z) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -11.0) tmp = x; elseif (a <= 1.56) tmp = Float64(x + Float64(tan(z) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -11.0) tmp = x; elseif (a <= 1.56) tmp = x + (tan(z) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -11.0], x, If[LessEqual[a, 1.56], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -11:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.56:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -11 or 1.5600000000000001 < a Initial program 76.1%
Taylor expanded in x around inf 23.1%
if -11 < a < 1.5600000000000001Initial program 78.2%
Taylor expanded in a around 0 76.4%
Taylor expanded in y around 0 54.6%
tan-quot54.6%
associate--l+54.6%
Applied egg-rr54.6%
Final simplification37.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 77.1%
Taylor expanded in x around inf 30.0%
Final simplification30.0%
herbie shell --seed 2024024
(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))))