
(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 15 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))))
(fma
(+ (* (+ (tan y) (tan z)) (cos a)) (* (sin a) (+ t_0 -1.0)))
(/ 1.0 (* (cos a) (- 1.0 t_0)))
x)))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) * tan(z);
return fma((((tan(y) + tan(z)) * cos(a)) + (sin(a) * (t_0 + -1.0))), (1.0 / (cos(a) * (1.0 - t_0))), x);
}
function code(x, y, z, a) t_0 = Float64(tan(y) * tan(z)) return fma(Float64(Float64(Float64(tan(y) + tan(z)) * cos(a)) + Float64(sin(a) * Float64(t_0 + -1.0))), Float64(1.0 / Float64(cos(a) * Float64(1.0 - t_0))), x) end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, 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[(1.0 / N[(N[Cos[a], $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y \cdot \tan z\\
\mathsf{fma}\left(\left(\tan y + \tan z\right) \cdot \cos a + \sin a \cdot \left(t\_0 + -1\right), \frac{1}{\cos a \cdot \left(1 - t\_0\right)}, x\right)
\end{array}
\end{array}
Initial program 80.1%
tan-sum99.8%
tan-quot99.8%
frac-sub99.8%
Applied egg-rr99.8%
+-commutative99.8%
div-inv99.8%
fma-define99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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 80.1%
tan-sum99.8%
tan-quot99.8%
frac-sub99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.0005)
(+ x (+ t_0 (/ -1.0 (/ (cos a) (sin a)))))
(if (<= (tan a) 4e-5)
(+ x (- (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))) a))
(+ t_0 (- x (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.0005) {
tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a))));
} else if (tan(a) <= 4e-5) {
tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a);
} else {
tmp = t_0 + (x - 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 (tan(a) <= (-0.0005d0)) then
tmp = x + (t_0 + ((-1.0d0) / (cos(a) / sin(a))))
else if (tan(a) <= 4d-5) then
tmp = x + (((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z))))) - a)
else
tmp = t_0 + (x - 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 (Math.tan(a) <= -0.0005) {
tmp = x + (t_0 + (-1.0 / (Math.cos(a) / Math.sin(a))));
} else if (Math.tan(a) <= 4e-5) {
tmp = x + (((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z))))) - a);
} else {
tmp = t_0 + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.0005: tmp = x + (t_0 + (-1.0 / (math.cos(a) / math.sin(a)))) elif math.tan(a) <= 4e-5: tmp = x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) - a) else: tmp = t_0 + (x - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.0005) tmp = Float64(x + Float64(t_0 + Float64(-1.0 / Float64(cos(a) / sin(a))))); elseif (tan(a) <= 4e-5) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))) - a)); else tmp = Float64(t_0 + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.0005) tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a)))); elseif (tan(a) <= 4e-5) tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a); else tmp = t_0 + (x - 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[N[Tan[a], $MachinePrecision], -0.0005], N[(x + N[(t$95$0 + N[(-1.0 / N[(N[Cos[a], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 4e-5], 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]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.0005:\\
\;\;\;\;x + \left(t\_0 + \frac{-1}{\frac{\cos a}{\sin a}}\right)\\
\mathbf{elif}\;\tan a \leq 4 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.0000000000000001e-4Initial program 79.6%
tan-quot79.6%
clear-num79.6%
Applied egg-rr79.6%
if -5.0000000000000001e-4 < (tan.f64 a) < 4.00000000000000033e-5Initial program 81.9%
Taylor expanded in a around 0 81.9%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
if 4.00000000000000033e-5 < (tan.f64 a) Initial program 76.5%
+-commutative76.5%
associate-+l-76.5%
Applied egg-rr76.5%
Final simplification89.3%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.0005)
(+ x (+ t_0 (/ -1.0 (/ (cos a) (sin a)))))
(if (<= (tan a) 4e-5)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ t_0 (- x (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.0005) {
tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a))));
} else if (tan(a) <= 4e-5) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = t_0 + (x - 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 (tan(a) <= (-0.0005d0)) then
tmp = x + (t_0 + ((-1.0d0) / (cos(a) / sin(a))))
else if (tan(a) <= 4d-5) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = t_0 + (x - 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 (Math.tan(a) <= -0.0005) {
tmp = x + (t_0 + (-1.0 / (Math.cos(a) / Math.sin(a))));
} else if (Math.tan(a) <= 4e-5) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = t_0 + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.0005: tmp = x + (t_0 + (-1.0 / (math.cos(a) / math.sin(a)))) elif math.tan(a) <= 4e-5: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = t_0 + (x - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.0005) tmp = Float64(x + Float64(t_0 + Float64(-1.0 / Float64(cos(a) / sin(a))))); elseif (tan(a) <= 4e-5) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(t_0 + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.0005) tmp = x + (t_0 + (-1.0 / (cos(a) / sin(a)))); elseif (tan(a) <= 4e-5) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = t_0 + (x - 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[N[Tan[a], $MachinePrecision], -0.0005], N[(x + N[(t$95$0 + N[(-1.0 / N[(N[Cos[a], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 4e-5], 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[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.0005:\\
\;\;\;\;x + \left(t\_0 + \frac{-1}{\frac{\cos a}{\sin a}}\right)\\
\mathbf{elif}\;\tan a \leq 4 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.0000000000000001e-4Initial program 79.6%
tan-quot79.6%
clear-num79.6%
Applied egg-rr79.6%
if -5.0000000000000001e-4 < (tan.f64 a) < 4.00000000000000033e-5Initial program 81.9%
Taylor expanded in a around 0 81.9%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 4.00000000000000033e-5 < (tan.f64 a) Initial program 76.5%
+-commutative76.5%
associate-+l-76.5%
Applied egg-rr76.5%
Final simplification89.3%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (/ (sin a) (cos a)))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - (sin(a) / cos(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)))) - (sin(a) / cos(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.sin(a) / Math.cos(a)));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - (math.sin(a) / math.cos(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)))) - Float64(sin(a) / cos(a)))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - (sin(a) / cos(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[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 80.1%
tan-sum99.8%
tan-quot99.8%
frac-sub99.8%
Applied egg-rr99.8%
div-sub99.7%
Simplified99.8%
(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.1%
+-commutative80.1%
sub-neg80.1%
associate-+l+80.1%
tan-sum99.7%
div-inv99.7%
fma-define99.7%
neg-mul-199.7%
fma-define99.7%
Applied egg-rr99.7%
fma-undefine99.7%
fma-undefine99.7%
neg-mul-199.7%
associate-+r+99.7%
sub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(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.1%
tan-quot80.1%
clear-num80.1%
Applied egg-rr80.1%
Final simplification80.1%
(FPCore (x y z a) :precision binary64 (if (or (<= a -10000.0) (not (<= a 1.08e-16))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -10000.0) || !(a <= 1.08e-16)) {
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 <= (-10000.0d0)) .or. (.not. (a <= 1.08d-16))) 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 <= -10000.0) || !(a <= 1.08e-16)) {
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 <= -10000.0) or not (a <= 1.08e-16): 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 <= -10000.0) || !(a <= 1.08e-16)) 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 <= -10000.0) || ~((a <= 1.08e-16))) 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, -10000.0], N[Not[LessEqual[a, 1.08e-16]], $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 -10000 \lor \neg \left(a \leq 1.08 \cdot 10^{-16}\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 < -1e4 or 1.08e-16 < a Initial program 78.4%
Taylor expanded in y around inf 60.6%
if -1e4 < a < 1.08e-16Initial program 81.7%
Taylor expanded in a around 0 81.1%
Final simplification71.0%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.35) (not (<= a 2.3e-5))) (pow (cbrt x) 3.0) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.35) || !(a <= 2.3e-5)) {
tmp = pow(cbrt(x), 3.0);
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.35) || !(a <= 2.3e-5)) {
tmp = Math.pow(Math.cbrt(x), 3.0);
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.35) || !(a <= 2.3e-5)) tmp = cbrt(x) ^ 3.0; else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.35], N[Not[LessEqual[a, 2.3e-5]], $MachinePrecision]], N[Power[N[Power[x, 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \lor \neg \left(a \leq 2.3 \cdot 10^{-5}\right):\\
\;\;\;\;{\left(\sqrt[3]{x}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -1.3500000000000001 or 2.3e-5 < a Initial program 77.6%
Taylor expanded in y around 0 55.4%
tan-quot55.4%
add-cube-cbrt54.6%
pow354.6%
tan-quot54.6%
+-commutative54.6%
Applied egg-rr54.6%
Taylor expanded in x around inf 21.5%
if -1.3500000000000001 < a < 2.3e-5Initial program 82.5%
Taylor expanded in a around 0 81.9%
Final simplification52.4%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -4e-14) (+ x (- (tan y) (tan a))) (- x (- (tan a) (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -4e-14) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x - (tan(a) - tan(z));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-4d-14)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x - (tan(a) - tan(z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -4e-14) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x - (Math.tan(a) - Math.tan(z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -4e-14: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x - (math.tan(a) - math.tan(z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -4e-14) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x - Float64(tan(a) - tan(z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -4e-14) tmp = x + (tan(y) - tan(a)); else tmp = x - (tan(a) - tan(z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -4e-14], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -4 \cdot 10^{-14}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(\tan a - \tan z\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -4e-14Initial program 75.1%
Taylor expanded in y around inf 52.7%
if -4e-14 < (+.f64 y z) Initial program 83.3%
Taylor expanded in y around 0 68.5%
Final simplification62.2%
(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.1%
(FPCore (x y z a) :precision binary64 (if (<= a -1.5) x (if (<= a 2.3e-5) (+ x (- (tan (+ y z)) a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.5) {
tmp = x;
} else if (a <= 2.3e-5) {
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.5d0)) then
tmp = x
else if (a <= 2.3d-5) 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.5) {
tmp = x;
} else if (a <= 2.3e-5) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.5: tmp = x elif a <= 2.3e-5: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.5) tmp = x; elseif (a <= 2.3e-5) 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.5) tmp = x; elseif (a <= 2.3e-5) tmp = x + (tan((y + z)) - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.5], x, If[LessEqual[a, 2.3e-5], 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.5:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.3 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.5 or 2.3e-5 < a Initial program 77.6%
Taylor expanded in x around inf 21.5%
if -1.5 < a < 2.3e-5Initial program 82.5%
Taylor expanded in a around 0 81.9%
(FPCore (x y z a) :precision binary64 (if (<= a -4.4e-15) x (if (<= a 2.3e-5) (- x (- a (tan y))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -4.4e-15) {
tmp = x;
} else if (a <= 2.3e-5) {
tmp = x - (a - tan(y));
} 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 <= (-4.4d-15)) then
tmp = x
else if (a <= 2.3d-5) then
tmp = x - (a - tan(y))
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 <= -4.4e-15) {
tmp = x;
} else if (a <= 2.3e-5) {
tmp = x - (a - Math.tan(y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -4.4e-15: tmp = x elif a <= 2.3e-5: tmp = x - (a - math.tan(y)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -4.4e-15) tmp = x; elseif (a <= 2.3e-5) tmp = Float64(x - Float64(a - tan(y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -4.4e-15) tmp = x; elseif (a <= 2.3e-5) tmp = x - (a - tan(y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -4.4e-15], x, If[LessEqual[a, 2.3e-5], N[(x - N[(a - N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.4 \cdot 10^{-15}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.3 \cdot 10^{-5}:\\
\;\;\;\;x - \left(a - \tan y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -4.39999999999999971e-15 or 2.3e-5 < a Initial program 77.2%
Taylor expanded in x around inf 22.2%
if -4.39999999999999971e-15 < a < 2.3e-5Initial program 83.0%
Taylor expanded in a around 0 83.0%
Taylor expanded in y around inf 65.2%
Final simplification43.4%
(FPCore (x y z a) :precision binary64 (if (<= y -4.6e-14) (- x (- a (tan y))) (+ x (- (tan z) a))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -4.6e-14) {
tmp = x - (a - tan(y));
} else {
tmp = x + (tan(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 (y <= (-4.6d-14)) then
tmp = x - (a - tan(y))
else
tmp = x + (tan(z) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -4.6e-14) {
tmp = x - (a - Math.tan(y));
} else {
tmp = x + (Math.tan(z) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -4.6e-14: tmp = x - (a - math.tan(y)) else: tmp = x + (math.tan(z) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -4.6e-14) tmp = Float64(x - Float64(a - tan(y))); else tmp = Float64(x + Float64(tan(z) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -4.6e-14) tmp = x - (a - tan(y)); else tmp = x + (tan(z) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -4.6e-14], N[(x - N[(a - N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-14}:\\
\;\;\;\;x - \left(a - \tan y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\end{array}
\end{array}
if y < -4.59999999999999996e-14Initial program 67.0%
Taylor expanded in a around 0 30.7%
Taylor expanded in y around inf 30.9%
if -4.59999999999999996e-14 < y Initial program 84.7%
Taylor expanded in a around 0 48.3%
Taylor expanded in y around 0 42.4%
Final simplification39.4%
(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.1%
Taylor expanded in x around inf 34.6%
herbie shell --seed 2024163
(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))))