
(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 (* (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 80.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 80.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
(let* ((t_0 (tan (+ y z))))
(if (<= a -0.15)
(+ x (+ t_0 (/ -1.0 (/ (cos a) (sin a)))))
(if (<= a 6.5e-19)
(+ x (- (/ 1.0 (/ (- 1.0 (* (tan y) (tan z))) (+ (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 + z));
double tmp;
if (a <= -0.15) {
tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a))));
} else if (a <= 6.5e-19) {
tmp = x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (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 + z))
if (a <= (-0.15d0)) then
tmp = x + (t_0 + ((-1.0d0) / (cos(a) / sin(a))))
else if (a <= 6.5d-19) then
tmp = x + ((1.0d0 / ((1.0d0 - (tan(y) * tan(z))) / (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 + z));
double tmp;
if (a <= -0.15) {
tmp = x + (t_0 + (-1.0 / (Math.cos(a) / Math.sin(a))));
} else if (a <= 6.5e-19) {
tmp = x + ((1.0 / ((1.0 - (Math.tan(y) * Math.tan(z))) / (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 + z)) tmp = 0 if a <= -0.15: tmp = x + (t_0 + (-1.0 / (math.cos(a) / math.sin(a)))) elif a <= 6.5e-19: tmp = x + ((1.0 / ((1.0 - (math.tan(y) * math.tan(z))) / (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 = tan(Float64(y + z)) tmp = 0.0 if (a <= -0.15) tmp = Float64(x + Float64(t_0 + Float64(-1.0 / Float64(cos(a) / sin(a))))); elseif (a <= 6.5e-19) 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(t_0 - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (a <= -0.15) tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a)))); elseif (a <= 6.5e-19) tmp = x + ((1.0 / ((1.0 - (tan(y) * tan(z))) / (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[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[a, -0.15], N[(x + N[(t$95$0 + N[(-1.0 / N[(N[Cos[a], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.5e-19], 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[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;a \leq -0.15:\\
\;\;\;\;x + \left(t\_0 + \frac{-1}{\frac{\cos a}{\sin a}}\right)\\
\mathbf{elif}\;a \leq 6.5 \cdot 10^{-19}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1 - \tan y \cdot \tan z}{\tan y + \tan z}} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if a < -0.149999999999999994Initial program 76.3%
tan-quot76.2%
clear-num76.3%
Applied egg-rr76.3%
if -0.149999999999999994 < a < 6.5000000000000001e-19Initial program 81.7%
Taylor expanded in a around 0 81.7%
tan-sum99.8%
clear-num99.8%
Applied egg-rr99.4%
if 6.5000000000000001e-19 < a Initial program 81.7%
Final simplification89.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= a -0.15)
(+ x (+ t_0 (/ -1.0 (/ (cos a) (sin a)))))
(if (<= a 6.5e-19)
(+ x (- (/ (+ (tan y) (tan z)) (- 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 + z));
double tmp;
if (a <= -0.15) {
tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a))));
} else if (a <= 6.5e-19) {
tmp = x + (((tan(y) + tan(z)) / (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 + z))
if (a <= (-0.15d0)) then
tmp = x + (t_0 + ((-1.0d0) / (cos(a) / sin(a))))
else if (a <= 6.5d-19) then
tmp = x + (((tan(y) + tan(z)) / (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 + z));
double tmp;
if (a <= -0.15) {
tmp = x + (t_0 + (-1.0 / (Math.cos(a) / Math.sin(a))));
} else if (a <= 6.5e-19) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (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 + z)) tmp = 0 if a <= -0.15: tmp = x + (t_0 + (-1.0 / (math.cos(a) / math.sin(a)))) elif a <= 6.5e-19: tmp = x + (((math.tan(y) + math.tan(z)) / (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 = tan(Float64(y + z)) tmp = 0.0 if (a <= -0.15) tmp = Float64(x + Float64(t_0 + Float64(-1.0 / Float64(cos(a) / sin(a))))); elseif (a <= 6.5e-19) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / 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 + z)); tmp = 0.0; if (a <= -0.15) tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a)))); elseif (a <= 6.5e-19) tmp = x + (((tan(y) + tan(z)) / (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[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[a, -0.15], N[(x + N[(t$95$0 + N[(-1.0 / N[(N[Cos[a], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.5e-19], 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[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;a \leq -0.15:\\
\;\;\;\;x + \left(t\_0 + \frac{-1}{\frac{\cos a}{\sin a}}\right)\\
\mathbf{elif}\;a \leq 6.5 \cdot 10^{-19}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if a < -0.149999999999999994Initial program 76.3%
tan-quot76.2%
clear-num76.3%
Applied egg-rr76.3%
if -0.149999999999999994 < a < 6.5000000000000001e-19Initial program 81.7%
Taylor expanded in a around 0 81.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-undefine99.4%
unsub-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if 6.5000000000000001e-19 < a Initial program 81.7%
Final simplification89.0%
(FPCore (x y z a) :precision binary64 (+ x (+ (tan (+ y z)) (/ -1.0 (/ (cos a) (sin a))))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) + (-1.0 / (cos(a) / sin(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)) + ((-1.0d0) / (cos(a) / sin(a))))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) + (-1.0 / (Math.cos(a) / Math.sin(a))));
}
def code(x, y, z, a): return x + (math.tan((y + z)) + (-1.0 / (math.cos(a) / math.sin(a))))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) + Float64(-1.0 / Float64(cos(a) / sin(a))))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) + (-1.0 / (cos(a) / sin(a)))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(-1.0 / N[(N[Cos[a], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) + \frac{-1}{\frac{\cos a}{\sin a}}\right)
\end{array}
Initial program 80.3%
tan-quot80.2%
clear-num80.3%
Applied egg-rr80.3%
Final simplification80.3%
(FPCore (x y z a) :precision binary64 (if (<= a -0.14) x (if (<= a 1.58) (+ x (- (tan (+ y z)) a)) (cbrt (pow x 3.0)))))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.14) {
tmp = x;
} else if (a <= 1.58) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = cbrt(pow(x, 3.0));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.14) {
tmp = x;
} else if (a <= 1.58) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = Math.cbrt(Math.pow(x, 3.0));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (a <= -0.14) tmp = x; elseif (a <= 1.58) 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, -0.14], x, If[LessEqual[a, 1.58], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[x, 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.14:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.58:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x}^{3}}\\
\end{array}
\end{array}
if a < -0.14000000000000001Initial program 75.4%
Taylor expanded in x around inf 21.9%
if -0.14000000000000001 < a < 1.5800000000000001Initial program 82.7%
Taylor expanded in a around 0 82.7%
if 1.5800000000000001 < a Initial program 80.5%
add-cbrt-cube80.0%
pow380.1%
+-commutative80.1%
associate-+l-80.0%
Applied egg-rr80.0%
Taylor expanded in x around inf 23.6%
Final simplification53.1%
(FPCore (x y z a) :precision binary64 (+ x (+ (tan a) (tan (+ y z)))))
double code(double x, double y, double z, double a) {
return x + (tan(a) + tan((y + z)));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan(a) + tan((y + z)))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan(a) + Math.tan((y + z)));
}
def code(x, y, z, a): return x + (math.tan(a) + math.tan((y + z)))
function code(x, y, z, a) return Float64(x + Float64(tan(a) + tan(Float64(y + z)))) end
function tmp = code(x, y, z, a) tmp = x + (tan(a) + tan((y + z))); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[a], $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan a + \tan \left(y + z\right)\right)
\end{array}
Initial program 80.3%
sub-neg80.3%
Applied egg-rr80.3%
rem-square-sqrt40.0%
fabs-sqr40.0%
rem-square-sqrt65.6%
fabs-neg65.6%
rem-square-sqrt25.7%
fabs-sqr25.7%
rem-square-sqrt51.6%
+-commutative51.6%
Simplified51.6%
Final simplification51.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 80.3%
Final simplification80.3%
(FPCore (x y z a) :precision binary64 (if (<= a -0.14) 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 <= -0.14) {
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 <= (-0.14d0)) 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 <= -0.14) {
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 <= -0.14: 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 <= -0.14) 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 <= -0.14) 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, -0.14], 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 -0.14:\\
\;\;\;\;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 < -0.14000000000000001 or 1.5800000000000001 < a Initial program 77.7%
Taylor expanded in x around inf 22.7%
if -0.14000000000000001 < a < 1.5800000000000001Initial program 82.7%
Taylor expanded in a around 0 82.7%
Final simplification53.1%
(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 80.3%
Taylor expanded in x around inf 33.1%
Final simplification33.1%
herbie shell --seed 2024059
(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))))