
(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 13 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 (- 1.0 (* (tan y) (tan z)))))
(+
x
(/ (- (* (cos a) (+ (tan y) (tan z))) (* (sin a) t_0)) (* (cos a) t_0)))))
double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (tan(y) * tan(z));
return x + (((cos(a) * (tan(y) + tan(z))) - (sin(a) * t_0)) / (cos(a) * 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 = 1.0d0 - (tan(y) * tan(z))
code = x + (((cos(a) * (tan(y) + tan(z))) - (sin(a) * t_0)) / (cos(a) * t_0))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (Math.tan(y) * Math.tan(z));
return x + (((Math.cos(a) * (Math.tan(y) + Math.tan(z))) - (Math.sin(a) * t_0)) / (Math.cos(a) * t_0));
}
def code(x, y, z, a): t_0 = 1.0 - (math.tan(y) * math.tan(z)) return x + (((math.cos(a) * (math.tan(y) + math.tan(z))) - (math.sin(a) * t_0)) / (math.cos(a) * t_0))
function code(x, y, z, a) t_0 = Float64(1.0 - Float64(tan(y) * tan(z))) return Float64(x + Float64(Float64(Float64(cos(a) * Float64(tan(y) + tan(z))) - Float64(sin(a) * t_0)) / Float64(cos(a) * t_0))) end
function tmp = code(x, y, z, a) t_0 = 1.0 - (tan(y) * tan(z)); tmp = x + (((cos(a) * (tan(y) + tan(z))) - (sin(a) * t_0)) / (cos(a) * t_0)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[Cos[a], $MachinePrecision] * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan y \cdot \tan z\\
x + \frac{\cos a \cdot \left(\tan y + \tan z\right) - \sin a \cdot t\_0}{\cos a \cdot t\_0}
\end{array}
\end{array}
Initial program 78.9%
lift--.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lift-tan.f64N/A
tan-quotN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites99.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 78.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= a -2.1e-12)
(+ x (- (tan (+ y z)) (tan a)))
(if (<= a 2.36e-63)
(+ x (/ t_0 (- 1.0 (* (tan y) (tan z)))))
(+ x (- (* t_0 1.0) (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (a <= -2.1e-12) {
tmp = x + (tan((y + z)) - tan(a));
} else if (a <= 2.36e-63) {
tmp = x + (t_0 / (1.0 - (tan(y) * tan(z))));
} else {
tmp = x + ((t_0 * 1.0) - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if (a <= (-2.1d-12)) then
tmp = x + (tan((y + z)) - tan(a))
else if (a <= 2.36d-63) then
tmp = x + (t_0 / (1.0d0 - (tan(y) * tan(z))))
else
tmp = x + ((t_0 * 1.0d0) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) + Math.tan(z);
double tmp;
if (a <= -2.1e-12) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else if (a <= 2.36e-63) {
tmp = x + (t_0 / (1.0 - (Math.tan(y) * Math.tan(z))));
} else {
tmp = x + ((t_0 * 1.0) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if a <= -2.1e-12: tmp = x + (math.tan((y + z)) - math.tan(a)) elif a <= 2.36e-63: tmp = x + (t_0 / (1.0 - (math.tan(y) * math.tan(z)))) else: tmp = x + ((t_0 * 1.0) - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (a <= -2.1e-12) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); elseif (a <= 2.36e-63) tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z))))); else tmp = Float64(x + Float64(Float64(t_0 * 1.0) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(y) + tan(z); tmp = 0.0; if (a <= -2.1e-12) tmp = x + (tan((y + z)) - tan(a)); elseif (a <= 2.36e-63) tmp = x + (t_0 / (1.0 - (tan(y) * tan(z)))); else tmp = x + ((t_0 * 1.0) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.1e-12], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.36e-63], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(t$95$0 * 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;a \leq -2.1 \cdot 10^{-12}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{elif}\;a \leq 2.36 \cdot 10^{-63}:\\
\;\;\;\;x + \frac{t\_0}{1 - \tan y \cdot \tan z}\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 \cdot 1 - \tan a\right)\\
\end{array}
\end{array}
if a < -2.09999999999999994e-12Initial program 77.5%
if -2.09999999999999994e-12 < a < 2.35999999999999998e-63Initial program 82.1%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6482.1
Applied rewrites82.1%
Applied rewrites99.8%
if 2.35999999999999998e-63 < a Initial program 75.9%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites76.0%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6476.1
Applied rewrites76.1%
Final simplification86.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))) (t_1 (+ x t_0)))
(if (<= t_0 -1e-11)
t_1
(if (<= t_0 0.02)
(+
x
(-
(fma
(fma
z
(* z (fma (* z z) 0.05396825396825397 0.13333333333333333))
0.3333333333333333)
(* z (* z z))
z)
(tan a)))
t_1))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -1e-11) {
tmp = t_1;
} else if (t_0 <= 0.02) {
tmp = x + (fma(fma(z, (z * fma((z * z), 0.05396825396825397, 0.13333333333333333)), 0.3333333333333333), (z * (z * z)), z) - tan(a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, a) t_0 = tan(Float64(y + z)) t_1 = Float64(x + t_0) tmp = 0.0 if (t_0 <= -1e-11) tmp = t_1; elseif (t_0 <= 0.02) tmp = Float64(x + Float64(fma(fma(z, Float64(z * fma(Float64(z * z), 0.05396825396825397, 0.13333333333333333)), 0.3333333333333333), Float64(z * Float64(z * z)), z) - tan(a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-11], t$95$1, If[LessEqual[t$95$0, 0.02], N[(x + N[(N[(N[(z * N[(z * N[(N[(z * z), $MachinePrecision] * 0.05396825396825397 + 0.13333333333333333), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(z * N[(z * z), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;x + \left(\mathsf{fma}\left(\mathsf{fma}\left(z, z \cdot \mathsf{fma}\left(z \cdot z, 0.05396825396825397, 0.13333333333333333\right), 0.3333333333333333\right), z \cdot \left(z \cdot z\right), z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -9.99999999999999939e-12 or 0.0200000000000000004 < (tan.f64 (+.f64 y z)) Initial program 72.4%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6447.4
Applied rewrites47.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6447.4
Applied rewrites47.4%
if -9.99999999999999939e-12 < (tan.f64 (+.f64 y z)) < 0.0200000000000000004Initial program 99.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in z around 0
Applied rewrites95.9%
Final simplification59.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))) (t_1 (+ x t_0)))
(if (<= t_0 -1e-11)
t_1
(if (<= t_0 0.02)
(+
x
(-
(fma
(fma z (* z 0.13333333333333333) 0.3333333333333333)
(* z (* z z))
z)
(tan a)))
t_1))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -1e-11) {
tmp = t_1;
} else if (t_0 <= 0.02) {
tmp = x + (fma(fma(z, (z * 0.13333333333333333), 0.3333333333333333), (z * (z * z)), z) - tan(a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, a) t_0 = tan(Float64(y + z)) t_1 = Float64(x + t_0) tmp = 0.0 if (t_0 <= -1e-11) tmp = t_1; elseif (t_0 <= 0.02) tmp = Float64(x + Float64(fma(fma(z, Float64(z * 0.13333333333333333), 0.3333333333333333), Float64(z * Float64(z * z)), z) - tan(a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-11], t$95$1, If[LessEqual[t$95$0, 0.02], N[(x + N[(N[(N[(z * N[(z * 0.13333333333333333), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(z * N[(z * z), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;x + \left(\mathsf{fma}\left(\mathsf{fma}\left(z, z \cdot 0.13333333333333333, 0.3333333333333333\right), z \cdot \left(z \cdot z\right), z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -9.99999999999999939e-12 or 0.0200000000000000004 < (tan.f64 (+.f64 y z)) Initial program 72.4%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6447.4
Applied rewrites47.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6447.4
Applied rewrites47.4%
if -9.99999999999999939e-12 < (tan.f64 (+.f64 y z)) < 0.0200000000000000004Initial program 99.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in z around 0
Applied rewrites95.9%
Final simplification59.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))) (t_1 (+ x t_0)))
(if (<= t_0 -1e-11)
t_1
(if (<= t_0 0.02)
(+ x (- (fma z (* (* z z) 0.3333333333333333) z) (tan a)))
t_1))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -1e-11) {
tmp = t_1;
} else if (t_0 <= 0.02) {
tmp = x + (fma(z, ((z * z) * 0.3333333333333333), z) - tan(a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, a) t_0 = tan(Float64(y + z)) t_1 = Float64(x + t_0) tmp = 0.0 if (t_0 <= -1e-11) tmp = t_1; elseif (t_0 <= 0.02) tmp = Float64(x + Float64(fma(z, Float64(Float64(z * z) * 0.3333333333333333), z) - tan(a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-11], t$95$1, If[LessEqual[t$95$0, 0.02], N[(x + N[(N[(z * N[(N[(z * z), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;x + \left(\mathsf{fma}\left(z, \left(z \cdot z\right) \cdot 0.3333333333333333, z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -9.99999999999999939e-12 or 0.0200000000000000004 < (tan.f64 (+.f64 y z)) Initial program 72.4%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6463.2
Applied rewrites63.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6447.4
Applied rewrites47.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6447.4
Applied rewrites47.4%
if -9.99999999999999939e-12 < (tan.f64 (+.f64 y z)) < 0.0200000000000000004Initial program 99.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in z around 0
Applied rewrites95.9%
Final simplification59.0%
(FPCore (x y z a) :precision binary64 (+ x (- (* (+ (tan y) (tan z)) 1.0) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) * 1.0) - 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(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(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) * 1.0) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * 1.0) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) * 1.0) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) \cdot 1 - \tan a\right)
\end{array}
Initial program 78.9%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites79.1%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6479.2
Applied rewrites79.2%
Final simplification79.2%
(FPCore (x y z a) :precision binary64 (- (fma (+ (tan y) (tan z)) 1.0 x) (tan a)))
double code(double x, double y, double z, double a) {
return fma((tan(y) + tan(z)), 1.0, x) - tan(a);
}
function code(x, y, z, a) return Float64(fma(Float64(tan(y) + tan(z)), 1.0, x) - tan(a)) end
code[x_, y_, z_, a_] := N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * 1.0 + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\tan y + \tan z, 1, x\right) - \tan a
\end{array}
Initial program 78.9%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites79.1%
lift-fma.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
*-commutativeN/A
lower-fma.f6479.1
Applied rewrites79.1%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -1e-11) (+ x (tan (+ y z))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -1e-11) {
tmp = x + tan((y + z));
} else {
tmp = x + (tan(z) - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= (-1d-11)) then
tmp = x + tan((y + z))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -1e-11) {
tmp = x + Math.tan((y + z));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -1e-11: tmp = x + math.tan((y + z)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -1e-11) tmp = Float64(x + tan(Float64(y + z))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -1e-11) tmp = x + tan((y + z)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -1e-11], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -1 \cdot 10^{-11}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -9.99999999999999939e-12Initial program 73.0%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6461.5
Applied rewrites61.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6445.3
Applied rewrites45.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6445.3
Applied rewrites45.3%
if -9.99999999999999939e-12 < (+.f64 y z) Initial program 82.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6464.0
Applied rewrites64.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.0
Applied rewrites64.0%
Final simplification57.4%
(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 78.9%
(FPCore (x y z a) :precision binary64 (+ x (tan (+ y z))))
double code(double x, double y, double z, double a) {
return x + 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((y + z))
end function
public static double code(double x, double y, double z, double a) {
return x + Math.tan((y + z));
}
def code(x, y, z, a): return x + math.tan((y + z))
function code(x, y, z, a) return Float64(x + tan(Float64(y + z))) end
function tmp = code(x, y, z, a) tmp = x + tan((y + z)); end
code[x_, y_, z_, a_] := N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \tan \left(y + z\right)
\end{array}
Initial program 78.9%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6472.0
Applied rewrites72.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f6451.5
Applied rewrites51.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6451.5
Applied rewrites51.5%
Final simplification51.5%
(FPCore (x y z a) :precision binary64 (/ 1.0 (/ 1.0 x)))
double code(double x, double y, double z, double a) {
return 1.0 / (1.0 / 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 = 1.0d0 / (1.0d0 / x)
end function
public static double code(double x, double y, double z, double a) {
return 1.0 / (1.0 / x);
}
def code(x, y, z, a): return 1.0 / (1.0 / x)
function code(x, y, z, a) return Float64(1.0 / Float64(1.0 / x)) end
function tmp = code(x, y, z, a) tmp = 1.0 / (1.0 / x); end
code[x_, y_, z_, a_] := N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{x}}
\end{array}
Initial program 78.9%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6478.8
Applied rewrites78.7%
Taylor expanded in x around inf
lower-/.f6432.7
Applied rewrites32.7%
(FPCore (x y z a) :precision binary64 (/ 1.0 (/ -1.0 x)))
double code(double x, double y, double z, double a) {
return 1.0 / (-1.0 / 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 = 1.0d0 / ((-1.0d0) / x)
end function
public static double code(double x, double y, double z, double a) {
return 1.0 / (-1.0 / x);
}
def code(x, y, z, a): return 1.0 / (-1.0 / x)
function code(x, y, z, a) return Float64(1.0 / Float64(-1.0 / x)) end
function tmp = code(x, y, z, a) tmp = 1.0 / (-1.0 / x); end
code[x_, y_, z_, a_] := N[(1.0 / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{-1}{x}}
\end{array}
Initial program 78.9%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6478.8
Applied rewrites78.7%
Taylor expanded in x around inf
lower-/.f6432.7
Applied rewrites32.7%
Applied rewrites32.7%
Taylor expanded in x around -inf
Applied rewrites2.5%
herbie shell --seed 2024233
(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))))