
(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 13 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 (/ (/ (sin y) (/ (cos z) (sin z))) (cos y)))))
(tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) * (1.0 / (1.0 - ((sin(y) / (cos(z) / sin(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 / (1.0d0 - ((sin(y) / (cos(z) / sin(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 / (1.0 - ((Math.sin(y) / (Math.cos(z) / Math.sin(z))) / Math.cos(y))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - ((math.sin(y) / (math.cos(z) / math.sin(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(1.0 - Float64(Float64(sin(y) / Float64(cos(z) / sin(z))) / cos(y))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - ((sin(y) / (cos(z) / sin(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[(1.0 - N[(N[(N[Sin[y], $MachinePrecision] / N[(N[Cos[z], $MachinePrecision] / N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[y], $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 - \frac{\frac{\sin y}{\frac{\cos z}{\sin z}}}{\cos y}} - \tan a\right)
\end{array}
Initial program 79.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
*-commutative99.6%
tan-quot99.7%
associate-*r/99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 99.7%
associate-/l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (/ (* (tan z) (sin y)) (cos y))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) * (1.0 / (1.0 - ((tan(z) * sin(y)) / 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 / (1.0d0 - ((tan(z) * sin(y)) / 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 / (1.0 - ((Math.tan(z) * Math.sin(y)) / Math.cos(y))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - ((math.tan(z) * math.sin(y)) / 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(1.0 - Float64(Float64(tan(z) * sin(y)) / cos(y))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - ((tan(z) * sin(y)) / 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[(1.0 - N[(N[(N[Tan[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / N[Cos[y], $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 - \frac{\tan z \cdot \sin y}{\cos y}} - \tan a\right)
\end{array}
Initial program 79.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
*-commutative99.6%
tan-quot99.7%
associate-*r/99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z a) :precision binary64 (if (or (<= a -5e-14) (not (<= a 3.7e-8))) (+ 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 <= -5e-14) || !(a <= 3.7e-8)) {
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 <= -5e-14) || !(a <= 3.7e-8)) 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, -5e-14], N[Not[LessEqual[a, 3.7e-8]], $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 -5 \cdot 10^{-14} \lor \neg \left(a \leq 3.7 \cdot 10^{-8}\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 < -5.0000000000000002e-14 or 3.7e-8 < a Initial program 79.3%
if -5.0000000000000002e-14 < a < 3.7e-8Initial program 80.3%
+-commutative80.3%
associate-+l-80.3%
Applied egg-rr80.3%
Taylor expanded in a around 0 80.2%
neg-mul-180.2%
Simplified80.2%
tan-sum99.3%
div-inv99.3%
fma-neg99.3%
+-commutative99.3%
*-commutative99.3%
Applied egg-rr99.3%
remove-double-neg99.3%
Simplified99.3%
Final simplification88.6%
(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 79.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 79.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.04e-13) (not (<= a 5.8e-8))) (+ 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 ((a <= -1.04e-13) || !(a <= 5.8e-8)) {
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 ((a <= (-1.04d-13)) .or. (.not. (a <= 5.8d-8))) 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 ((a <= -1.04e-13) || !(a <= 5.8e-8)) {
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 (a <= -1.04e-13) or not (a <= 5.8e-8): 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 ((a <= -1.04e-13) || !(a <= 5.8e-8)) 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 ((a <= -1.04e-13) || ~((a <= 5.8e-8))) 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[a, -1.04e-13], N[Not[LessEqual[a, 5.8e-8]], $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}\;a \leq -1.04 \cdot 10^{-13} \lor \neg \left(a \leq 5.8 \cdot 10^{-8}\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 a < -1.03999999999999999e-13 or 5.8000000000000003e-8 < a Initial program 79.3%
if -1.03999999999999999e-13 < a < 5.8000000000000003e-8Initial program 80.3%
+-commutative80.3%
associate-+l-80.3%
Applied egg-rr80.3%
Taylor expanded in a around 0 80.2%
neg-mul-180.2%
Simplified80.2%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.3%
Final simplification88.6%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.04e-13) (not (<= a 3.7e-8))) (+ 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 ((a <= -1.04e-13) || !(a <= 3.7e-8)) {
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 ((a <= (-1.04d-13)) .or. (.not. (a <= 3.7d-8))) 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 ((a <= -1.04e-13) || !(a <= 3.7e-8)) {
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 (a <= -1.04e-13) or not (a <= 3.7e-8): 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 ((a <= -1.04e-13) || !(a <= 3.7e-8)) 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 ((a <= -1.04e-13) || ~((a <= 3.7e-8))) 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[a, -1.04e-13], N[Not[LessEqual[a, 3.7e-8]], $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}\;a \leq -1.04 \cdot 10^{-13} \lor \neg \left(a \leq 3.7 \cdot 10^{-8}\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 a < -1.03999999999999999e-13 or 3.7e-8 < a Initial program 79.3%
if -1.03999999999999999e-13 < a < 3.7e-8Initial program 80.3%
+-commutative80.3%
associate-+l-80.3%
Applied egg-rr80.3%
Taylor expanded in a around 0 80.2%
neg-mul-180.2%
Simplified80.2%
tan-sum99.3%
div-inv99.3%
fma-neg99.3%
+-commutative99.3%
*-commutative99.3%
Applied egg-rr99.3%
fma-udef99.3%
associate-*r/99.3%
*-rgt-identity99.3%
remove-double-neg99.3%
Simplified99.3%
Final simplification88.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 5e-6) (+ x (- (tan y) (tan a))) (+ x (tan (+ y z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-6) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + 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 ((y + z) <= 5d-6) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + tan((y + z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-6) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + Math.tan((y + z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 5e-6: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + math.tan((y + z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 5e-6) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + tan(Float64(y + z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 5e-6) tmp = x + (tan(y) - tan(a)); else tmp = x + tan((y + z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 5e-6], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 5 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 5.00000000000000041e-6Initial program 83.9%
+-commutative83.9%
associate-+l-83.9%
Applied egg-rr83.9%
Taylor expanded in z around 0 71.9%
tan-quot71.9%
associate--r-72.0%
Applied egg-rr72.0%
if 5.00000000000000041e-6 < (+.f64 y z) Initial program 71.9%
+-commutative71.9%
associate-+l-71.7%
Applied egg-rr71.7%
Taylor expanded in a around 0 44.6%
neg-mul-144.6%
Simplified44.6%
sub-neg44.6%
+-commutative44.6%
Applied egg-rr44.6%
remove-double-neg44.6%
+-commutative44.6%
Simplified44.6%
Final simplification62.4%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 5e-6) (+ x (- (tan y) (tan a))) (+ x (/ (sin z) (cos z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-6) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (sin(z) / cos(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 + z) <= 5d-6) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (sin(z) / cos(z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-6) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.sin(z) / Math.cos(z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 5e-6: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.sin(z) / math.cos(z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 5e-6) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(sin(z) / cos(z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 5e-6) tmp = x + (tan(y) - tan(a)); else tmp = x + (sin(z) / cos(z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 5e-6], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Sin[z], $MachinePrecision] / N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 5 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\sin z}{\cos z}\\
\end{array}
\end{array}
if (+.f64 y z) < 5.00000000000000041e-6Initial program 83.9%
+-commutative83.9%
associate-+l-83.9%
Applied egg-rr83.9%
Taylor expanded in z around 0 71.9%
tan-quot71.9%
associate--r-72.0%
Applied egg-rr72.0%
if 5.00000000000000041e-6 < (+.f64 y z) Initial program 71.9%
+-commutative71.9%
associate-+l-71.7%
Applied egg-rr71.7%
Taylor expanded in a around 0 44.6%
neg-mul-144.6%
Simplified44.6%
Taylor expanded in y around 0 33.9%
+-commutative33.9%
Simplified33.9%
Final simplification58.7%
(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 79.8%
Final simplification79.8%
(FPCore (x y z a) :precision binary64 (if (or (<= (+ y z) -1.0) (not (<= (+ y z) 5e-6))) (+ x (tan (+ y z))) (+ y (- x (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (((y + z) <= -1.0) || !((y + z) <= 5e-6)) {
tmp = x + tan((y + z));
} else {
tmp = y + (x - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (((y + z) <= (-1.0d0)) .or. (.not. ((y + z) <= 5d-6))) then
tmp = x + tan((y + z))
else
tmp = y + (x - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (((y + z) <= -1.0) || !((y + z) <= 5e-6)) {
tmp = x + Math.tan((y + z));
} else {
tmp = y + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if ((y + z) <= -1.0) or not ((y + z) <= 5e-6): tmp = x + math.tan((y + z)) else: tmp = y + (x - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if ((Float64(y + z) <= -1.0) || !(Float64(y + z) <= 5e-6)) tmp = Float64(x + tan(Float64(y + z))); else tmp = Float64(y + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (((y + z) <= -1.0) || ~(((y + z) <= 5e-6))) tmp = x + tan((y + z)); else tmp = y + (x - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[(y + z), $MachinePrecision], -1.0], N[Not[LessEqual[N[(y + z), $MachinePrecision], 5e-6]], $MachinePrecision]], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(y + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -1 \lor \neg \left(y + z \leq 5 \cdot 10^{-6}\right):\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;y + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -1 or 5.00000000000000041e-6 < (+.f64 y z) Initial program 72.0%
+-commutative72.0%
associate-+l-71.9%
Applied egg-rr71.9%
Taylor expanded in a around 0 45.3%
neg-mul-145.3%
Simplified45.3%
sub-neg45.3%
+-commutative45.3%
Applied egg-rr45.3%
remove-double-neg45.3%
+-commutative45.3%
Simplified45.3%
if -1 < (+.f64 y z) < 5.00000000000000041e-6Initial program 99.9%
+-commutative99.9%
associate-+l-99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 98.9%
Taylor expanded in y around 0 98.9%
Final simplification60.2%
(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 79.8%
+-commutative79.8%
associate-+l-79.7%
Applied egg-rr79.7%
Taylor expanded in a around 0 49.8%
neg-mul-149.8%
Simplified49.8%
sub-neg49.8%
+-commutative49.8%
Applied egg-rr49.8%
remove-double-neg49.8%
+-commutative49.8%
Simplified49.8%
Final simplification49.8%
(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 79.8%
Taylor expanded in x around inf 33.0%
Final simplification33.0%
herbie shell --seed 2023337
(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))))