
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ (- (/ (+ (/ 1.0 (/ (cos y) (sin y))) (tan z)) (- 1.0 (* (tan z) (tan y)))) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return ((((1.0 / (cos(y) / sin(y))) + tan(z)) / (1.0 - (tan(z) * tan(y)))) - 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 = ((((1.0d0 / (cos(y) / sin(y))) + tan(z)) / (1.0d0 - (tan(z) * tan(y)))) - 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 ((((1.0 / (Math.cos(y) / Math.sin(y))) + Math.tan(z)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a)) + x;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return ((((1.0 / (math.cos(y) / math.sin(y))) + math.tan(z)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a)) + x
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(Float64(Float64(Float64(1.0 / Float64(cos(y) / sin(y))) + tan(z)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a)) + x) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = ((((1.0 / (cos(y) / sin(y))) + tan(z)) / (1.0 - (tan(z) * tan(y)))) - 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[(1.0 / N[(N[Cos[y], $MachinePrecision] / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\frac{\frac{1}{\frac{\cos y}{\sin y}} + \tan z}{1 - \tan z \cdot \tan y} - \tan a\right) + x
\end{array}
Initial program 81.9%
+-commutative81.9%
sub-neg81.9%
associate-+l+81.8%
tan-sum99.6%
div-inv99.6%
fma-define99.6%
neg-mul-199.6%
fma-define99.6%
Applied egg-rr99.6%
fma-undefine99.6%
fma-undefine99.6%
neg-mul-199.6%
associate-+r+99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
frac-2neg99.8%
Applied egg-rr99.8%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
distribute-frac-neg299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.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 (if (or (<= (tan a) -0.002) (not (<= (tan a) 0.0002))) (+ x (- (tan (+ y z)) (tan a))) (+ x (- (* (+ (tan z) (tan y)) (/ -1.0 (+ (* (tan z) (tan y)) -1.0))) a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.002) || !(tan(a) <= 0.0002)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x + (((tan(z) + tan(y)) * (-1.0 / ((tan(z) * tan(y)) + -1.0))) - a);
}
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 ((tan(a) <= (-0.002d0)) .or. (.not. (tan(a) <= 0.0002d0))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x + (((tan(z) + tan(y)) * ((-1.0d0) / ((tan(z) * tan(y)) + (-1.0d0)))) - a)
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 ((Math.tan(a) <= -0.002) || !(Math.tan(a) <= 0.0002)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x + (((Math.tan(z) + Math.tan(y)) * (-1.0 / ((Math.tan(z) * Math.tan(y)) + -1.0))) - a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.002) or not (math.tan(a) <= 0.0002): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x + (((math.tan(z) + math.tan(y)) * (-1.0 / ((math.tan(z) * math.tan(y)) + -1.0))) - 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.002) || !(tan(a) <= 0.0002)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) * Float64(-1.0 / Float64(Float64(tan(z) * tan(y)) + -1.0))) - a)); 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 ((tan(a) <= -0.002) || ~((tan(a) <= 0.0002)))
tmp = x + (tan((y + z)) - tan(a));
else
tmp = x + (((tan(z) + tan(y)) * (-1.0 / ((tan(z) * tan(y)) + -1.0))) - a);
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[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.0002]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.002 \lor \neg \left(\tan a \leq 0.0002\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(\tan z + \tan y\right) \cdot \frac{-1}{\tan z \cdot \tan y + -1} - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3 or 2.0000000000000001e-4 < (tan.f64 a) Initial program 83.1%
if -2e-3 < (tan.f64 a) < 2.0000000000000001e-4Initial program 80.7%
Taylor expanded in a around 0 80.7%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification91.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.002) (not (<= (tan a) 0.0002))) (+ x (- (tan (+ y z)) (tan a))) (- x (+ a (/ (+ (tan z) (tan y)) (+ (* (tan z) (tan y)) -1.0))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.002) || !(tan(a) <= 0.0002)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x - (a + ((tan(z) + tan(y)) / ((tan(z) * tan(y)) + -1.0)));
}
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 ((tan(a) <= (-0.002d0)) .or. (.not. (tan(a) <= 0.0002d0))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x - (a + ((tan(z) + tan(y)) / ((tan(z) * tan(y)) + (-1.0d0))))
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 ((Math.tan(a) <= -0.002) || !(Math.tan(a) <= 0.0002)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x - (a + ((Math.tan(z) + Math.tan(y)) / ((Math.tan(z) * Math.tan(y)) + -1.0)));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.002) or not (math.tan(a) <= 0.0002): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x - (a + ((math.tan(z) + math.tan(y)) / ((math.tan(z) * math.tan(y)) + -1.0))) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.002) || !(tan(a) <= 0.0002)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x - Float64(a + Float64(Float64(tan(z) + tan(y)) / Float64(Float64(tan(z) * tan(y)) + -1.0)))); 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 ((tan(a) <= -0.002) || ~((tan(a) <= 0.0002)))
tmp = x + (tan((y + z)) - tan(a));
else
tmp = x - (a + ((tan(z) + tan(y)) / ((tan(z) * tan(y)) + -1.0)));
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[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.0002]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(a + N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $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.002 \lor \neg \left(\tan a \leq 0.0002\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(a + \frac{\tan z + \tan y}{\tan z \cdot \tan y + -1}\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3 or 2.0000000000000001e-4 < (tan.f64 a) Initial program 83.1%
if -2e-3 < (tan.f64 a) < 2.0000000000000001e-4Initial program 80.7%
Taylor expanded in a around 0 80.7%
tan-sum99.6%
div-inv99.6%
fma-neg99.6%
+-commutative99.6%
*-commutative99.6%
Applied egg-rr99.6%
fma-undefine99.6%
unsub-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification91.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.002) (not (<= (tan a) 0.0002))) (+ x (- (tan (+ y z)) (tan a))) (+ x (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.002) || !(tan(a) <= 0.0002)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = x + ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y))));
}
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 ((tan(a) <= (-0.002d0)) .or. (.not. (tan(a) <= 0.0002d0))) then
tmp = x + (tan((y + z)) - tan(a))
else
tmp = x + ((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y))))
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 ((Math.tan(a) <= -0.002) || !(Math.tan(a) <= 0.0002)) {
tmp = x + (Math.tan((y + z)) - Math.tan(a));
} else {
tmp = x + ((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y))));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.002) or not (math.tan(a) <= 0.0002): tmp = x + (math.tan((y + z)) - math.tan(a)) else: tmp = x + ((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.002) || !(tan(a) <= 0.0002)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(x + Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y))))); 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 ((tan(a) <= -0.002) || ~((tan(a) <= 0.0002)))
tmp = x + (tan((y + z)) - tan(a));
else
tmp = x + ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y))));
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[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.0002]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $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.002 \lor \neg \left(\tan a \leq 0.0002\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3 or 2.0000000000000001e-4 < (tan.f64 a) Initial program 83.1%
if -2e-3 < (tan.f64 a) < 2.0000000000000001e-4Initial program 80.7%
expm1-log1p-u68.6%
expm1-undefine68.6%
Applied egg-rr68.6%
expm1-define68.6%
Simplified68.6%
+-commutative68.6%
expm1-log1p-u80.7%
associate--r-80.7%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
fma-undefine99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in a around 0 98.5%
neg-mul-198.5%
Simplified98.5%
Final simplification91.1%
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 a) (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))));
}
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(a) - ((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))))
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(a) - ((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x - (math.tan(a) - ((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x - (tan(a) - ((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))));
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[a], $MachinePrecision] - N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x - \left(\tan a - \frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}\right)
\end{array}
Initial program 81.9%
+-commutative81.9%
sub-neg81.9%
associate-+l+81.8%
tan-sum99.6%
div-inv99.6%
fma-define99.6%
neg-mul-199.6%
fma-define99.6%
Applied egg-rr99.6%
fma-undefine99.6%
fma-undefine99.6%
neg-mul-199.6%
associate-+r+99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.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 (if (or (<= (tan a) -1e-6) (not (<= (tan a) 4e-14))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ y z)) a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -1e-6) || !(tan(a) <= 4e-14)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
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 ((tan(a) <= (-1d-6)) .or. (.not. (tan(a) <= 4d-14))) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan((y + z)) - a)
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 ((Math.tan(a) <= -1e-6) || !(Math.tan(a) <= 4e-14)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -1e-6) or not (math.tan(a) <= 4e-14): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -1e-6) || !(tan(a) <= 4e-14)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); 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 ((tan(a) <= -1e-6) || ~((tan(a) <= 4e-14)))
tmp = x + (tan(y) - tan(a));
else
tmp = x + (tan((y + z)) - a);
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[Or[LessEqual[N[Tan[a], $MachinePrecision], -1e-6], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 4e-14]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -1 \cdot 10^{-6} \lor \neg \left(\tan a \leq 4 \cdot 10^{-14}\right):\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -9.99999999999999955e-7 or 4e-14 < (tan.f64 a) Initial program 81.9%
Taylor expanded in y around inf 63.5%
if -9.99999999999999955e-7 < (tan.f64 a) < 4e-14Initial program 81.8%
Taylor expanded in a around 0 81.8%
Final simplification72.8%
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) -4e-14) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -4e-14) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan(z) - tan(a));
}
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) <= (-4d-14)) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan(z) - tan(a))
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) <= -4e-14) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= -4e-14: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -4e-14) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); 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) <= -4e-14)
tmp = x + (tan(y) - tan(a));
else
tmp = x + (tan(z) - tan(a));
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], -4e-14], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $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}\;y + z \leq -4 \cdot 10^{-14}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -4e-14Initial program 71.6%
Taylor expanded in y around inf 45.7%
if -4e-14 < (+.f64 y z) Initial program 87.3%
Taylor expanded in y around 0 68.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 81.9%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= a -1.9) x (if (<= a 2.9e-10) (+ x (- (tan (+ y z)) a)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.9) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = 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 (a <= (-1.9d0)) then
tmp = x
else if (a <= 2.9d-10) then
tmp = x + (tan((y + z)) - a)
else
tmp = 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 (a <= -1.9) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if a <= -1.9: tmp = x elif a <= 2.9e-10: tmp = x + (math.tan((y + z)) - a) else: tmp = x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (a <= -1.9) tmp = x; elseif (a <= 2.9e-10) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = 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 (a <= -1.9)
tmp = x;
elseif (a <= 2.9e-10)
tmp = x + (tan((y + z)) - a);
else
tmp = 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[a, -1.9], x, If[LessEqual[a, 2.9e-10], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.9 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.8999999999999999 or 2.89999999999999981e-10 < a Initial program 82.0%
Taylor expanded in x around inf 22.6%
if -1.8999999999999999 < a < 2.89999999999999981e-10Initial program 81.7%
Taylor expanded in a around 0 81.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 (<= a -5e-10) x (if (<= a 2.9e-10) (+ x (- (tan z) a)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -5e-10) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (tan(z) - a);
} else {
tmp = 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 (a <= (-5d-10)) then
tmp = x
else if (a <= 2.9d-10) then
tmp = x + (tan(z) - a)
else
tmp = 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 (a <= -5e-10) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (Math.tan(z) - a);
} else {
tmp = x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if a <= -5e-10: tmp = x elif a <= 2.9e-10: tmp = x + (math.tan(z) - a) else: tmp = x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (a <= -5e-10) tmp = x; elseif (a <= 2.9e-10) tmp = Float64(x + Float64(tan(z) - a)); else tmp = 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 (a <= -5e-10)
tmp = x;
elseif (a <= 2.9e-10)
tmp = x + (tan(z) - a);
else
tmp = 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[a, -5e-10], x, If[LessEqual[a, 2.9e-10], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-10}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.9 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -5.00000000000000031e-10 or 2.89999999999999981e-10 < a Initial program 81.1%
Taylor expanded in x around inf 22.6%
if -5.00000000000000031e-10 < a < 2.89999999999999981e-10Initial program 82.6%
Taylor expanded in a around 0 82.6%
Taylor expanded in y around 0 62.0%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= a -1.55) x (if (<= a 2.9e-10) (+ x (- (tan y) a)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (tan(y) - a);
} else {
tmp = 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 (a <= (-1.55d0)) then
tmp = x
else if (a <= 2.9d-10) then
tmp = x + (tan(y) - a)
else
tmp = 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 (a <= -1.55) {
tmp = x;
} else if (a <= 2.9e-10) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if a <= -1.55: tmp = x elif a <= 2.9e-10: tmp = x + (math.tan(y) - a) else: tmp = x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (a <= -1.55) tmp = x; elseif (a <= 2.9e-10) tmp = Float64(x + Float64(tan(y) - a)); else tmp = 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 (a <= -1.55)
tmp = x;
elseif (a <= 2.9e-10)
tmp = x + (tan(y) - a);
else
tmp = 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[a, -1.55], x, If[LessEqual[a, 2.9e-10], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.9 \cdot 10^{-10}:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 2.89999999999999981e-10 < a Initial program 82.0%
Taylor expanded in x around inf 22.6%
if -1.55000000000000004 < a < 2.89999999999999981e-10Initial program 81.7%
Taylor expanded in a around 0 81.4%
Taylor expanded in y around inf 61.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)
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return 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 = x
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return x end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := x
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x
\end{array}
Initial program 81.9%
Taylor expanded in x around inf 32.8%
herbie shell --seed 2024144
(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))))