
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ (- (/ (fma (sin z) (/ 1.0 (cos z)) (tan y)) (fma (- (tan z)) (tan y) 1.0)) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return ((fma(sin(z), (1.0 / cos(z)), tan(y)) / fma(-tan(z), tan(y), 1.0)) - tan(a)) + x;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(Float64(fma(sin(z), Float64(1.0 / cos(z)), tan(y)) / fma(Float64(-tan(z)), tan(y), 1.0)) - tan(a)) + x) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(N[(N[(N[Sin[z], $MachinePrecision] * N[(1.0 / N[Cos[z], $MachinePrecision]), $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\frac{\mathsf{fma}\left(\sin z, \frac{1}{\cos z}, \tan y\right)}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - \tan a\right) + x
\end{array}
Initial program 80.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-tan.f64N/A
tan-quotN/A
div-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
unpow-1N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.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 (+ (tan z) (tan y))))
(if (<= (tan a) -0.02)
(- x (+ (/ t_0 -1.0) (tan a)))
(if (<= (tan a) 1e-42)
(fma -1.0 (/ t_0 (fma (tan z) (tan y) -1.0)) (- (- a x)))
(+ (- (tan (+ y z)) (tan a)) x)))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(z) + tan(y);
double tmp;
if (tan(a) <= -0.02) {
tmp = x - ((t_0 / -1.0) + tan(a));
} else if (tan(a) <= 1e-42) {
tmp = fma(-1.0, (t_0 / fma(tan(z), tan(y), -1.0)), -(a - x));
} else {
tmp = (tan((y + z)) - tan(a)) + x;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(z) + tan(y)) tmp = 0.0 if (tan(a) <= -0.02) tmp = Float64(x - Float64(Float64(t_0 / -1.0) + tan(a))); elseif (tan(a) <= 1e-42) tmp = fma(-1.0, Float64(t_0 / fma(tan(z), tan(y), -1.0)), Float64(-Float64(a - x))); else tmp = Float64(Float64(tan(Float64(y + z)) - tan(a)) + x); 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[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.02], N[(x - N[(N[(t$95$0 / -1.0), $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-42], N[(-1.0 * N[(t$95$0 / N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + (-N[(a - x), $MachinePrecision])), $MachinePrecision], N[(N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;\tan a \leq -0.02:\\
\;\;\;\;x - \left(\frac{t\_0}{-1} + \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-42}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t\_0}{\mathsf{fma}\left(\tan z, \tan y, -1\right)}, -\left(a - x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan \left(y + z\right) - \tan a\right) + x\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004Initial program 79.2%
lift--.f64N/A
sub-negN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites80.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
if -0.0200000000000000004 < (tan.f64 a) < 1.00000000000000004e-42Initial program 78.7%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in a around 0
lower--.f6478.7
Applied rewrites78.7%
lift--.f64N/A
sub-negN/A
Applied rewrites99.3%
if 1.00000000000000004e-42 < (tan.f64 a) Initial program 86.6%
Final simplification90.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 (+ (tan z) (tan y))))
(if (<= (tan a) -2e-11)
(- x (+ (/ t_0 -1.0) (tan a)))
(if (<= (tan a) 1e-42)
(fma -1.0 (/ t_0 (fma (tan z) (tan y) -1.0)) (- (- x)))
(+ (- (tan (+ y z)) (tan a)) x)))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = tan(z) + tan(y);
double tmp;
if (tan(a) <= -2e-11) {
tmp = x - ((t_0 / -1.0) + tan(a));
} else if (tan(a) <= 1e-42) {
tmp = fma(-1.0, (t_0 / fma(tan(z), tan(y), -1.0)), -(-x));
} else {
tmp = (tan((y + z)) - tan(a)) + x;
}
return tmp;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(z) + tan(y)) tmp = 0.0 if (tan(a) <= -2e-11) tmp = Float64(x - Float64(Float64(t_0 / -1.0) + tan(a))); elseif (tan(a) <= 1e-42) tmp = fma(-1.0, Float64(t_0 / fma(tan(z), tan(y), -1.0)), Float64(-Float64(-x))); else tmp = Float64(Float64(tan(Float64(y + z)) - tan(a)) + x); 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[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -2e-11], N[(x - N[(N[(t$95$0 / -1.0), $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-42], N[(-1.0 * N[(t$95$0 / N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + (-(-x))), $MachinePrecision], N[(N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;\tan a \leq -2 \cdot 10^{-11}:\\
\;\;\;\;x - \left(\frac{t\_0}{-1} + \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-42}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t\_0}{\mathsf{fma}\left(\tan z, \tan y, -1\right)}, -\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan \left(y + z\right) - \tan a\right) + x\\
\end{array}
\end{array}
if (tan.f64 a) < -1.99999999999999988e-11Initial program 79.0%
lift--.f64N/A
sub-negN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites80.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6480.0
Applied rewrites80.0%
if -1.99999999999999988e-11 < (tan.f64 a) < 1.00000000000000004e-42Initial program 78.8%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6478.8
Applied rewrites78.8%
lift--.f64N/A
sub-negN/A
Applied rewrites99.8%
if 1.00000000000000004e-42 < (tan.f64 a) Initial program 86.6%
Final simplification90.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ (- (/ (+ (tan z) (tan y)) (fma (- (tan z)) (tan y) 1.0)) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return (((tan(z) + tan(y)) / fma(-tan(z), tan(y), 1.0)) - tan(a)) + x;
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(Float64(Float64(tan(z) + tan(y)) / fma(Float64(-tan(z)), tan(y), 1.0)) - tan(a)) + x) end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - \tan a\right) + x
\end{array}
Initial program 80.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Final simplification99.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 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(z) + tan(y)) / -1.0) + 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) + tan(y)) / (-1.0d0)) + 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) + Math.tan(y)) / -1.0) + Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x - (((math.tan(z) + math.tan(y)) / -1.0) + 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(z) + tan(y)) / -1.0) + tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x - (((tan(z) + 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[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x - \left(\frac{\tan z + \tan y}{-1} + \tan a\right)
\end{array}
Initial program 80.9%
lift--.f64N/A
sub-negN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites81.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6481.4
Applied rewrites81.4%
Final simplification81.4%
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 z) (tan y)) (- 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(z) + tan(y)), (x - tan(a)));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return fma(1.0, Float64(tan(z) + tan(y)), 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[z], $MachinePrecision] + N[Tan[y], $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 z + \tan y, x - \tan a\right)
\end{array}
Initial program 80.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
associate-+l+N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
+-commutativeN/A
lift-neg.f64N/A
sub-negN/A
lift--.f64N/A
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites81.4%
Final simplification81.4%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= (+ y z) 2e-9) (+ (- (tan y) (tan a)) x) (- (tan (+ y z)) (/ (* (- x) x) x))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 2e-9) {
tmp = (tan(y) - tan(a)) + x;
} else {
tmp = tan((y + z)) - ((-x * x) / x);
}
return tmp;
}
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
real(8) :: tmp
if ((y + z) <= 2d-9) then
tmp = (tan(y) - tan(a)) + x
else
tmp = tan((y + z)) - ((-x * x) / x)
end if
code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 2e-9) {
tmp = (Math.tan(y) - Math.tan(a)) + x;
} else {
tmp = Math.tan((y + z)) - ((-x * x) / x);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= 2e-9: tmp = (math.tan(y) - math.tan(a)) + x else: tmp = math.tan((y + z)) - ((-x * x) / x) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 2e-9) tmp = Float64(Float64(tan(y) - tan(a)) + x); else tmp = Float64(tan(Float64(y + z)) - Float64(Float64(Float64(-x) * x) / x)); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if ((y + z) <= 2e-9)
tmp = (tan(y) - tan(a)) + x;
else
tmp = tan((y + z)) - ((-x * x) / x);
end
tmp_2 = 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[(y + z), $MachinePrecision], 2e-9], N[(N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[((-x) * x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\left(\tan y - \tan a\right) + x\\
\mathbf{else}:\\
\;\;\;\;\tan \left(y + z\right) - \frac{\left(-x\right) \cdot x}{x}\\
\end{array}
\end{array}
if (+.f64 y z) < 2.00000000000000012e-9Initial program 83.8%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-tan.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6469.0
Applied rewrites69.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6469.0
Applied rewrites69.0%
if 2.00000000000000012e-9 < (+.f64 y z) Initial program 76.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6476.0
Applied rewrites76.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6452.3
Applied rewrites52.3%
Applied rewrites52.3%
Final simplification62.8%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ (- (tan (+ y z)) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return (tan((y + z)) - tan(a)) + x;
}
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 = (tan((y + z)) - tan(a)) + x
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return (Math.tan((y + z)) - Math.tan(a)) + x;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return (math.tan((y + z)) - math.tan(a)) + x
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(tan(Float64(y + z)) - tan(a)) + x) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = (tan((y + z)) - tan(a)) + x;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\tan \left(y + z\right) - \tan a\right) + x
\end{array}
Initial program 80.9%
Final simplification80.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- (tan (+ y z)) (/ (* (- x) x) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return tan((y + z)) - ((-x * x) / x);
}
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 = tan((y + z)) - ((-x * x) / x)
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return Math.tan((y + z)) - ((-x * x) / x);
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return math.tan((y + z)) - ((-x * x) / x)
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(tan(Float64(y + z)) - Float64(Float64(Float64(-x) * x) / x)) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = tan((y + z)) - ((-x * x) / x);
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[(N[((-x) * x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\tan \left(y + z\right) - \frac{\left(-x\right) \cdot x}{x}
\end{array}
Initial program 80.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6480.9
Applied rewrites80.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6450.7
Applied rewrites50.7%
Applied rewrites50.7%
Final simplification50.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- (tan (+ y z)) (- x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return tan((y + z)) - -x;
}
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 = tan((y + z)) - -x
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return Math.tan((y + z)) - -x;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return math.tan((y + z)) - -x
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(tan(Float64(y + z)) - Float64(-x)) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = tan((y + z)) - -x;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\tan \left(y + z\right) - \left(-x\right)
\end{array}
Initial program 80.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6480.9
Applied rewrites80.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6450.7
Applied rewrites50.7%
Final simplification50.7%
herbie shell --seed 2024327
(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))))