
(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 9 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 (/ (* (sin z) (sin y)) (* (cos z) (cos y))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - ((sin(z) * sin(y)) / (cos(z) * cos(y))))) - 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 - ((sin(z) * sin(y)) / (cos(z) * cos(y))))) - 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.sin(z) * Math.sin(y)) / (Math.cos(z) * Math.cos(y))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.sin(z) * math.sin(y)) / (math.cos(z) * math.cos(y))))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(Float64(sin(z) * sin(y)) / Float64(cos(z) * cos(y))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - ((sin(z) * sin(y)) / (cos(z) * cos(y))))) - 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[(N[Sin[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\sin z \cdot \sin y}{\cos z \cdot \cos y}} - \tan a\right)
\end{array}
Initial program 77.6%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
*-commutative99.7%
tan-quot99.8%
tan-quot99.8%
frac-times99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.0002)
(+ (/ (log (exp (sin (+ y z)))) (cos (+ y z))) (- x (tan a)))
(if (<= (tan a) 2e-17)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- (log (exp (tan (+ y z)))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.0002) {
tmp = (log(exp(sin((y + z)))) / cos((y + z))) + (x - tan(a));
} else if (tan(a) <= 2e-17) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (log(exp(tan((y + 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 (tan(a) <= (-0.0002d0)) then
tmp = (log(exp(sin((y + z)))) / cos((y + z))) + (x - tan(a))
else if (tan(a) <= 2d-17) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (log(exp(tan((y + z)))) - 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.0002) {
tmp = (Math.log(Math.exp(Math.sin((y + z)))) / Math.cos((y + z))) + (x - Math.tan(a));
} else if (Math.tan(a) <= 2e-17) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (Math.log(Math.exp(Math.tan((y + z)))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.0002: tmp = (math.log(math.exp(math.sin((y + z)))) / math.cos((y + z))) + (x - math.tan(a)) elif math.tan(a) <= 2e-17: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (math.log(math.exp(math.tan((y + z)))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.0002) tmp = Float64(Float64(log(exp(sin(Float64(y + z)))) / cos(Float64(y + z))) + Float64(x - tan(a))); elseif (tan(a) <= 2e-17) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(log(exp(tan(Float64(y + z)))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -0.0002) tmp = (log(exp(sin((y + z)))) / cos((y + z))) + (x - tan(a)); elseif (tan(a) <= 2e-17) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + (log(exp(tan((y + z)))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.0002], N[(N[(N[Log[N[Exp[N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-17], 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[(N[Log[N[Exp[N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.0002:\\
\;\;\;\;\frac{\log \left(e^{\sin \left(y + z\right)}\right)}{\cos \left(y + z\right)} + \left(x - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-17}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\log \left(e^{\tan \left(y + z\right)}\right) - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2.0000000000000001e-4Initial program 79.3%
+-commutative79.3%
sub-neg79.3%
associate-+l+79.2%
tan-quot79.2%
div-inv79.2%
fma-define79.2%
neg-mul-179.2%
fma-define79.2%
Applied egg-rr79.2%
fma-undefine79.2%
associate-*r/79.2%
*-rgt-identity79.2%
+-commutative79.2%
+-commutative79.2%
fma-undefine79.2%
neg-mul-179.2%
+-commutative79.2%
sub-neg79.2%
Simplified79.2%
add-log-exp79.3%
+-commutative79.3%
Applied egg-rr79.3%
if -2.0000000000000001e-4 < (tan.f64 a) < 2.00000000000000014e-17Initial program 76.5%
Taylor expanded in a around 0 76.5%
tan-sum99.9%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
if 2.00000000000000014e-17 < (tan.f64 a) Initial program 78.3%
add-log-exp78.3%
Applied egg-rr78.3%
Final simplification89.0%
(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.6%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= a -0.000165)
(+ x (- (log (exp t_0)) (tan a)))
(if (<= a 0.002)
(+ 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 (a <= -0.000165) {
tmp = x + (log(exp(t_0)) - tan(a));
} else if (a <= 0.002) {
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 (a <= (-0.000165d0)) then
tmp = x + (log(exp(t_0)) - tan(a))
else if (a <= 0.002d0) 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 (a <= -0.000165) {
tmp = x + (Math.log(Math.exp(t_0)) - Math.tan(a));
} else if (a <= 0.002) {
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 a <= -0.000165: tmp = x + (math.log(math.exp(t_0)) - math.tan(a)) elif a <= 0.002: 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 (a <= -0.000165) tmp = Float64(x + Float64(log(exp(t_0)) - tan(a))); elseif (a <= 0.002) 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 (a <= -0.000165) tmp = x + (log(exp(t_0)) - tan(a)); elseif (a <= 0.002) 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[a, -0.000165], N[(x + N[(N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.002], 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}\;a \leq -0.000165:\\
\;\;\;\;x + \left(\log \left(e^{t\_0}\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 0.002:\\
\;\;\;\;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 a < -1.65e-4Initial program 78.7%
add-log-exp78.8%
Applied egg-rr78.8%
if -1.65e-4 < a < 2e-3Initial program 76.5%
Taylor expanded in a around 0 76.5%
tan-sum99.9%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
if 2e-3 < a Initial program 78.6%
Final simplification89.0%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.000226) (not (<= a 1.95e-30))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.000226) || !(a <= 1.95e-30)) {
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 <= (-0.000226d0)) .or. (.not. (a <= 1.95d-30))) 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 <= -0.000226) || !(a <= 1.95e-30)) {
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 <= -0.000226) or not (a <= 1.95e-30): 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 <= -0.000226) || !(a <= 1.95e-30)) 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 <= -0.000226) || ~((a <= 1.95e-30))) 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, -0.000226], N[Not[LessEqual[a, 1.95e-30]], $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 -0.000226 \lor \neg \left(a \leq 1.95 \cdot 10^{-30}\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 < -2.25999999999999991e-4 or 1.9500000000000002e-30 < a Initial program 78.0%
add-cbrt-cube77.6%
pow1/369.2%
pow369.3%
+-commutative69.3%
associate-+l-69.3%
Applied egg-rr69.3%
Taylor expanded in z around 0 53.5%
pow-pow58.8%
metadata-eval58.8%
unpow158.8%
tan-quot58.9%
associate--r-58.9%
Applied egg-rr58.9%
if -2.25999999999999991e-4 < a < 1.9500000000000002e-30Initial program 77.2%
Taylor expanded in a around 0 77.2%
Final simplification67.5%
(FPCore (x y z a)
:precision binary64
(if (<= a -1.4)
x
(if (<= a 5.8e-21)
(+ x (- (tan (+ y z)) a))
(pow (pow x 3.0) 0.3333333333333333))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.4) {
tmp = x;
} else if (a <= 5.8e-21) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = pow(pow(x, 3.0), 0.3333333333333333);
}
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.4d0)) then
tmp = x
else if (a <= 5.8d-21) then
tmp = x + (tan((y + z)) - a)
else
tmp = (x ** 3.0d0) ** 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.4) {
tmp = x;
} else if (a <= 5.8e-21) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = Math.pow(Math.pow(x, 3.0), 0.3333333333333333);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.4: tmp = x elif a <= 5.8e-21: tmp = x + (math.tan((y + z)) - a) else: tmp = math.pow(math.pow(x, 3.0), 0.3333333333333333) return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.4) tmp = x; elseif (a <= 5.8e-21) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = (x ^ 3.0) ^ 0.3333333333333333; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.4) tmp = x; elseif (a <= 5.8e-21) tmp = x + (tan((y + z)) - a); else tmp = (x ^ 3.0) ^ 0.3333333333333333; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.4], x, If[LessEqual[a, 5.8e-21], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[x, 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{-21}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;{\left({x}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if a < -1.3999999999999999Initial program 78.5%
Taylor expanded in x around inf 21.5%
if -1.3999999999999999 < a < 5.8e-21Initial program 77.6%
Taylor expanded in a around 0 77.5%
if 5.8e-21 < a Initial program 76.6%
add-cbrt-cube76.1%
pow1/370.1%
pow370.1%
+-commutative70.1%
associate-+l-70.1%
Applied egg-rr70.1%
Taylor expanded in x around inf 22.1%
Final simplification48.5%
(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.6%
Final simplification77.6%
(FPCore (x y z a) :precision binary64 (if (<= a -1.25) x (if (<= a 5.8e-21) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.25) {
tmp = x;
} else if (a <= 5.8e-21) {
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.25d0)) then
tmp = x
else if (a <= 5.8d-21) 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.25) {
tmp = x;
} else if (a <= 5.8e-21) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.25: tmp = x elif a <= 5.8e-21: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.25) tmp = x; elseif (a <= 5.8e-21) 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.25) tmp = x; elseif (a <= 5.8e-21) tmp = x + (tan((y + z)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.25], x, If[LessEqual[a, 5.8e-21], 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.25:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{-21}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.25 or 5.8e-21 < a Initial program 77.6%
Taylor expanded in x around inf 21.8%
if -1.25 < a < 5.8e-21Initial program 77.6%
Taylor expanded in a around 0 77.5%
Final simplification48.5%
(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.6%
Taylor expanded in x around inf 30.8%
Final simplification30.8%
herbie shell --seed 2024089
(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))))