
(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 20 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}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (fma (tan y) (tan z) 1.0)))
(+
x
(fma
(/ 1.0 (- (/ 1.0 t_0) (/ (* (pow (tan z) 2.0) (pow (tan y) 2.0)) t_0)))
(fma (/ 1.0 (cos z)) (sin z) (tan y))
(- (tan a))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = fma(tan(y), tan(z), 1.0);
return x + fma((1.0 / ((1.0 / t_0) - ((pow(tan(z), 2.0) * pow(tan(y), 2.0)) / t_0))), fma((1.0 / cos(z)), sin(z), tan(y)), -tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = fma(tan(y), tan(z), 1.0) return Float64(x + fma(Float64(1.0 / Float64(Float64(1.0 / t_0) - Float64(Float64((tan(z) ^ 2.0) * (tan(y) ^ 2.0)) / t_0))), fma(Float64(1.0 / cos(z)), sin(z), tan(y)), Float64(-tan(a)))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + 1.0), $MachinePrecision]}, N[(x + N[(N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] - N[(N[(N[Power[N[Tan[z], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Tan[y], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan y, \tan z, 1\right)\\
x + \mathsf{fma}\left(\frac{1}{\frac{1}{t\_0} - \frac{{\tan z}^{2} \cdot {\tan y}^{2}}{t\_0}}, \mathsf{fma}\left(\frac{1}{\cos z}, \sin z, \tan y\right), -\tan a\right)
\end{array}
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
lift--.f64N/A
flip--N/A
metadata-evalN/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
Applied rewrites99.7%
lift-pow.f64N/A
lift-*.f64N/A
unpow-prod-downN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
div-invN/A
lift-/.f64N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (fma (tan y) (tan z) 1.0)))
(+
x
(fma
(/ 1.0 (- (/ 1.0 t_0) (/ (pow (* (tan y) (tan z)) 2.0) t_0)))
(fma (/ 1.0 (cos z)) (sin z) (tan y))
(- (tan a))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = fma(tan(y), tan(z), 1.0);
return x + fma((1.0 / ((1.0 / t_0) - (pow((tan(y) * tan(z)), 2.0) / t_0))), fma((1.0 / cos(z)), sin(z), tan(y)), -tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = fma(tan(y), tan(z), 1.0) return Float64(x + fma(Float64(1.0 / Float64(Float64(1.0 / t_0) - Float64((Float64(tan(y) * tan(z)) ^ 2.0) / t_0))), fma(Float64(1.0 / cos(z)), sin(z), tan(y)), Float64(-tan(a)))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + 1.0), $MachinePrecision]}, N[(x + N[(N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] - N[(N[Power[N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan y, \tan z, 1\right)\\
x + \mathsf{fma}\left(\frac{1}{\frac{1}{t\_0} - \frac{{\left(\tan y \cdot \tan z\right)}^{2}}{t\_0}}, \mathsf{fma}\left(\frac{1}{\cos z}, \sin z, \tan y\right), -\tan a\right)
\end{array}
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
lift--.f64N/A
flip--N/A
metadata-evalN/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -0.05)
(- (fma 1.0 t_0 x) (tan a))
(if (<= (tan a) 1e-14)
(+
x
(fma
(/ 1.0 (- 1.0 (* (tan y) (tan z))))
t_0
(- (fma a (* a (* a 0.3333333333333333)) a))))
(+ x (fma 1.0 t_0 (- (tan a))))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.05) {
tmp = fma(1.0, t_0, x) - tan(a);
} else if (tan(a) <= 1e-14) {
tmp = x + fma((1.0 / (1.0 - (tan(y) * tan(z)))), t_0, -fma(a, (a * (a * 0.3333333333333333)), a));
} else {
tmp = x + fma(1.0, t_0, -tan(a));
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.05) tmp = Float64(fma(1.0, t_0, x) - tan(a)); elseif (tan(a) <= 1e-14) tmp = Float64(x + fma(Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), t_0, Float64(-fma(a, Float64(a * Float64(a * 0.3333333333333333)), a)))); else tmp = Float64(x + fma(1.0, t_0, Float64(-tan(a)))); end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], N[(N[(1.0 * t$95$0 + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-14], N[(x + N[(N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + (-N[(a * N[(a * N[(a * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 * t$95$0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(1, t\_0, x\right) - \tan a\\
\mathbf{elif}\;\tan a \leq 10^{-14}:\\
\;\;\;\;x + \mathsf{fma}\left(\frac{1}{1 - \tan y \cdot \tan z}, t\_0, -\mathsf{fma}\left(a, a \cdot \left(a \cdot 0.3333333333333333\right), a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(1, t\_0, -\tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003Initial program 79.0%
lift--.f64N/A
sub-negN/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-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites80.0%
lift-+.f64N/A
lift-fma.f64N/A
associate-+r+N/A
lift-neg.f64N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6480.0
Applied rewrites80.0%
if -0.050000000000000003 < (tan.f64 a) < 9.99999999999999999e-15Initial program 74.6%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6474.6
Applied rewrites74.6%
lift--.f64N/A
sub-negN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift--.f64N/A
div-invN/A
lift-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
if 9.99999999999999999e-15 < (tan.f64 a) Initial program 79.0%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= (tan a) -0.05)
(- (fma 1.0 t_0 x) (tan a))
(if (<= (tan a) 1e-14)
(+
x
(-
(/ t_0 (- 1.0 (* (tan y) (tan z))))
(fma (* a a) (* a 0.3333333333333333) a)))
(+ x (fma 1.0 t_0 (- (tan a))))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if (tan(a) <= -0.05) {
tmp = fma(1.0, t_0, x) - tan(a);
} else if (tan(a) <= 1e-14) {
tmp = x + ((t_0 / (1.0 - (tan(y) * tan(z)))) - fma((a * a), (a * 0.3333333333333333), a));
} else {
tmp = x + fma(1.0, t_0, -tan(a));
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if (tan(a) <= -0.05) tmp = Float64(fma(1.0, t_0, x) - tan(a)); elseif (tan(a) <= 1e-14) tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z)))) - fma(Float64(a * a), Float64(a * 0.3333333333333333), a))); else tmp = Float64(x + fma(1.0, t_0, Float64(-tan(a)))); end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], N[(N[(1.0 * t$95$0 + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-14], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a * 0.3333333333333333), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 * t$95$0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(1, t\_0, x\right) - \tan a\\
\mathbf{elif}\;\tan a \leq 10^{-14}:\\
\;\;\;\;x + \left(\frac{t\_0}{1 - \tan y \cdot \tan z} - \mathsf{fma}\left(a \cdot a, a \cdot 0.3333333333333333, a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(1, t\_0, -\tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003Initial program 79.0%
lift--.f64N/A
sub-negN/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-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites80.0%
lift-+.f64N/A
lift-fma.f64N/A
associate-+r+N/A
lift-neg.f64N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6480.0
Applied rewrites80.0%
if -0.050000000000000003 < (tan.f64 a) < 9.99999999999999999e-15Initial program 74.6%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6474.6
Applied rewrites74.6%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if 9.99999999999999999e-15 < (tan.f64 a) Initial program 79.0%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites79.3%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (fma (/ 1.0 (- 1.0 (* (tan y) (tan z)))) (fma (/ 1.0 (cos z)) (sin z) (tan y)) (- (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + fma((1.0 / (1.0 - (tan(y) * tan(z)))), fma((1.0 / cos(z)), sin(z), tan(y)), -tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + fma(Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), fma(Float64(1.0 / cos(z)), sin(z), tan(y)), Float64(-tan(a)))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \mathsf{fma}\left(\frac{1}{1 - \tan y \cdot \tan z}, \mathsf{fma}\left(\frac{1}{\cos z}, \sin z, \tan y\right), -\tan a\right)
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (fma (/ 1.0 (cos z)) (sin z) (tan y)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + ((fma((1.0 / cos(z)), sin(z), tan(y)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(fma(Float64(1.0 / cos(z)), sin(z), tan(y)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] * N[Sin[z], $MachinePrecision] + N[Tan[y], $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, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\mathsf{fma}\left(\frac{1}{\cos z}, \sin z, \tan y\right)}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 76.8%
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.6
Applied rewrites99.6%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
div-invN/A
lift-/.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6499.6
Applied rewrites99.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (fma (/ 1.0 (- 1.0 (* (tan y) (tan z)))) (+ (tan y) (tan z)) (- (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + fma((1.0 / (1.0 - (tan(y) * tan(z)))), (tan(y) + tan(z)), -tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + fma(Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), Float64(tan(y) + tan(z)), Float64(-tan(a)))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \mathsf{fma}\left(\frac{1}{1 - \tan y \cdot \tan z}, \tan y + \tan z, -\tan a\right)
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (fma (tan z) (- (tan y)) 1.0)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / fma(tan(z), -tan(y), 1.0)) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / fma(tan(z), Float64(-tan(y)), 1.0)) - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[z], $MachinePrecision] * (-N[Tan[y], $MachinePrecision]) + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan y + \tan z}{\mathsf{fma}\left(\tan z, -\tan y, 1\right)} - \tan a\right)
\end{array}
Initial program 76.8%
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.6
Applied rewrites99.6%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
assert(x < y && y < z && z < 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));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < a;
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));
}
[x, y, z, a] = sort([x, y, z, 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))
x, y, z, a = sort([x, y, z, 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
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. 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, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 76.8%
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.6
Applied rewrites99.6%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.05)
(+ x (- (/ 1.0 (/ (fma z (* z -0.3333333333333333) 1.0) z)) (tan a)))
(if (<= (tan a) 5e-7)
(+
x
(-
(tan (+ y z))
(fma
(fma a (* a 0.13333333333333333) 0.3333333333333333)
(* a (* a a))
a)))
(+
x
(-
(/
1.0
(/
(fma
(* z z)
(fma (* z z) -0.022222222222222223 -0.3333333333333333)
1.0)
z))
(tan a))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.05) {
tmp = x + ((1.0 / (fma(z, (z * -0.3333333333333333), 1.0) / z)) - tan(a));
} else if (tan(a) <= 5e-7) {
tmp = x + (tan((y + z)) - fma(fma(a, (a * 0.13333333333333333), 0.3333333333333333), (a * (a * a)), a));
} else {
tmp = x + ((1.0 / (fma((z * z), fma((z * z), -0.022222222222222223, -0.3333333333333333), 1.0) / z)) - tan(a));
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.05) tmp = Float64(x + Float64(Float64(1.0 / Float64(fma(z, Float64(z * -0.3333333333333333), 1.0) / z)) - tan(a))); elseif (tan(a) <= 5e-7) tmp = Float64(x + Float64(tan(Float64(y + z)) - fma(fma(a, Float64(a * 0.13333333333333333), 0.3333333333333333), Float64(a * Float64(a * a)), a))); else tmp = Float64(x + Float64(Float64(1.0 / Float64(fma(Float64(z * z), fma(Float64(z * z), -0.022222222222222223, -0.3333333333333333), 1.0) / z)) - tan(a))); end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], N[(x + N[(N[(1.0 / N[(N[(z * N[(z * -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 5e-7], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(a * N[(a * 0.13333333333333333), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(N[(N[(z * z), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] * -0.022222222222222223 + -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;x + \left(\frac{1}{\frac{\mathsf{fma}\left(z, z \cdot -0.3333333333333333, 1\right)}{z}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-7}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot 0.13333333333333333, 0.3333333333333333\right), a \cdot \left(a \cdot a\right), a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\frac{\mathsf{fma}\left(z \cdot z, \mathsf{fma}\left(z \cdot z, -0.022222222222222223, -0.3333333333333333\right), 1\right)}{z}} - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003Initial program 79.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6465.4
Applied rewrites65.4%
Applied rewrites65.3%
Taylor expanded in z around 0
Applied rewrites43.6%
if -0.050000000000000003 < (tan.f64 a) < 4.99999999999999977e-7Initial program 75.2%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
if 4.99999999999999977e-7 < (tan.f64 a) Initial program 78.0%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6457.6
Applied rewrites57.6%
Applied rewrites57.6%
Taylor expanded in z around 0
Applied rewrites42.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0
(+
x
(- (/ 1.0 (/ (fma z (* z -0.3333333333333333) 1.0) z)) (tan a)))))
(if (<= (tan a) -0.05)
t_0
(if (<= (tan a) 5e-7)
(+
x
(-
(tan (+ y z))
(fma
(fma a (* a 0.13333333333333333) 0.3333333333333333)
(* a (* a a))
a)))
t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x + ((1.0 / (fma(z, (z * -0.3333333333333333), 1.0) / z)) - tan(a));
double tmp;
if (tan(a) <= -0.05) {
tmp = t_0;
} else if (tan(a) <= 5e-7) {
tmp = x + (tan((y + z)) - fma(fma(a, (a * 0.13333333333333333), 0.3333333333333333), (a * (a * a)), a));
} else {
tmp = t_0;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(1.0 / Float64(fma(z, Float64(z * -0.3333333333333333), 1.0) / z)) - tan(a))) tmp = 0.0 if (tan(a) <= -0.05) tmp = t_0; elseif (tan(a) <= 5e-7) tmp = Float64(x + Float64(tan(Float64(y + z)) - fma(fma(a, Float64(a * 0.13333333333333333), 0.3333333333333333), Float64(a * Float64(a * a)), a))); else tmp = t_0; end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(1.0 / N[(N[(z * N[(z * -0.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 5e-7], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(a * N[(a * 0.13333333333333333), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x + \left(\frac{1}{\frac{\mathsf{fma}\left(z, z \cdot -0.3333333333333333, 1\right)}{z}} - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-7}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot 0.13333333333333333, 0.3333333333333333\right), a \cdot \left(a \cdot a\right), a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003 or 4.99999999999999977e-7 < (tan.f64 a) Initial program 78.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6461.4
Applied rewrites61.4%
Applied rewrites61.4%
Taylor expanded in z around 0
Applied rewrites42.9%
if -0.050000000000000003 < (tan.f64 a) < 4.99999999999999977e-7Initial program 75.2%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (fma 1.0 (+ (tan y) (tan z)) (- (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + fma(1.0, (tan(y) + tan(z)), -tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + fma(1.0, Float64(tan(y) + tan(z)), Float64(-tan(a)))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(1.0 * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \mathsf{fma}\left(1, \tan y + \tan z, -\tan a\right)
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites76.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (fma 1.0 (+ (tan y) (tan z)) (- x (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return fma(1.0, (tan(y) + tan(z)), (x - tan(a)));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return fma(1.0, Float64(tan(y) + tan(z)), Float64(x - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(1.0 * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\mathsf{fma}\left(1, \tan y + \tan z, x - \tan a\right)
\end{array}
Initial program 76.8%
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.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- (fma 1.0 (+ (tan y) (tan z)) x) (tan a)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return fma(1.0, (tan(y) + tan(z)), x) - tan(a);
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(fma(1.0, Float64(tan(y) + tan(z)), x) - tan(a)) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(1.0 * N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\mathsf{fma}\left(1, \tan y + \tan z, x\right) - \tan a
\end{array}
Initial program 76.8%
lift--.f64N/A
sub-negN/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-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites76.9%
lift-+.f64N/A
lift-fma.f64N/A
associate-+r+N/A
lift-neg.f64N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6476.9
Applied rewrites76.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (tan (* (- z y) (/ (+ y z) (- z y)))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (tan(((z - y) * ((y + z) / (z - y)))) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan(((z - y) * ((y + z) / (z - y)))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x + (Math.tan(((z - y) * ((y + z) / (z - y)))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan(((z - y) * ((y + z) / (z - y)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(Float64(z - y) * Float64(Float64(y + z) / Float64(z - y)))) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan(((z - y) * ((y + z) / (z - y)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(N[(z - y), $MachinePrecision] * N[(N[(y + z), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(\left(z - y\right) \cdot \frac{y + z}{z - y}\right) - \tan a\right)
\end{array}
Initial program 76.8%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6446.7
Applied rewrites46.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (tan z) (tan a)))))
(if (<= a -0.019)
t_0
(if (<= a 0.039)
(+ x (- (tan (+ y z)) (fma (* a a) (* a 0.3333333333333333) a)))
t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x + (tan(z) - tan(a));
double tmp;
if (a <= -0.019) {
tmp = t_0;
} else if (a <= 0.039) {
tmp = x + (tan((y + z)) - fma((a * a), (a * 0.3333333333333333), a));
} else {
tmp = t_0;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x + Float64(tan(z) - tan(a))) tmp = 0.0 if (a <= -0.019) tmp = t_0; elseif (a <= 0.039) tmp = Float64(x + Float64(tan(Float64(y + z)) - fma(Float64(a * a), Float64(a * 0.3333333333333333), a))); else tmp = t_0; end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.019], t$95$0, If[LessEqual[a, 0.039], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a * 0.3333333333333333), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x + \left(\tan z - \tan a\right)\\
\mathbf{if}\;a \leq -0.019:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.039:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(a \cdot a, a \cdot 0.3333333333333333, a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.0189999999999999995 or 0.0389999999999999999 < a Initial program 78.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6461.4
Applied rewrites61.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6461.4
Applied rewrites61.4%
if -0.0189999999999999995 < a < 0.0389999999999999999Initial program 75.2%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Final simplification68.4%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan((y + z)) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. 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, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 76.8%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (/ 1.0 (/ 1.0 z)) (tan a)))))
(if (<= a -0.46)
t_0
(if (<= a 0.156)
(+ x (- (tan (+ y z)) (fma (* a a) (* a 0.3333333333333333) a)))
t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x + ((1.0 / (1.0 / z)) - tan(a));
double tmp;
if (a <= -0.46) {
tmp = t_0;
} else if (a <= 0.156) {
tmp = x + (tan((y + z)) - fma((a * a), (a * 0.3333333333333333), a));
} else {
tmp = t_0;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x + Float64(Float64(1.0 / Float64(1.0 / z)) - tan(a))) tmp = 0.0 if (a <= -0.46) tmp = t_0; elseif (a <= 0.156) tmp = Float64(x + Float64(tan(Float64(y + z)) - fma(Float64(a * a), Float64(a * 0.3333333333333333), a))); else tmp = t_0; end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(1.0 / N[(1.0 / z), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.46], t$95$0, If[LessEqual[a, 0.156], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a * 0.3333333333333333), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x + \left(\frac{1}{\frac{1}{z}} - \tan a\right)\\
\mathbf{if}\;a \leq -0.46:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.156:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(a \cdot a, a \cdot 0.3333333333333333, a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.46000000000000002 or 0.156 < a Initial program 78.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6461.4
Applied rewrites61.4%
Applied rewrites61.4%
Taylor expanded in z around 0
Applied rewrites31.6%
if -0.46000000000000002 < a < 0.156Initial program 75.2%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (fma 0.3333333333333333 (* z (* z z)) z) (tan a)))))
(if (<= a -0.46)
t_0
(if (<= a 0.156)
(+ x (- (tan (+ y z)) (fma (* a a) (* a 0.3333333333333333) a)))
t_0))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = x + (fma(0.3333333333333333, (z * (z * z)), z) - tan(a));
double tmp;
if (a <= -0.46) {
tmp = t_0;
} else if (a <= 0.156) {
tmp = x + (tan((y + z)) - fma((a * a), (a * 0.3333333333333333), a));
} else {
tmp = t_0;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(x + Float64(fma(0.3333333333333333, Float64(z * Float64(z * z)), z) - tan(a))) tmp = 0.0 if (a <= -0.46) tmp = t_0; elseif (a <= 0.156) tmp = Float64(x + Float64(tan(Float64(y + z)) - fma(Float64(a * a), Float64(a * 0.3333333333333333), a))); else tmp = t_0; end return tmp end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[(0.3333333333333333 * N[(z * N[(z * z), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.46], t$95$0, If[LessEqual[a, 0.156], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * N[(a * 0.3333333333333333), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := x + \left(\mathsf{fma}\left(0.3333333333333333, z \cdot \left(z \cdot z\right), z\right) - \tan a\right)\\
\mathbf{if}\;a \leq -0.46:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.156:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \mathsf{fma}\left(a \cdot a, a \cdot 0.3333333333333333, a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.46000000000000002 or 0.156 < a Initial program 78.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6461.4
Applied rewrites61.4%
Taylor expanded in z around 0
Applied rewrites31.3%
if -0.46000000000000002 < a < 0.156Initial program 75.2%
Taylor expanded in a around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (fma 0.3333333333333333 (* z (* z z)) z) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (fma(0.3333333333333333, (z * (z * z)), z) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(fma(0.3333333333333333, Float64(z * Float64(z * z)), z) - tan(a))) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(0.3333333333333333 * N[(z * N[(z * z), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\mathsf{fma}\left(0.3333333333333333, z \cdot \left(z \cdot z\right), z\right) - \tan a\right)
\end{array}
Initial program 76.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.2
Applied rewrites60.2%
Taylor expanded in z around 0
Applied rewrites29.2%
herbie shell --seed 2024237
(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))))