
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (- (* (+ (tan y) (tan z)) (/ -1.0 (+ -1.0 (* (tan y) (tan z))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) * (-1.0 / (-1.0 + (tan(y) * tan(z))))) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(y) + tan(z)) * ((-1.0d0) / ((-1.0d0) + (tan(y) * tan(z))))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(y) + Math.tan(z)) * (-1.0 / (-1.0 + (Math.tan(y) * Math.tan(z))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) * (-1.0 / (-1.0 + (math.tan(y) * math.tan(z))))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(-1.0 / Float64(-1.0 + Float64(tan(y) * tan(z))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) * (-1.0 / (-1.0 + (tan(y) * tan(z))))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(-1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) \cdot \frac{-1}{-1 + \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 76.0%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -4e-13) (not (<= (tan a) 4e-29))) (+ x (- (tan (+ y z)) (tan a))) (- x (* (+ (tan y) (tan z)) (/ -1.0 (- 1.0 (* (tan y) (tan z))))))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -4e-13) || !(tan(a) <= 4e-29)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x - ((tan(y) + tan(z)) * (-1.0 / (1.0 - (tan(y) * tan(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 ((tan(a) <= (-4d-13)) .or. (.not. (tan(a) <= 4d-29))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x - ((tan(y) + tan(z)) * ((-1.0d0) / (1.0d0 - (tan(y) * tan(z)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -4e-13) || !(Math.tan(a) <= 4e-29)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x - ((Math.tan(y) + Math.tan(z)) * (-1.0 / (1.0 - (Math.tan(y) * Math.tan(z)))));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -4e-13) or not (math.tan(a) <= 4e-29): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x - ((math.tan(y) + math.tan(z)) * (-1.0 / (1.0 - (math.tan(y) * math.tan(z))))) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -4e-13) || !(tan(a) <= 4e-29)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x - Float64(Float64(tan(y) + tan(z)) * Float64(-1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -4e-13) || ~((tan(a) <= 4e-29))) tmp = x + (tan((y + z)) - tan(a)); else tmp = x - ((tan(y) + tan(z)) * (-1.0 / (1.0 - (tan(y) * tan(z))))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -4e-13], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 4e-29]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -4 \cdot 10^{-13} \lor \neg \left(\tan a \leq 4 \cdot 10^{-29}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(\tan y + \tan z\right) \cdot \frac{-1}{1 - \tan y \cdot \tan z}\\
\end{array}
\end{array}
if (tan.f64 a) < -4.0000000000000001e-13 or 3.99999999999999977e-29 < (tan.f64 a) Initial program 79.9%
if -4.0000000000000001e-13 < (tan.f64 a) < 3.99999999999999977e-29Initial program 71.6%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
+-commutative99.7%
un-div-inv99.7%
tan-sum71.6%
associate--r-71.6%
tan-sum99.7%
un-div-inv99.7%
*-commutative99.7%
fma-neg99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 99.7%
neg-mul-171.6%
Simplified99.7%
fma-undefine99.7%
remove-double-neg99.7%
Applied egg-rr99.7%
Final simplification89.2%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -4e-13) (not (<= (tan a) 4e-29))) (+ x (- (tan (+ y z)) (tan a))) (- x (/ (+ (tan y) (tan z)) (+ -1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -4e-13) || !(tan(a) <= 4e-29)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x - ((tan(y) + tan(z)) / (-1.0 + (tan(y) * tan(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 ((tan(a) <= (-4d-13)) .or. (.not. (tan(a) <= 4d-29))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x - ((tan(y) + tan(z)) / ((-1.0d0) + (tan(y) * tan(z))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -4e-13) || !(Math.tan(a) <= 4e-29)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x - ((Math.tan(y) + Math.tan(z)) / (-1.0 + (Math.tan(y) * Math.tan(z))));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -4e-13) or not (math.tan(a) <= 4e-29): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x - ((math.tan(y) + math.tan(z)) / (-1.0 + (math.tan(y) * math.tan(z)))) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -4e-13) || !(tan(a) <= 4e-29)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x - Float64(Float64(tan(y) + tan(z)) / Float64(-1.0 + Float64(tan(y) * tan(z))))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -4e-13) || ~((tan(a) <= 4e-29))) tmp = x + (tan((y + z)) - tan(a)); else tmp = x - ((tan(y) + tan(z)) / (-1.0 + (tan(y) * tan(z)))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -4e-13], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 4e-29]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -4 \cdot 10^{-13} \lor \neg \left(\tan a \leq 4 \cdot 10^{-29}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\tan y + \tan z}{-1 + \tan y \cdot \tan z}\\
\end{array}
\end{array}
if (tan.f64 a) < -4.0000000000000001e-13 or 3.99999999999999977e-29 < (tan.f64 a) Initial program 79.9%
if -4.0000000000000001e-13 < (tan.f64 a) < 3.99999999999999977e-29Initial program 71.6%
+-commutative71.6%
associate-+l-71.6%
Applied egg-rr71.6%
Taylor expanded in a around 0 71.6%
neg-mul-171.6%
Simplified71.6%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
remove-double-neg99.7%
Applied egg-rr99.7%
fma-undefine99.7%
*-commutative99.7%
+-commutative99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification89.2%
(FPCore (x y z a) :precision binary64 (if (or (<= a -4e-13) (not (<= a 5e-27))) (+ x (- (tan (+ y z)) (tan a))) (fma (+ (tan y) (tan z)) (/ -1.0 (+ -1.0 (* (tan y) (tan z)))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -4e-13) || !(a <= 5e-27)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = fma((tan(y) + tan(z)), (-1.0 / (-1.0 + (tan(y) * tan(z)))), x);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -4e-13) || !(a <= 5e-27)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = fma(Float64(tan(y) + tan(z)), Float64(-1.0 / Float64(-1.0 + Float64(tan(y) * tan(z)))), x); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -4e-13], N[Not[LessEqual[a, 5e-27]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-13} \lor \neg \left(a \leq 5 \cdot 10^{-27}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\tan y + \tan z, \frac{-1}{-1 + \tan y \cdot \tan z}, x\right)\\
\end{array}
\end{array}
if a < -4.0000000000000001e-13 or 5.0000000000000002e-27 < a Initial program 79.9%
if -4.0000000000000001e-13 < a < 5.0000000000000002e-27Initial program 71.6%
+-commutative71.6%
associate-+l-71.6%
Applied egg-rr71.6%
Taylor expanded in a around 0 71.6%
neg-mul-171.6%
Simplified71.6%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
remove-double-neg99.7%
Applied egg-rr99.7%
Final simplification89.2%
(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 76.0%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (tan (+ y z))) (t_1 (+ x t_0))) (if (<= t_0 -5e-7) t_1 (if (<= t_0 2e-25) (+ z (- x (tan a))) (fabs t_1)))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -5e-7) {
tmp = t_1;
} else if (t_0 <= 2e-25) {
tmp = z + (x - tan(a));
} else {
tmp = fabs(t_1);
}
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) :: t_1
real(8) :: tmp
t_0 = tan((y + z))
t_1 = x + t_0
if (t_0 <= (-5d-7)) then
tmp = t_1
else if (t_0 <= 2d-25) then
tmp = z + (x - tan(a))
else
tmp = abs(t_1)
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 t_1 = x + t_0;
double tmp;
if (t_0 <= -5e-7) {
tmp = t_1;
} else if (t_0 <= 2e-25) {
tmp = z + (x - Math.tan(a));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) t_1 = x + t_0 tmp = 0 if t_0 <= -5e-7: tmp = t_1 elif t_0 <= 2e-25: tmp = z + (x - math.tan(a)) else: tmp = math.fabs(t_1) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) t_1 = Float64(x + t_0) tmp = 0.0 if (t_0 <= -5e-7) tmp = t_1; elseif (t_0 <= 2e-25) tmp = Float64(z + Float64(x - tan(a))); else tmp = abs(t_1); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); t_1 = x + t_0; tmp = 0.0; if (t_0 <= -5e-7) tmp = t_1; elseif (t_0 <= 2e-25) tmp = z + (x - tan(a)); else tmp = abs(t_1); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-7], t$95$1, If[LessEqual[t$95$0, 2e-25], N[(z + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-25}:\\
\;\;\;\;z + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -4.99999999999999977e-7Initial program 69.2%
+-commutative69.2%
associate-+l-69.1%
Applied egg-rr69.1%
Taylor expanded in a around 0 41.6%
neg-mul-141.6%
Simplified41.6%
sub-neg41.6%
remove-double-neg41.6%
Applied egg-rr41.6%
if -4.99999999999999977e-7 < (tan.f64 (+.f64 y z)) < 2.00000000000000008e-25Initial program 99.4%
+-commutative99.4%
associate-+l-99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 99.4%
Taylor expanded in z around 0 99.4%
if 2.00000000000000008e-25 < (tan.f64 (+.f64 y z)) Initial program 71.6%
+-commutative71.6%
associate-+l-71.6%
Applied egg-rr71.6%
Taylor expanded in a around 0 46.3%
neg-mul-146.3%
Simplified46.3%
add-sqr-sqrt46.1%
sqrt-unprod46.3%
pow246.3%
sub-neg46.3%
remove-double-neg46.3%
Applied egg-rr46.3%
unpow246.3%
rem-sqrt-square46.3%
+-commutative46.3%
Simplified46.3%
Final simplification54.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (or (<= t_0 -5e-7) (not (<= t_0 2e-25)))
(+ 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-7) || !(t_0 <= 2e-25)) {
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-7)) .or. (.not. (t_0 <= 2d-25))) 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-7) || !(t_0 <= 2e-25)) {
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-7) or not (t_0 <= 2e-25): 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-7) || !(t_0 <= 2e-25)) 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-7) || ~((t_0 <= 2e-25))) 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-7], N[Not[LessEqual[t$95$0, 2e-25]], $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^{-7} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-25}\right):\\
\;\;\;\;x + t\_0\\
\mathbf{else}:\\
\;\;\;\;z + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -4.99999999999999977e-7 or 2.00000000000000008e-25 < (tan.f64 (+.f64 y z)) Initial program 70.4%
+-commutative70.4%
associate-+l-70.3%
Applied egg-rr70.3%
Taylor expanded in a around 0 43.8%
neg-mul-143.8%
Simplified43.8%
sub-neg43.8%
remove-double-neg43.8%
Applied egg-rr43.8%
if -4.99999999999999977e-7 < (tan.f64 (+.f64 y z)) < 2.00000000000000008e-25Initial program 99.4%
+-commutative99.4%
associate-+l-99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 99.4%
Taylor expanded in z around 0 99.4%
Final simplification54.7%
(FPCore (x y z a) :precision binary64 (if (<= y -7.2e-7) (+ x (/ (sin y) (cos y))) (- x (- (tan a) (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -7.2e-7) {
tmp = x + (sin(y) / cos(y));
} else {
tmp = x - (tan(a) - tan(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 (y <= (-7.2d-7)) then
tmp = x + (sin(y) / cos(y))
else
tmp = x - (tan(a) - tan(z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -7.2e-7) {
tmp = x + (Math.sin(y) / Math.cos(y));
} else {
tmp = x - (Math.tan(a) - Math.tan(z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -7.2e-7: tmp = x + (math.sin(y) / math.cos(y)) else: tmp = x - (math.tan(a) - math.tan(z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -7.2e-7) tmp = Float64(x + Float64(sin(y) / cos(y))); else tmp = Float64(x - Float64(tan(a) - tan(z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -7.2e-7) tmp = x + (sin(y) / cos(y)); else tmp = x - (tan(a) - tan(z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -7.2e-7], N[(x + N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{-7}:\\
\;\;\;\;x + \frac{\sin y}{\cos y}\\
\mathbf{else}:\\
\;\;\;\;x - \left(\tan a - \tan z\right)\\
\end{array}
\end{array}
if y < -7.19999999999999989e-7Initial program 57.9%
+-commutative57.9%
associate-+l-57.9%
Applied egg-rr57.9%
Taylor expanded in a around 0 35.7%
neg-mul-135.7%
Simplified35.7%
Taylor expanded in z around 0 35.5%
if -7.19999999999999989e-7 < y Initial program 83.0%
+-commutative83.0%
associate-+l-83.0%
Applied egg-rr83.0%
Taylor expanded in y around 0 69.2%
tan-quot69.3%
associate--r-69.3%
Applied egg-rr69.3%
Final simplification59.9%
(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 76.0%
Final simplification76.0%
(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 76.0%
+-commutative76.0%
associate-+l-76.0%
Applied egg-rr76.0%
Taylor expanded in a around 0 46.5%
neg-mul-146.5%
Simplified46.5%
sub-neg46.5%
remove-double-neg46.5%
Applied egg-rr46.5%
Final simplification46.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 76.0%
Taylor expanded in x around inf 29.5%
Final simplification29.5%
herbie shell --seed 2024055
(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))))