
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (- x (+ (tan a) (/ (+ (tan y) (tan z)) (fma (tan y) (tan z) -1.0)))))
double code(double x, double y, double z, double a) {
return x - (tan(a) + ((tan(y) + tan(z)) / fma(tan(y), tan(z), -1.0)));
}
function code(x, y, z, a) return Float64(x - Float64(tan(a) + Float64(Float64(tan(y) + tan(z)) / fma(tan(y), tan(z), -1.0)))) 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[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a + \frac{\tan y + \tan z}{\mathsf{fma}\left(\tan y, \tan z, -1\right)}\right)
\end{array}
Initial program 76.8%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
expm1-log1p-u92.0%
expm1-undefine92.0%
log1p-undefine92.0%
add-exp-log99.8%
Applied egg-rr99.8%
associate--l+99.8%
fma-neg99.8%
metadata-eval99.8%
Simplified99.8%
sub-neg99.8%
associate--r+99.8%
metadata-eval99.8%
Applied egg-rr99.8%
sub-neg99.8%
sub0-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -0.0001)
(+ x (- (/ 1.0 (/ (cos (+ y z)) (sin (+ y z)))) (tan a)))
(if (<= (tan a) 2e-23)
(+ (/ t_0 (- 1.0 (* (tan y) (tan z)))) (- x a))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.0001) {
tmp = x + ((1.0 / (cos((y + z)) / sin((y + z)))) - tan(a));
} else if (tan(a) <= 2e-23) {
tmp = (t_0 / (1.0 - (tan(y) * tan(z)))) + (x - 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) + tan(z)
if (tan(a) <= (-0.0001d0)) then
tmp = x + ((1.0d0 / (cos((y + z)) / sin((y + z)))) - tan(a))
else if (tan(a) <= 2d-23) then
tmp = (t_0 / (1.0d0 - (tan(y) * tan(z)))) + (x - 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) + Math.tan(z);
double tmp;
if (Math.tan(a) <= -0.0001) {
tmp = x + ((1.0 / (Math.cos((y + z)) / Math.sin((y + z)))) - Math.tan(a));
} else if (Math.tan(a) <= 2e-23) {
tmp = (t_0 / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - a);
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if math.tan(a) <= -0.0001: tmp = x + ((1.0 / (math.cos((y + z)) / math.sin((y + z)))) - math.tan(a)) elif math.tan(a) <= 2e-23: tmp = (t_0 / (1.0 - (math.tan(y) * math.tan(z)))) + (x - a) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.0001) tmp = Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(y + z)) / sin(Float64(y + z)))) - tan(a))); elseif (tan(a) <= 2e-23) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - 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) + tan(z); tmp = 0.0; if (tan(a) <= -0.0001) tmp = x + ((1.0 / (cos((y + z)) / sin((y + z)))) - tan(a)); elseif (tan(a) <= 2e-23) tmp = (t_0 / (1.0 - (tan(y) * tan(z)))) + (x - a); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.0001], N[(x + N[(N[(1.0 / N[(N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-23], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.0001:\\
\;\;\;\;x + \left(\frac{1}{\frac{\cos \left(y + z\right)}{\sin \left(y + z\right)}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-23}:\\
\;\;\;\;\frac{t\_0}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -1.00000000000000005e-4Initial program 77.5%
tan-quot77.6%
clear-num77.6%
Applied egg-rr77.6%
if -1.00000000000000005e-4 < (tan.f64 a) < 1.99999999999999992e-23Initial program 76.5%
add-cbrt-cube75.8%
pow1/373.0%
pow373.0%
+-commutative73.0%
associate-+l-73.0%
Applied egg-rr73.0%
unpow1/375.9%
rem-cbrt-cube76.5%
tan-sum99.8%
div-inv99.8%
fma-neg99.8%
Applied egg-rr99.8%
fma-undefine99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in a around 0 99.8%
if 1.99999999999999992e-23 < (tan.f64 a) Initial program 76.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u94.9%
expm1-undefine94.9%
log1p-undefine94.8%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 77.1%
Final simplification87.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -1e-8)
(+ x (- (/ 1.0 (/ (cos (+ y z)) (sin (+ y z)))) (tan a)))
(if (<= (tan a) 2e-23)
(+ x (/ t_0 (- 1.0 (* (tan y) (tan z)))))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -1e-8) {
tmp = x + ((1.0 / (cos((y + z)) / sin((y + z)))) - tan(a));
} else if (tan(a) <= 2e-23) {
tmp = x + (t_0 / (1.0 - (tan(y) * tan(z))));
} 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) + tan(z)
if (tan(a) <= (-1d-8)) then
tmp = x + ((1.0d0 / (cos((y + z)) / sin((y + z)))) - tan(a))
else if (tan(a) <= 2d-23) then
tmp = x + (t_0 / (1.0d0 - (tan(y) * tan(z))))
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) + Math.tan(z);
double tmp;
if (Math.tan(a) <= -1e-8) {
tmp = x + ((1.0 / (Math.cos((y + z)) / Math.sin((y + z)))) - Math.tan(a));
} else if (Math.tan(a) <= 2e-23) {
tmp = x + (t_0 / (1.0 - (Math.tan(y) * Math.tan(z))));
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if math.tan(a) <= -1e-8: tmp = x + ((1.0 / (math.cos((y + z)) / math.sin((y + z)))) - math.tan(a)) elif math.tan(a) <= 2e-23: tmp = x + (t_0 / (1.0 - (math.tan(y) * math.tan(z)))) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -1e-8) tmp = Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(y + z)) / sin(Float64(y + z)))) - tan(a))); elseif (tan(a) <= 2e-23) tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z))))); 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) + tan(z); tmp = 0.0; if (tan(a) <= -1e-8) tmp = x + ((1.0 / (cos((y + z)) / sin((y + z)))) - tan(a)); elseif (tan(a) <= 2e-23) tmp = x + (t_0 / (1.0 - (tan(y) * tan(z)))); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -1e-8], N[(x + N[(N[(1.0 / N[(N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-23], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -1 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\frac{1}{\frac{\cos \left(y + z\right)}{\sin \left(y + z\right)}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-23}:\\
\;\;\;\;x + \frac{t\_0}{1 - \tan y \cdot \tan z}\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -1e-8Initial program 77.9%
tan-quot77.9%
clear-num77.9%
Applied egg-rr77.9%
if -1e-8 < (tan.f64 a) < 1.99999999999999992e-23Initial program 76.3%
add-cbrt-cube75.6%
pow1/372.8%
pow372.8%
+-commutative72.8%
associate-+l-72.8%
Applied egg-rr72.8%
unpow1/375.6%
rem-cbrt-cube76.3%
tan-sum99.8%
div-inv99.8%
fma-neg99.8%
Applied egg-rr99.8%
fma-undefine99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in a around 0 99.8%
neg-mul-199.8%
Simplified99.8%
if 1.99999999999999992e-23 < (tan.f64 a) Initial program 76.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u94.9%
expm1-undefine94.9%
log1p-undefine94.8%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 77.1%
Final simplification87.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 76.8%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.05)
x
(if (<= (tan a) 5e-10)
(+ 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 (tan(a) <= -0.05) {
tmp = x;
} else if (tan(a) <= 5e-10) {
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 (tan(a) <= (-0.05d0)) then
tmp = x
else if (tan(a) <= 5d-10) 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 (Math.tan(a) <= -0.05) {
tmp = x;
} else if (Math.tan(a) <= 5e-10) {
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 math.tan(a) <= -0.05: tmp = x elif math.tan(a) <= 5e-10: 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 (tan(a) <= -0.05) tmp = x; elseif (tan(a) <= 5e-10) 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 (tan(a) <= -0.05) tmp = x; elseif (tan(a) <= 5e-10) 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[N[Tan[a], $MachinePrecision], -0.05], x, If[LessEqual[N[Tan[a], $MachinePrecision], 5e-10], 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}\;\tan a \leq -0.05:\\
\;\;\;\;x\\
\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;{\left({x}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003Initial program 77.2%
Taylor expanded in x around inf 24.4%
if -0.050000000000000003 < (tan.f64 a) < 5.00000000000000031e-10Initial program 77.3%
Taylor expanded in a around 0 77.1%
if 5.00000000000000031e-10 < (tan.f64 a) Initial program 75.9%
add-cbrt-cube75.7%
pow1/370.9%
pow370.9%
+-commutative70.9%
associate-+l-70.9%
Applied egg-rr70.9%
Taylor expanded in x around inf 23.4%
(FPCore (x y z a) :precision binary64 (+ x (- (+ (tan y) (tan z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((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)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((Math.tan(y) + Math.tan(z)) - Math.tan(a));
}
def code(x, y, z, a): return x + ((math.tan(y) + math.tan(z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(tan(y) + tan(z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((tan(y) + tan(z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) - \tan a\right)
\end{array}
Initial program 76.8%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
expm1-log1p-u92.0%
expm1-undefine92.0%
log1p-undefine92.0%
add-exp-log99.8%
Applied egg-rr99.8%
associate--l+99.8%
fma-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 77.0%
Final simplification77.0%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.6e-13) (not (<= a 0.000425))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.6e-13) || !(a <= 0.000425)) {
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 <= (-1.6d-13)) .or. (.not. (a <= 0.000425d0))) 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 <= -1.6e-13) || !(a <= 0.000425)) {
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 <= -1.6e-13) or not (a <= 0.000425): 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 <= -1.6e-13) || !(a <= 0.000425)) 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 <= -1.6e-13) || ~((a <= 0.000425))) 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, -1.6e-13], N[Not[LessEqual[a, 0.000425]], $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 -1.6 \cdot 10^{-13} \lor \neg \left(a \leq 0.000425\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 < -1.6e-13 or 4.24999999999999976e-4 < a Initial program 76.4%
Taylor expanded in y around inf 57.5%
if -1.6e-13 < a < 4.24999999999999976e-4Initial program 77.4%
Taylor expanded in a around 0 77.4%
Final simplification66.1%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -4e-13) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -4e-13) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(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 ((y + z) <= (-4d-13)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(z) - 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) <= -4e-13) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -4e-13: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -4e-13) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -4e-13) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -4e-13], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -4 \cdot 10^{-13}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -4.0000000000000001e-13Initial program 64.3%
Taylor expanded in y around inf 40.2%
if -4.0000000000000001e-13 < (+.f64 y z) Initial program 84.0%
Taylor expanded in y around 0 68.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 76.8%
(FPCore (x y z a)
:precision binary64
(if (<= a -1.35)
x
(if (<= a -2.45e-294)
(+ x (- (tan y) a))
(if (<= a 1.58) (+ x (- (tan z) a)) x))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.35) {
tmp = x;
} else if (a <= -2.45e-294) {
tmp = x + (tan(y) - a);
} else if (a <= 1.58) {
tmp = x + (tan(z) - a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-1.35d0)) then
tmp = x
else if (a <= (-2.45d-294)) then
tmp = x + (tan(y) - a)
else if (a <= 1.58d0) then
tmp = x + (tan(z) - a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.35) {
tmp = x;
} else if (a <= -2.45e-294) {
tmp = x + (Math.tan(y) - a);
} else if (a <= 1.58) {
tmp = x + (Math.tan(z) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.35: tmp = x elif a <= -2.45e-294: tmp = x + (math.tan(y) - a) elif a <= 1.58: tmp = x + (math.tan(z) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.35) tmp = x; elseif (a <= -2.45e-294) tmp = Float64(x + Float64(tan(y) - a)); elseif (a <= 1.58) tmp = Float64(x + Float64(tan(z) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.35) tmp = x; elseif (a <= -2.45e-294) tmp = x + (tan(y) - a); elseif (a <= 1.58) tmp = x + (tan(z) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.35], x, If[LessEqual[a, -2.45e-294], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.58], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -2.45 \cdot 10^{-294}:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{elif}\;a \leq 1.58:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.3500000000000001 or 1.5800000000000001 < a Initial program 76.5%
Taylor expanded in x around inf 23.8%
if -1.3500000000000001 < a < -2.4499999999999999e-294Initial program 76.5%
Taylor expanded in a around 0 76.1%
Taylor expanded in y around inf 60.2%
if -2.4499999999999999e-294 < a < 1.5800000000000001Initial program 78.1%
Taylor expanded in a around 0 78.1%
Taylor expanded in y around 0 65.3%
(FPCore (x y z a) :precision binary64 (if (<= a -1.55) x (if (<= a 1.58) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 1.58) {
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.55d0)) then
tmp = x
else if (a <= 1.58d0) 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.55) {
tmp = x;
} else if (a <= 1.58) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.55: tmp = x elif a <= 1.58: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.55) tmp = x; elseif (a <= 1.58) 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.55) tmp = x; elseif (a <= 1.58) tmp = x + (tan((y + z)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.55], x, If[LessEqual[a, 1.58], 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.55:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.58:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.5800000000000001 < a Initial program 76.5%
Taylor expanded in x around inf 23.8%
if -1.55000000000000004 < a < 1.5800000000000001Initial program 77.3%
Taylor expanded in a around 0 77.1%
(FPCore (x y z a) :precision binary64 (if (<= a -1.85) x (if (<= a 3.3e-10) (+ x (- (tan y) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.85) {
tmp = x;
} else if (a <= 3.3e-10) {
tmp = x + (tan(y) - 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.85d0)) then
tmp = x
else if (a <= 3.3d-10) then
tmp = x + (tan(y) - 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.85) {
tmp = x;
} else if (a <= 3.3e-10) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.85: tmp = x elif a <= 3.3e-10: tmp = x + (math.tan(y) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.85) tmp = x; elseif (a <= 3.3e-10) tmp = Float64(x + Float64(tan(y) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.85) tmp = x; elseif (a <= 3.3e-10) tmp = x + (tan(y) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.85], x, If[LessEqual[a, 3.3e-10], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.85:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.8500000000000001 or 3.3e-10 < a Initial program 76.6%
Taylor expanded in x around inf 23.9%
if -1.8500000000000001 < a < 3.3e-10Initial program 77.1%
Taylor expanded in a around 0 76.9%
Taylor expanded in y around inf 59.7%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 76.8%
Taylor expanded in x around inf 33.8%
(FPCore (x y z a) :precision binary64 a)
double code(double x, double y, double z, double a) {
return 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 = a
end function
public static double code(double x, double y, double z, double a) {
return a;
}
def code(x, y, z, a): return a
function code(x, y, z, a) return a end
function tmp = code(x, y, z, a) tmp = a; end
code[x_, y_, z_, a_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 76.8%
Taylor expanded in a around 0 36.1%
Taylor expanded in a around inf 3.4%
neg-mul-13.4%
Simplified3.4%
add-sqr-sqrt2.5%
sqrt-unprod4.7%
sqr-neg4.7%
sqrt-unprod2.5%
add-sqr-sqrt3.3%
*-un-lft-identity3.3%
Applied egg-rr3.3%
*-lft-identity3.3%
Simplified3.3%
herbie shell --seed 2024137
(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))))