
(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 10 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 y) (sin z)) (* (cos y) (cos z))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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 - ((sin(y) * sin(z)) / (cos(y) * cos(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.sin(y) * Math.sin(z)) / (Math.cos(y) * Math.cos(z))))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.sin(y) * math.sin(z)) / (math.cos(y) * math.cos(z))))) - 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(y) * sin(z)) / Float64(cos(y) * cos(z))))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\sin y \cdot \sin z}{\cos y \cdot \cos z}} - \tan a\right)
\end{array}
Initial program 78.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(if (or (<= (tan a) -0.001) (not (<= (tan a) 2e-15)))
(+ x (- (tan (+ y z)) (tan a)))
(+
x
(-
(/ (+ (tan y) (tan z)) (+ 1.0 (+ 1.0 (- -1.0 (* (tan y) (tan z))))))
a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.001) || !(tan(a) <= 2e-15)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x + (((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(z)))))) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((tan(a) <= (-0.001d0)) .or. (.not. (tan(a) <= 2d-15))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x + (((tan(y) + tan(z)) / (1.0d0 + (1.0d0 + ((-1.0d0) - (tan(y) * tan(z)))))) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.001) || !(Math.tan(a) <= 2e-15)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 + (1.0 + (-1.0 - (Math.tan(y) * Math.tan(z)))))) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.001) or not (math.tan(a) <= 2e-15): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 + (1.0 + (-1.0 - (math.tan(y) * math.tan(z)))))) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.001) || !(tan(a) <= 2e-15)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 + Float64(1.0 + Float64(-1.0 - Float64(tan(y) * tan(z)))))) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.001) || ~((tan(a) <= 2e-15))) tmp = x + (tan((y + z)) - tan(a)); else tmp = x + (((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(z)))))) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.001], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 2e-15]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(1.0 + N[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.001 \lor \neg \left(\tan a \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)} - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -1e-3 or 2.0000000000000002e-15 < (tan.f64 a) Initial program 82.7%
if -1e-3 < (tan.f64 a) < 2.0000000000000002e-15Initial program 74.3%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
expm1-log1p-u92.1%
expm1-udef92.2%
log1p-udef92.2%
add-exp-log99.6%
Applied egg-rr99.6%
Taylor expanded in a around 0 99.6%
Final simplification90.7%
(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 78.8%
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 (if (or (<= a -0.00048) (not (<= a 2.8e-14))) (+ x (- (tan (+ y z)) (tan a))) (+ (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (- x a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.00048) || !(a <= 2.8e-14)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - 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.00048d0)) .or. (.not. (a <= 2.8d-14))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) + (x - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.00048) || !(a <= 2.8e-14)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.00048) or not (a <= 2.8e-14): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) + (x - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.00048) || !(a <= 2.8e-14)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.00048) || ~((a <= 2.8e-14))) tmp = x + (tan((y + z)) - tan(a)); else tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.00048], N[Not[LessEqual[a, 2.8e-14]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[(x - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00048 \lor \neg \left(a \leq 2.8 \cdot 10^{-14}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\
\end{array}
\end{array}
if a < -4.80000000000000012e-4 or 2.8000000000000001e-14 < a Initial program 82.7%
if -4.80000000000000012e-4 < a < 2.8000000000000001e-14Initial program 74.3%
associate-+r-74.3%
+-commutative74.3%
associate--l+74.3%
Simplified74.3%
Taylor expanded in a around 0 74.3%
tan-sum99.5%
div-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
fma-udef99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification90.7%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 5e-8) (+ x (- (tan y) (tan a))) (+ (tan (+ y z)) (/ 1.0 (/ 1.0 x)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-8) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = tan((y + z)) + (1.0 / (1.0 / 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 ((y + z) <= 5d-8) then
tmp = x + (tan(y) - tan(a))
else
tmp = tan((y + z)) + (1.0d0 / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 5e-8) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = Math.tan((y + z)) + (1.0 / (1.0 / x));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 5e-8: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = math.tan((y + z)) + (1.0 / (1.0 / x)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 5e-8) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(tan(Float64(y + z)) + Float64(1.0 / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 5e-8) tmp = x + (tan(y) - tan(a)); else tmp = tan((y + z)) + (1.0 / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 5e-8], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 5 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(y + z\right) + \frac{1}{\frac{1}{x}}\\
\end{array}
\end{array}
if (+.f64 y z) < 4.9999999999999998e-8Initial program 81.3%
Taylor expanded in z around 0 72.7%
tan-quot72.8%
expm1-log1p-u66.1%
expm1-udef66.1%
Applied egg-rr66.1%
expm1-def66.1%
expm1-log1p72.8%
Simplified72.8%
if 4.9999999999999998e-8 < (+.f64 y z) Initial program 75.1%
associate-+r-75.0%
+-commutative75.0%
associate--l+75.0%
Simplified75.0%
flip--74.8%
clear-num74.7%
pow274.7%
Applied egg-rr74.7%
Taylor expanded in x around inf 50.0%
Final simplification63.4%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 78.8%
Final simplification78.8%
(FPCore (x y z a) :precision binary64 (if (or (<= (+ y z) -10000000.0) (not (<= (+ y z) 5e-8))) (+ (tan (+ y z)) (/ 1.0 (/ 1.0 x))) (+ x (- y (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (((y + z) <= -10000000.0) || !((y + z) <= 5e-8)) {
tmp = tan((y + z)) + (1.0 / (1.0 / x));
} else {
tmp = x + (y - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (((y + z) <= (-10000000.0d0)) .or. (.not. ((y + z) <= 5d-8))) then
tmp = tan((y + z)) + (1.0d0 / (1.0d0 / x))
else
tmp = x + (y - 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) <= -10000000.0) || !((y + z) <= 5e-8)) {
tmp = Math.tan((y + z)) + (1.0 / (1.0 / x));
} else {
tmp = x + (y - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if ((y + z) <= -10000000.0) or not ((y + z) <= 5e-8): tmp = math.tan((y + z)) + (1.0 / (1.0 / x)) else: tmp = x + (y - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if ((Float64(y + z) <= -10000000.0) || !(Float64(y + z) <= 5e-8)) tmp = Float64(tan(Float64(y + z)) + Float64(1.0 / Float64(1.0 / x))); else tmp = Float64(x + Float64(y - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (((y + z) <= -10000000.0) || ~(((y + z) <= 5e-8))) tmp = tan((y + z)) + (1.0 / (1.0 / x)); else tmp = x + (y - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[(y + z), $MachinePrecision], -10000000.0], N[Not[LessEqual[N[(y + z), $MachinePrecision], 5e-8]], $MachinePrecision]], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -10000000 \lor \neg \left(y + z \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\tan \left(y + z\right) + \frac{1}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -1e7 or 4.9999999999999998e-8 < (+.f64 y z) Initial program 71.4%
associate-+r-71.3%
+-commutative71.3%
associate--l+71.3%
Simplified71.3%
flip--71.2%
clear-num71.1%
pow271.1%
Applied egg-rr71.1%
Taylor expanded in x around inf 45.5%
if -1e7 < (+.f64 y z) < 4.9999999999999998e-8Initial program 99.9%
Taylor expanded in z around 0 99.0%
Taylor expanded in y around 0 99.0%
Final simplification59.3%
(FPCore (x y z a) :precision binary64 (if (or (<= a -8.8e+24) (not (<= a 0.24))) (+ x (- y (tan a))) (+ (tan (+ y z)) (- x a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -8.8e+24) || !(a <= 0.24)) {
tmp = x + (y - tan(a));
} else {
tmp = tan((y + z)) + (x - 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 <= (-8.8d+24)) .or. (.not. (a <= 0.24d0))) then
tmp = x + (y - tan(a))
else
tmp = tan((y + z)) + (x - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -8.8e+24) || !(a <= 0.24)) {
tmp = x + (y - Math.tan(a));
} else {
tmp = Math.tan((y + z)) + (x - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -8.8e+24) or not (a <= 0.24): tmp = x + (y - math.tan(a)) else: tmp = math.tan((y + z)) + (x - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -8.8e+24) || !(a <= 0.24)) tmp = Float64(x + Float64(y - tan(a))); else tmp = Float64(tan(Float64(y + z)) + Float64(x - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -8.8e+24) || ~((a <= 0.24))) tmp = x + (y - tan(a)); else tmp = tan((y + z)) + (x - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -8.8e+24], N[Not[LessEqual[a, 0.24]], $MachinePrecision]], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+24} \lor \neg \left(a \leq 0.24\right):\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(y + z\right) + \left(x - a\right)\\
\end{array}
\end{array}
if a < -8.80000000000000007e24 or 0.23999999999999999 < a Initial program 81.8%
Taylor expanded in z around 0 69.8%
Taylor expanded in y around 0 35.0%
if -8.80000000000000007e24 < a < 0.23999999999999999Initial program 75.9%
associate-+r-75.8%
+-commutative75.8%
associate--l+75.8%
Simplified75.8%
Taylor expanded in a around 0 72.5%
Final simplification54.3%
(FPCore (x y z a) :precision binary64 (if (<= y -18000000.0) x (if (<= y 8.2e-54) (+ x (- y (tan a))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -18000000.0) {
tmp = x;
} else if (y <= 8.2e-54) {
tmp = x + (y - tan(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 (y <= (-18000000.0d0)) then
tmp = x
else if (y <= 8.2d-54) then
tmp = x + (y - tan(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 (y <= -18000000.0) {
tmp = x;
} else if (y <= 8.2e-54) {
tmp = x + (y - Math.tan(a));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -18000000.0: tmp = x elif y <= 8.2e-54: tmp = x + (y - math.tan(a)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -18000000.0) tmp = x; elseif (y <= 8.2e-54) tmp = Float64(x + Float64(y - tan(a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -18000000.0) tmp = x; elseif (y <= 8.2e-54) tmp = x + (y - tan(a)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -18000000.0], x, If[LessEqual[y, 8.2e-54], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-54}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.8e7 or 8.2000000000000001e-54 < y Initial program 63.6%
Taylor expanded in x around inf 23.6%
if -1.8e7 < y < 8.2000000000000001e-54Initial program 99.1%
Taylor expanded in z around 0 67.2%
Taylor expanded in y around 0 66.4%
Final simplification41.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 78.8%
Taylor expanded in x around inf 31.6%
Final simplification31.6%
herbie shell --seed 2023275
(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))))