
(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
(-
(/
1.0
(/
(- 1.0 (/ (* (sin z) (sin y)) (* (cos z) (cos y))))
(+ (tan y) (tan z))))
(tan a))))
double code(double x, double y, double z, double a) {
return x + ((1.0 / ((1.0 - ((sin(z) * sin(y)) / (cos(z) * cos(y)))) / (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 + ((1.0d0 / ((1.0d0 - ((sin(z) * sin(y)) / (cos(z) * cos(y)))) / (tan(y) + tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((1.0 / ((1.0 - ((Math.sin(z) * Math.sin(y)) / (Math.cos(z) * Math.cos(y)))) / (Math.tan(y) + Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + ((1.0 / ((1.0 - ((math.sin(z) * math.sin(y)) / (math.cos(z) * math.cos(y)))) / (math.tan(y) + math.tan(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 - Float64(Float64(sin(z) * sin(y)) / Float64(cos(z) * cos(y)))) / Float64(tan(y) + tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((1.0 / ((1.0 - ((sin(z) * sin(y)) / (cos(z) * cos(y)))) / (tan(y) + tan(z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(1.0 / N[(N[(1.0 - N[(N[(N[Sin[z], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[z], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{1}{\frac{1 - \frac{\sin z \cdot \sin y}{\cos z \cdot \cos y}}{\tan y + \tan z}} - \tan a\right)
\end{array}
Initial program 79.3%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
*-commutative99.7%
tan-quot99.7%
tan-quot99.7%
frac-times99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ 1.0 (/ (- 1.0 (* (tan y) (tan z))) (+ (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (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 + ((1.0d0 / ((1.0d0 - (tan(y) * tan(z))) / (tan(y) + tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((1.0 / ((1.0 - (Math.tan(y) * Math.tan(z))) / (Math.tan(y) + Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + ((1.0 / ((1.0 - (math.tan(y) * math.tan(z))) / (math.tan(y) + math.tan(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 - Float64(tan(y) * tan(z))) / Float64(tan(y) + tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (tan(y) + tan(z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(1.0 / N[(N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{1}{\frac{1 - \tan y \cdot \tan z}{\tan y + \tan z}} - \tan a\right)
\end{array}
Initial program 79.3%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
Final simplification99.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 79.3%
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 (<= a -0.00034)
(+ x (- (tan (+ z y)) (tan a)))
(if (<= a 0.175)
(+ x (- (/ 1.0 (/ (- 1.0 (* (tan y) (tan z))) (+ (tan y) (tan z)))) a))
(+ x (- (/ 1.0 (/ (cos (+ z y)) (sin (+ z y)))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.00034) {
tmp = x + (tan((z + y)) - tan(a));
} else if (a <= 0.175) {
tmp = x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (tan(y) + tan(z)))) - a);
} else {
tmp = x + ((1.0 / (cos((z + y)) / sin((z + 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 (a <= (-0.00034d0)) then
tmp = x + (tan((z + y)) - tan(a))
else if (a <= 0.175d0) then
tmp = x + ((1.0d0 / ((1.0d0 - (tan(y) * tan(z))) / (tan(y) + tan(z)))) - a)
else
tmp = x + ((1.0d0 / (cos((z + y)) / sin((z + y)))) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.00034) {
tmp = x + (Math.tan((z + y)) - Math.tan(a));
} else if (a <= 0.175) {
tmp = x + ((1.0 / ((1.0 - (Math.tan(y) * Math.tan(z))) / (Math.tan(y) + Math.tan(z)))) - a);
} else {
tmp = x + ((1.0 / (Math.cos((z + y)) / Math.sin((z + y)))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -0.00034: tmp = x + (math.tan((z + y)) - math.tan(a)) elif a <= 0.175: tmp = x + ((1.0 / ((1.0 - (math.tan(y) * math.tan(z))) / (math.tan(y) + math.tan(z)))) - a) else: tmp = x + ((1.0 / (math.cos((z + y)) / math.sin((z + y)))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -0.00034) tmp = Float64(x + Float64(tan(Float64(z + y)) - tan(a))); elseif (a <= 0.175) tmp = Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 - Float64(tan(y) * tan(z))) / Float64(tan(y) + tan(z)))) - a)); else tmp = Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(z + y)) / sin(Float64(z + y)))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -0.00034) tmp = x + (tan((z + y)) - tan(a)); elseif (a <= 0.175) tmp = x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (tan(y) + tan(z)))) - a); else tmp = x + ((1.0 / (cos((z + y)) / sin((z + y)))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -0.00034], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.175], N[(x + N[(N[(1.0 / N[(N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00034:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 0.175:\\
\;\;\;\;x + \left(\frac{1}{\frac{1 - \tan y \cdot \tan z}{\tan y + \tan z}} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\frac{\cos \left(z + y\right)}{\sin \left(z + y\right)}} - \tan a\right)\\
\end{array}
\end{array}
if a < -3.4e-4Initial program 77.9%
if -3.4e-4 < a < 0.17499999999999999Initial program 80.9%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in a around 0 99.1%
if 0.17499999999999999 < a Initial program 76.7%
tan-quot76.8%
clear-num76.8%
Applied egg-rr76.8%
Final simplification89.0%
(FPCore (x y z a)
:precision binary64
(if (<= a -0.000165)
(+ x (- (tan (+ z y)) (tan a)))
(if (<= a 0.175)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- (/ 1.0 (/ (cos (+ z y)) (sin (+ z y)))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.000165) {
tmp = x + (tan((z + y)) - tan(a));
} else if (a <= 0.175) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + ((1.0 / (cos((z + y)) / sin((z + 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 (a <= (-0.000165d0)) then
tmp = x + (tan((z + y)) - tan(a))
else if (a <= 0.175d0) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + ((1.0d0 / (cos((z + y)) / sin((z + y)))) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.000165) {
tmp = x + (Math.tan((z + y)) - Math.tan(a));
} else if (a <= 0.175) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + ((1.0 / (Math.cos((z + y)) / Math.sin((z + y)))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -0.000165: tmp = x + (math.tan((z + y)) - math.tan(a)) elif a <= 0.175: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + ((1.0 / (math.cos((z + y)) / math.sin((z + y)))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -0.000165) tmp = Float64(x + Float64(tan(Float64(z + y)) - tan(a))); elseif (a <= 0.175) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(z + y)) / sin(Float64(z + y)))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -0.000165) tmp = x + (tan((z + y)) - tan(a)); elseif (a <= 0.175) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + ((1.0 / (cos((z + y)) / sin((z + y)))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -0.000165], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.175], 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] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000165:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 0.175:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\frac{\cos \left(z + y\right)}{\sin \left(z + y\right)}} - \tan a\right)\\
\end{array}
\end{array}
if a < -1.65e-4Initial program 77.9%
if -1.65e-4 < a < 0.17499999999999999Initial program 80.9%
Taylor expanded in a around 0 80.7%
tan-sum99.1%
*-un-lft-identity99.1%
associate-*l/99.1%
*-commutative99.1%
fma-neg99.1%
Applied egg-rr99.1%
fma-undefine99.1%
*-commutative99.1%
unsub-neg99.1%
associate-*l/99.1%
*-lft-identity99.1%
Simplified99.1%
if 0.17499999999999999 < a Initial program 76.7%
tan-quot76.8%
clear-num76.8%
Applied egg-rr76.8%
Final simplification89.0%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.6) (not (<= a 4.7))) (+ x (/ (sin y) (cos y))) (+ x (- (tan (+ z y)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.6) || !(a <= 4.7)) {
tmp = x + (sin(y) / cos(y));
} else {
tmp = x + (tan((z + y)) - 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.6d0)) .or. (.not. (a <= 4.7d0))) then
tmp = x + (sin(y) / cos(y))
else
tmp = x + (tan((z + y)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.6) || !(a <= 4.7)) {
tmp = x + (Math.sin(y) / Math.cos(y));
} else {
tmp = x + (Math.tan((z + y)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -1.6) or not (a <= 4.7): tmp = x + (math.sin(y) / math.cos(y)) else: tmp = x + (math.tan((z + y)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.6) || !(a <= 4.7)) tmp = Float64(x + Float64(sin(y) / cos(y))); else tmp = Float64(x + Float64(tan(Float64(z + y)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -1.6) || ~((a <= 4.7))) tmp = x + (sin(y) / cos(y)); else tmp = x + (tan((z + y)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.6], N[Not[LessEqual[a, 4.7]], $MachinePrecision]], N[(x + N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \lor \neg \left(a \leq 4.7\right):\\
\;\;\;\;x + \frac{\sin y}{\cos y}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\end{array}
\end{array}
if a < -1.6000000000000001 or 4.70000000000000018 < a Initial program 77.2%
+-commutative77.2%
sub-neg77.2%
associate-+l+77.0%
tan-quot77.0%
div-inv77.0%
fma-define77.0%
neg-mul-177.0%
fma-define77.0%
Applied egg-rr77.0%
fma-undefine77.0%
associate-*r/77.0%
*-rgt-identity77.0%
+-commutative77.0%
+-commutative77.0%
fma-undefine77.0%
neg-mul-177.0%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt54.5%
fabs-neg54.5%
rem-square-sqrt9.7%
fabs-sqr9.7%
rem-square-sqrt21.7%
+-commutative21.7%
Simplified21.7%
Taylor expanded in z around 0 21.6%
associate-+r+21.6%
Simplified21.6%
Taylor expanded in a around 0 23.2%
+-commutative23.2%
Simplified23.2%
if -1.6000000000000001 < a < 4.70000000000000018Initial program 81.0%
Taylor expanded in a around 0 80.5%
Final simplification54.1%
(FPCore (x y z a) :precision binary64 (+ x (+ (tan a) (tan (+ z y)))))
double code(double x, double y, double z, double a) {
return x + (tan(a) + tan((z + y)));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan(a) + tan((z + y)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan(a) + Math.tan((z + y)));
}
def code(x, y, z, a): return x + (math.tan(a) + math.tan((z + y)))
function code(x, y, z, a) return Float64(x + Float64(tan(a) + tan(Float64(z + y)))) end
function tmp = code(x, y, z, a) tmp = x + (tan(a) + tan((z + y))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[a], $MachinePrecision] + N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan a + \tan \left(z + y\right)\right)
\end{array}
Initial program 79.3%
sub-neg79.3%
Applied egg-rr79.3%
+-commutative79.3%
rem-square-sqrt41.8%
fabs-sqr41.8%
rem-square-sqrt68.6%
fabs-neg68.6%
rem-square-sqrt26.8%
fabs-sqr26.8%
rem-square-sqrt52.6%
Simplified52.6%
Final simplification52.6%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ z y)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((z + 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((z + y)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((z + y)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((z + y)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(z + y)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((z + y)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(z + y\right) - \tan a\right)
\end{array}
Initial program 79.3%
Final simplification79.3%
(FPCore (x y z a) :precision binary64 (if (<= a -7.8) x (if (<= a 0.17) (+ x (- (tan (+ z y)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -7.8) {
tmp = x;
} else if (a <= 0.17) {
tmp = x + (tan((z + 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 <= (-7.8d0)) then
tmp = x
else if (a <= 0.17d0) then
tmp = x + (tan((z + 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 <= -7.8) {
tmp = x;
} else if (a <= 0.17) {
tmp = x + (Math.tan((z + y)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -7.8: tmp = x elif a <= 0.17: tmp = x + (math.tan((z + y)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -7.8) tmp = x; elseif (a <= 0.17) tmp = Float64(x + Float64(tan(Float64(z + y)) - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -7.8) tmp = x; elseif (a <= 0.17) tmp = x + (tan((z + y)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -7.8], x, If[LessEqual[a, 0.17], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.8:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 0.17:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -7.79999999999999982 or 0.170000000000000012 < a Initial program 76.5%
Taylor expanded in x around inf 22.6%
if -7.79999999999999982 < a < 0.170000000000000012Initial program 81.6%
Taylor expanded in a around 0 81.1%
Final simplification53.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 79.3%
Taylor expanded in x around inf 33.6%
Final simplification33.6%
herbie shell --seed 2024039
(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))))