
(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 16 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 (+ (- (/ (+ (tan y) (tan z)) (- 1.0 (+ -1.0 (+ 2.0 (fma (tan y) (tan z) -1.0))))) (tan a)) x))
double code(double x, double y, double z, double a) {
return (((tan(y) + tan(z)) / (1.0 - (-1.0 + (2.0 + fma(tan(y), tan(z), -1.0))))) - tan(a)) + x;
}
function code(x, y, z, a) return Float64(Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(-1.0 + Float64(2.0 + fma(tan(y), tan(z), -1.0))))) - tan(a)) + x) end
code[x_, y_, z_, a_] := N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(-1.0 + N[(2.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\tan y + \tan z}{1 - \left(-1 + \left(2 + \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)\right)} - \tan a\right) + x
\end{array}
Initial program 77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.4%
tan-sum99.5%
div-inv99.4%
fma-define99.5%
neg-mul-199.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.4%
fma-undefine99.4%
neg-mul-199.4%
associate-+r+99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
expm1-log1p-u94.5%
expm1-undefine94.5%
log1p-undefine94.5%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
expm1-log1p-u94.5%
expm1-undefine94.5%
log1p-undefine94.6%
add-exp-log99.6%
Applied egg-rr99.6%
sub-neg99.6%
associate-+r+99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -0.04)
(sqrt (pow (- (tan (+ y z)) (- (tan a) x)) 2.0))
(if (<= (tan a) 6e-18)
(+ x (- (/ t_0 (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.04) {
tmp = sqrt(pow((tan((y + z)) - (tan(a) - x)), 2.0));
} else if (tan(a) <= 6e-18) {
tmp = x + ((t_0 / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (t_0 - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if (tan(a) <= (-0.04d0)) then
tmp = sqrt(((tan((y + z)) - (tan(a) - x)) ** 2.0d0))
else if (tan(a) <= 6d-18) then
tmp = x + ((t_0 / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (t_0 - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) + Math.tan(z);
double tmp;
if (Math.tan(a) <= -0.04) {
tmp = Math.sqrt(Math.pow((Math.tan((y + z)) - (Math.tan(a) - x)), 2.0));
} else if (Math.tan(a) <= 6e-18) {
tmp = x + ((t_0 / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if math.tan(a) <= -0.04: tmp = math.sqrt(math.pow((math.tan((y + z)) - (math.tan(a) - x)), 2.0)) elif math.tan(a) <= 6e-18: tmp = x + ((t_0 / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.04) tmp = sqrt((Float64(tan(Float64(y + z)) - Float64(tan(a) - x)) ^ 2.0)); elseif (tan(a) <= 6e-18) tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(t_0 - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(y) + tan(z); tmp = 0.0; if (tan(a) <= -0.04) tmp = sqrt(((tan((y + z)) - (tan(a) - x)) ^ 2.0)); elseif (tan(a) <= 6e-18) tmp = x + ((t_0 / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.04], N[Sqrt[N[Power[N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Tan[a], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 6e-18], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.04:\\
\;\;\;\;\sqrt{{\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{2}}\\
\mathbf{elif}\;\tan a \leq 6 \cdot 10^{-18}:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0400000000000000008Initial program 76.1%
add-sqr-sqrt75.5%
sqrt-unprod76.6%
pow276.6%
+-commutative76.6%
associate-+l-76.4%
Applied egg-rr76.4%
if -0.0400000000000000008 < (tan.f64 a) < 5.99999999999999966e-18Initial program 77.5%
Taylor expanded in a around 0 77.5%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 5.99999999999999966e-18 < (tan.f64 a) Initial program 78.7%
+-commutative78.7%
sub-neg78.7%
associate-+l+78.4%
tan-sum99.0%
div-inv99.0%
fma-define99.0%
neg-mul-199.0%
fma-define99.0%
Applied egg-rr99.0%
fma-undefine99.0%
fma-undefine99.0%
neg-mul-199.0%
associate-+r+99.2%
unsub-neg99.2%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
expm1-log1p-u96.6%
expm1-undefine96.6%
log1p-undefine96.7%
add-exp-log99.3%
Applied egg-rr99.3%
associate--l+99.2%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 79.1%
Final simplification87.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -5e-8)
(sqrt (pow (- (tan (+ y z)) (- (tan a) x)) 2.0))
(if (<= (tan a) 6e-18)
(+ 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) <= -5e-8) {
tmp = sqrt(pow((tan((y + z)) - (tan(a) - x)), 2.0));
} else if (tan(a) <= 6e-18) {
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) <= (-5d-8)) then
tmp = sqrt(((tan((y + z)) - (tan(a) - x)) ** 2.0d0))
else if (tan(a) <= 6d-18) 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) <= -5e-8) {
tmp = Math.sqrt(Math.pow((Math.tan((y + z)) - (Math.tan(a) - x)), 2.0));
} else if (Math.tan(a) <= 6e-18) {
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) <= -5e-8: tmp = math.sqrt(math.pow((math.tan((y + z)) - (math.tan(a) - x)), 2.0)) elif math.tan(a) <= 6e-18: 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) <= -5e-8) tmp = sqrt((Float64(tan(Float64(y + z)) - Float64(tan(a) - x)) ^ 2.0)); elseif (tan(a) <= 6e-18) 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) <= -5e-8) tmp = sqrt(((tan((y + z)) - (tan(a) - x)) ^ 2.0)); elseif (tan(a) <= 6e-18) 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], -5e-8], N[Sqrt[N[Power[N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[Tan[a], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 6e-18], 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 -5 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{{\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{2}}\\
\mathbf{elif}\;\tan a \leq 6 \cdot 10^{-18}:\\
\;\;\;\;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) < -4.9999999999999998e-8Initial program 76.9%
add-sqr-sqrt76.3%
sqrt-unprod77.3%
pow277.3%
+-commutative77.3%
associate-+l-77.1%
Applied egg-rr77.1%
if -4.9999999999999998e-8 < (tan.f64 a) < 5.99999999999999966e-18Initial program 77.1%
log1p-expm1-u77.1%
Applied egg-rr77.1%
+-commutative77.1%
log1p-expm1-u77.1%
associate--r-77.1%
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.6%
neg-mul-199.6%
Simplified99.6%
if 5.99999999999999966e-18 < (tan.f64 a) Initial program 78.7%
+-commutative78.7%
sub-neg78.7%
associate-+l+78.4%
tan-sum99.0%
div-inv99.0%
fma-define99.0%
neg-mul-199.0%
fma-define99.0%
Applied egg-rr99.0%
fma-undefine99.0%
fma-undefine99.0%
neg-mul-199.0%
associate-+r+99.2%
unsub-neg99.2%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
expm1-log1p-u96.6%
expm1-undefine96.6%
log1p-undefine96.7%
add-exp-log99.3%
Applied egg-rr99.3%
associate--l+99.2%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 79.1%
Final simplification87.6%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (+ 1.0 (- -1.0 (fma (tan y) (tan z) -1.0)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 + (-1.0 - fma(tan(y), tan(z), -1.0)))) - tan(a));
}
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 + Float64(-1.0 - fma(tan(y), tan(z), -1.0)))) - 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] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 + \left(-1 - \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)} - \tan a\right)
\end{array}
Initial program 77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.4%
tan-sum99.5%
div-inv99.4%
fma-define99.5%
neg-mul-199.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.4%
fma-undefine99.4%
neg-mul-199.4%
associate-+r+99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
expm1-log1p-u94.5%
expm1-undefine94.5%
log1p-undefine94.5%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(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 77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.4%
tan-sum99.5%
div-inv99.4%
fma-define99.5%
neg-mul-199.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.4%
fma-undefine99.4%
neg-mul-199.4%
associate-+r+99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
expm1-log1p-u94.5%
expm1-undefine94.5%
log1p-undefine94.5%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate--r+99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
sub0-neg99.6%
Simplified99.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 77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.4%
tan-sum99.5%
div-inv99.4%
fma-define99.5%
neg-mul-199.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.4%
fma-undefine99.4%
neg-mul-199.4%
associate-+r+99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
(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 77.5%
+-commutative77.5%
sub-neg77.5%
associate-+l+77.4%
tan-sum99.5%
div-inv99.4%
fma-define99.5%
neg-mul-199.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.4%
fma-undefine99.4%
neg-mul-199.4%
associate-+r+99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
expm1-log1p-u94.5%
expm1-undefine94.5%
log1p-undefine94.5%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 77.6%
Final simplification77.6%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.000115) (not (<= a 9.8e-6))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.000115) || !(a <= 9.8e-6)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-0.000115d0)) .or. (.not. (a <= 9.8d-6))) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.000115) || !(a <= 9.8e-6)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.000115) or not (a <= 9.8e-6): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.000115) || !(a <= 9.8e-6)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.000115) || ~((a <= 9.8e-6))) tmp = x + (tan(y) - tan(a)); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.000115], N[Not[LessEqual[a, 9.8e-6]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000115 \lor \neg \left(a \leq 9.8 \cdot 10^{-6}\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.15e-4 or 9.79999999999999934e-6 < a Initial program 77.4%
Taylor expanded in y around inf 63.3%
if -1.15e-4 < a < 9.79999999999999934e-6Initial program 77.7%
Taylor expanded in a around 0 77.7%
Final simplification69.8%
(FPCore (x y z a) :precision binary64 (if (<= a -1.25) (pow (sqrt x) 2.0) (if (<= a 7.8) (+ x (- (tan (+ y z)) a)) (pow (cbrt x) 3.0))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.25) {
tmp = pow(sqrt(x), 2.0);
} else if (a <= 7.8) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = pow(cbrt(x), 3.0);
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.25) {
tmp = Math.pow(Math.sqrt(x), 2.0);
} else if (a <= 7.8) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = Math.pow(Math.cbrt(x), 3.0);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -1.25) tmp = sqrt(x) ^ 2.0; elseif (a <= 7.8) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = cbrt(x) ^ 3.0; end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.25], N[Power[N[Sqrt[x], $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[a, 7.8], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[x, 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.25:\\
\;\;\;\;{\left(\sqrt{x}\right)}^{2}\\
\mathbf{elif}\;a \leq 7.8:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{x}\right)}^{3}\\
\end{array}
\end{array}
if a < -1.25Initial program 76.2%
add-sqr-sqrt67.3%
pow267.3%
+-commutative67.3%
associate-+l-67.2%
Applied egg-rr67.2%
Taylor expanded in x around inf 19.9%
if -1.25 < a < 7.79999999999999982Initial program 78.0%
Taylor expanded in a around 0 77.2%
if 7.79999999999999982 < a Initial program 77.8%
add-cube-cbrt76.4%
pow376.3%
+-commutative76.3%
associate-+l-76.3%
Applied egg-rr76.3%
Taylor expanded in x around inf 22.3%
(FPCore (x y z a) :precision binary64 (if (<= a -1.55) x (if (<= a 1.55) (+ x (- (tan (+ y z)) a)) (pow (cbrt x) 3.0))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 1.55) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = pow(cbrt(x), 3.0);
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 1.55) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = Math.pow(Math.cbrt(x), 3.0);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -1.55) tmp = x; elseif (a <= 1.55) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = cbrt(x) ^ 3.0; end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.55], x, If[LessEqual[a, 1.55], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[x, 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{x}\right)}^{3}\\
\end{array}
\end{array}
if a < -1.55000000000000004Initial program 76.2%
Taylor expanded in x around inf 19.9%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 78.0%
Taylor expanded in a around 0 77.2%
if 1.55000000000000004 < a Initial program 77.8%
add-cube-cbrt76.4%
pow376.3%
+-commutative76.3%
associate-+l-76.3%
Applied egg-rr76.3%
Taylor expanded in x around inf 22.3%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -2e-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) <= -2e-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) <= (-2d-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) <= -2e-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) <= -2e-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) <= -2e-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) <= -2e-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], -2e-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 -2 \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) < -2.0000000000000001e-13Initial program 72.9%
Taylor expanded in y around inf 51.1%
if -2.0000000000000001e-13 < (+.f64 y z) Initial program 80.4%
Taylor expanded in y around 0 65.6%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 77.5%
(FPCore (x y z a)
:precision binary64
(if (<= a -2.2e-6)
x
(if (<= a -1.55e-235)
(+ x (- (tan y) a))
(if (<= a 7.8) (+ x (- (tan z) a)) x))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2e-6) {
tmp = x;
} else if (a <= -1.55e-235) {
tmp = x + (tan(y) - a);
} else if (a <= 7.8) {
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 <= (-2.2d-6)) then
tmp = x
else if (a <= (-1.55d-235)) then
tmp = x + (tan(y) - a)
else if (a <= 7.8d0) 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 <= -2.2e-6) {
tmp = x;
} else if (a <= -1.55e-235) {
tmp = x + (Math.tan(y) - a);
} else if (a <= 7.8) {
tmp = x + (Math.tan(z) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -2.2e-6: tmp = x elif a <= -1.55e-235: tmp = x + (math.tan(y) - a) elif a <= 7.8: tmp = x + (math.tan(z) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -2.2e-6) tmp = x; elseif (a <= -1.55e-235) tmp = Float64(x + Float64(tan(y) - a)); elseif (a <= 7.8) 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 <= -2.2e-6) tmp = x; elseif (a <= -1.55e-235) tmp = x + (tan(y) - a); elseif (a <= 7.8) tmp = x + (tan(z) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -2.2e-6], x, If[LessEqual[a, -1.55e-235], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7.8], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1.55 \cdot 10^{-235}:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{elif}\;a \leq 7.8:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.2000000000000001e-6 or 7.79999999999999982 < a Initial program 77.2%
Taylor expanded in x around inf 21.3%
if -2.2000000000000001e-6 < a < -1.55e-235Initial program 79.4%
Taylor expanded in a around 0 79.4%
Taylor expanded in y around inf 67.7%
if -1.55e-235 < a < 7.79999999999999982Initial program 77.0%
Taylor expanded in a around 0 75.7%
Taylor expanded in y around 0 56.8%
(FPCore (x y z a) :precision binary64 (if (<= a -1.7) x (if (<= a 7.8) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.7) {
tmp = x;
} else if (a <= 7.8) {
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.7d0)) then
tmp = x
else if (a <= 7.8d0) 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.7) {
tmp = x;
} else if (a <= 7.8) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.7: tmp = x elif a <= 7.8: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.7) tmp = x; elseif (a <= 7.8) 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.7) tmp = x; elseif (a <= 7.8) tmp = x + (tan((y + z)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.7], x, If[LessEqual[a, 7.8], 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.7:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 7.8:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.69999999999999996 or 7.79999999999999982 < a Initial program 77.1%
Taylor expanded in x around inf 21.2%
if -1.69999999999999996 < a < 7.79999999999999982Initial program 78.0%
Taylor expanded in a around 0 77.2%
(FPCore (x y z a) :precision binary64 (if (<= a -2.2e-6) x (if (<= a 7.8) (+ x (- (tan y) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2e-6) {
tmp = x;
} else if (a <= 7.8) {
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 <= (-2.2d-6)) then
tmp = x
else if (a <= 7.8d0) 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 <= -2.2e-6) {
tmp = x;
} else if (a <= 7.8) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -2.2e-6: tmp = x elif a <= 7.8: tmp = x + (math.tan(y) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -2.2e-6) tmp = x; elseif (a <= 7.8) 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 <= -2.2e-6) tmp = x; elseif (a <= 7.8) tmp = x + (tan(y) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -2.2e-6], x, If[LessEqual[a, 7.8], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 7.8:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.2000000000000001e-6 or 7.79999999999999982 < a Initial program 77.2%
Taylor expanded in x around inf 21.3%
if -2.2000000000000001e-6 < a < 7.79999999999999982Initial program 77.8%
Taylor expanded in a around 0 77.0%
Taylor expanded in y around inf 59.9%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 77.5%
Taylor expanded in x around inf 30.3%
herbie shell --seed 2024132
(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))))