
(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 12 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
(let* ((t_0 (* (tan y) (tan z))))
(+
x
(/
(+ (* (+ (tan y) (tan z)) (cos a)) (* (sin a) (+ t_0 -1.0)))
(* (cos a) (- 1.0 t_0))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) * tan(z);
return x + ((((tan(y) + tan(z)) * cos(a)) + (sin(a) * (t_0 + -1.0))) / (cos(a) * (1.0 - t_0)));
}
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
t_0 = tan(y) * tan(z)
code = x + ((((tan(y) + tan(z)) * cos(a)) + (sin(a) * (t_0 + (-1.0d0)))) / (cos(a) * (1.0d0 - t_0)))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) * Math.tan(z);
return x + ((((Math.tan(y) + Math.tan(z)) * Math.cos(a)) + (Math.sin(a) * (t_0 + -1.0))) / (Math.cos(a) * (1.0 - t_0)));
}
def code(x, y, z, a): t_0 = math.tan(y) * math.tan(z) return x + ((((math.tan(y) + math.tan(z)) * math.cos(a)) + (math.sin(a) * (t_0 + -1.0))) / (math.cos(a) * (1.0 - t_0)))
function code(x, y, z, a) t_0 = Float64(tan(y) * tan(z)) return Float64(x + Float64(Float64(Float64(Float64(tan(y) + tan(z)) * cos(a)) + Float64(sin(a) * Float64(t_0 + -1.0))) / Float64(cos(a) * Float64(1.0 - t_0)))) end
function tmp = code(x, y, z, a) t_0 = tan(y) * tan(z); tmp = x + ((((tan(y) + tan(z)) * cos(a)) + (sin(a) * (t_0 + -1.0))) / (cos(a) * (1.0 - t_0))); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y \cdot \tan z\\
x + \frac{\left(\tan y + \tan z\right) \cdot \cos a + \sin a \cdot \left(t\_0 + -1\right)}{\cos a \cdot \left(1 - t\_0\right)}
\end{array}
\end{array}
Initial program 76.2%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (/ (+ (tan y) (tan z)) (+ 1.0 (+ 1.0 (- -1.0 (* (tan y) (tan z)))))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(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) + tan(z)) / (1.0d0 + (1.0d0 + ((-1.0d0) - (tan(y) * tan(z)))))))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - ((Math.tan(y) + Math.tan(z)) / (1.0 + (1.0 + (-1.0 - (Math.tan(y) * Math.tan(z)))))));
}
def code(x, y, z, a): return x - (math.tan(a) - ((math.tan(y) + math.tan(z)) / (1.0 + (1.0 + (-1.0 - (math.tan(y) * math.tan(z)))))))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(y) + tan(z)) / Float64(1.0 + Float64(1.0 + Float64(-1.0 - Float64(tan(y) * tan(z)))))))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - ((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(z))))))); 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[(1.0 + N[(1.0 + N[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \frac{\tan y + \tan z}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)}\right)
\end{array}
Initial program 76.2%
tan-sum99.7%
tan-quot99.7%
frac-sub99.7%
Applied egg-rr99.7%
div-sub99.7%
times-frac99.7%
*-inverses99.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
expm1-log1p-u91.9%
expm1-udef91.9%
log1p-udef91.9%
add-exp-log99.7%
Applied egg-rr99.7%
distribute-frac-neg99.7%
tan-quot99.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 76.2%
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.00142)
(- (+ x t_0) (tan a))
(if (<= a 2.9e-12)
(+ 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.00142) {
tmp = (x + t_0) - tan(a);
} else if (a <= 2.9e-12) {
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.00142d0)) then
tmp = (x + t_0) - tan(a)
else if (a <= 2.9d-12) 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.00142) {
tmp = (x + t_0) - Math.tan(a);
} else if (a <= 2.9e-12) {
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.00142: tmp = (x + t_0) - math.tan(a) elif a <= 2.9e-12: 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.00142) tmp = Float64(Float64(x + t_0) - tan(a)); elseif (a <= 2.9e-12) 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.00142) tmp = (x + t_0) - tan(a); elseif (a <= 2.9e-12) 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.00142], N[(N[(x + t$95$0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.9e-12], 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.00142:\\
\;\;\;\;\left(x + t\_0\right) - \tan a\\
\mathbf{elif}\;a \leq 2.9 \cdot 10^{-12}:\\
\;\;\;\;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.00142000000000000004Initial program 76.6%
associate-+r-76.7%
+-commutative76.7%
Applied egg-rr76.7%
if -0.00142000000000000004 < a < 2.9000000000000002e-12Initial program 75.6%
tan-sum99.8%
tan-quot99.8%
frac-sub99.8%
Applied egg-rr99.8%
div-sub99.8%
times-frac99.8%
*-inverses99.8%
cancel-sign-sub-inv99.8%
Simplified99.8%
Taylor expanded in a around 0 99.8%
mul-1-neg99.8%
Simplified99.8%
if 2.9000000000000002e-12 < a Initial program 77.1%
Final simplification89.0%
(FPCore (x y z a) :precision binary64 (if (<= y -0.7) (exp (log x)) (if (<= y 3.8e-6) (+ x (- y (tan a))) (expm1 (log1p x)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = exp(log(x));
} else if (y <= 3.8e-6) {
tmp = x + (y - tan(a));
} else {
tmp = expm1(log1p(x));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = Math.exp(Math.log(x));
} else if (y <= 3.8e-6) {
tmp = x + (y - Math.tan(a));
} else {
tmp = Math.expm1(Math.log1p(x));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -0.7: tmp = math.exp(math.log(x)) elif y <= 3.8e-6: tmp = x + (y - math.tan(a)) else: tmp = math.expm1(math.log1p(x)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -0.7) tmp = exp(log(x)); elseif (y <= 3.8e-6) tmp = Float64(x + Float64(y - tan(a))); else tmp = expm1(log1p(x)); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[y, -0.7], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 3.8e-6], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.7:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
\end{array}
\end{array}
if y < -0.69999999999999996Initial program 61.9%
add-exp-log56.5%
+-commutative56.5%
associate-+l-56.5%
Applied egg-rr56.5%
Taylor expanded in x around inf 21.7%
mul-1-neg21.7%
log-rec21.7%
remove-double-neg21.7%
Simplified21.7%
if -0.69999999999999996 < y < 3.8e-6Initial program 99.8%
Taylor expanded in z around 0 61.3%
Taylor expanded in y around 0 61.0%
if 3.8e-6 < y Initial program 46.3%
add-exp-log44.2%
+-commutative44.2%
associate-+l-44.2%
Applied egg-rr44.2%
Taylor expanded in x around inf 22.5%
mul-1-neg22.5%
log-rec22.5%
remove-double-neg22.5%
Simplified22.5%
rem-exp-log22.5%
expm1-log1p-u22.5%
Applied egg-rr22.5%
Final simplification41.1%
(FPCore (x y z a) :precision binary64 (if (<= y -0.7) (exp (- (log (/ 1.0 x)))) (if (<= y 3.8e-6) (+ x (- y (tan a))) (expm1 (log1p x)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = exp(-log((1.0 / x)));
} else if (y <= 3.8e-6) {
tmp = x + (y - tan(a));
} else {
tmp = expm1(log1p(x));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = Math.exp(-Math.log((1.0 / x)));
} else if (y <= 3.8e-6) {
tmp = x + (y - Math.tan(a));
} else {
tmp = Math.expm1(Math.log1p(x));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -0.7: tmp = math.exp(-math.log((1.0 / x))) elif y <= 3.8e-6: tmp = x + (y - math.tan(a)) else: tmp = math.expm1(math.log1p(x)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -0.7) tmp = exp(Float64(-log(Float64(1.0 / x)))); elseif (y <= 3.8e-6) tmp = Float64(x + Float64(y - tan(a))); else tmp = expm1(log1p(x)); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[y, -0.7], N[Exp[(-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[y, 3.8e-6], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.7:\\
\;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
\end{array}
\end{array}
if y < -0.69999999999999996Initial program 61.9%
add-exp-log56.5%
+-commutative56.5%
associate-+l-56.5%
Applied egg-rr56.5%
Taylor expanded in x around inf 21.7%
if -0.69999999999999996 < y < 3.8e-6Initial program 99.8%
Taylor expanded in z around 0 61.3%
Taylor expanded in y around 0 61.0%
if 3.8e-6 < y Initial program 46.3%
add-exp-log44.2%
+-commutative44.2%
associate-+l-44.2%
Applied egg-rr44.2%
Taylor expanded in x around inf 22.5%
mul-1-neg22.5%
log-rec22.5%
remove-double-neg22.5%
Simplified22.5%
rem-exp-log22.5%
expm1-log1p-u22.5%
Applied egg-rr22.5%
Final simplification41.1%
(FPCore (x y z a) :precision binary64 (if (<= y -9.8e-6) (+ x (+ (tan y) (tan a))) (if (<= y 3.8e-6) (+ x (- y (tan a))) (expm1 (log1p x)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -9.8e-6) {
tmp = x + (tan(y) + tan(a));
} else if (y <= 3.8e-6) {
tmp = x + (y - tan(a));
} else {
tmp = expm1(log1p(x));
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -9.8e-6) {
tmp = x + (Math.tan(y) + Math.tan(a));
} else if (y <= 3.8e-6) {
tmp = x + (y - Math.tan(a));
} else {
tmp = Math.expm1(Math.log1p(x));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -9.8e-6: tmp = x + (math.tan(y) + math.tan(a)) elif y <= 3.8e-6: tmp = x + (y - math.tan(a)) else: tmp = math.expm1(math.log1p(x)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -9.8e-6) tmp = Float64(x + Float64(tan(y) + tan(a))); elseif (y <= 3.8e-6) tmp = Float64(x + Float64(y - tan(a))); else tmp = expm1(log1p(x)); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[y, -9.8e-6], N[(x + N[(N[Tan[y], $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e-6], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\tan y + \tan a\right)\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\
\end{array}
\end{array}
if y < -9.79999999999999934e-6Initial program 62.5%
Taylor expanded in z around 0 61.2%
tan-quot61.2%
sub-neg61.2%
tan-quot61.2%
distribute-frac-neg61.2%
add-sqr-sqrt26.4%
sqrt-unprod47.5%
sqr-neg47.5%
sqrt-unprod21.1%
add-sqr-sqrt40.0%
tan-quot40.0%
Applied egg-rr40.0%
if -9.79999999999999934e-6 < y < 3.8e-6Initial program 99.8%
Taylor expanded in z around 0 61.0%
Taylor expanded in y around 0 61.0%
if 3.8e-6 < y Initial program 46.3%
add-exp-log44.2%
+-commutative44.2%
associate-+l-44.2%
Applied egg-rr44.2%
Taylor expanded in x around inf 22.5%
mul-1-neg22.5%
log-rec22.5%
remove-double-neg22.5%
Simplified22.5%
rem-exp-log22.5%
expm1-log1p-u22.5%
Applied egg-rr22.5%
Final simplification45.5%
(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.2%
Final simplification76.2%
(FPCore (x y z a) :precision binary64 (if (<= y -0.7) (exp (log x)) (if (<= y 3.8e-6) (+ x (- y (tan a))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = exp(log(x));
} else if (y <= 3.8e-6) {
tmp = x + (y - tan(a));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-0.7d0)) then
tmp = exp(log(x))
else if (y <= 3.8d-6) then
tmp = x + (y - tan(a))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = Math.exp(Math.log(x));
} else if (y <= 3.8e-6) {
tmp = x + (y - Math.tan(a));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -0.7: tmp = math.exp(math.log(x)) elif y <= 3.8e-6: tmp = x + (y - math.tan(a)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -0.7) tmp = exp(log(x)); elseif (y <= 3.8e-6) tmp = Float64(x + Float64(y - tan(a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -0.7) tmp = exp(log(x)); elseif (y <= 3.8e-6) tmp = x + (y - tan(a)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -0.7], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 3.8e-6], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.7:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -0.69999999999999996Initial program 61.9%
add-exp-log56.5%
+-commutative56.5%
associate-+l-56.5%
Applied egg-rr56.5%
Taylor expanded in x around inf 21.7%
mul-1-neg21.7%
log-rec21.7%
remove-double-neg21.7%
Simplified21.7%
if -0.69999999999999996 < y < 3.8e-6Initial program 99.8%
Taylor expanded in z around 0 61.3%
Taylor expanded in y around 0 61.0%
if 3.8e-6 < y Initial program 46.3%
Taylor expanded in x around inf 22.5%
Final simplification41.1%
(FPCore (x y z a) :precision binary64 (+ x (- (tan y) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan(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(y) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan(y) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan(y) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(y) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan(y) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan y - \tan a\right)
\end{array}
Initial program 76.2%
Taylor expanded in z around 0 57.0%
tan-quot57.0%
expm1-log1p-u48.8%
expm1-udef48.8%
Applied egg-rr48.8%
expm1-def48.8%
expm1-log1p57.0%
Simplified57.0%
Final simplification57.0%
(FPCore (x y z a) :precision binary64 (if (<= y -0.7) x (if (<= y 3.8e-6) (+ x (- y (tan a))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = x;
} else if (y <= 3.8e-6) {
tmp = x + (y - tan(a));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-0.7d0)) then
tmp = x
else if (y <= 3.8d-6) then
tmp = x + (y - tan(a))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -0.7) {
tmp = x;
} else if (y <= 3.8e-6) {
tmp = x + (y - Math.tan(a));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -0.7: tmp = x elif y <= 3.8e-6: tmp = x + (y - math.tan(a)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -0.7) tmp = x; elseif (y <= 3.8e-6) tmp = Float64(x + Float64(y - tan(a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -0.7) tmp = x; elseif (y <= 3.8e-6) tmp = x + (y - tan(a)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -0.7], x, If[LessEqual[y, 3.8e-6], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.7:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -0.69999999999999996 or 3.8e-6 < y Initial program 53.7%
Taylor expanded in x around inf 22.1%
if -0.69999999999999996 < y < 3.8e-6Initial program 99.8%
Taylor expanded in z around 0 61.3%
Taylor expanded in y around 0 61.0%
Final simplification41.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 76.2%
Taylor expanded in x around inf 31.1%
Final simplification31.1%
herbie shell --seed 2024031
(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))))