
(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 (+ (- (/ (+ (/ (sin z) (cos z)) (tan y)) (- 1.0 (* (tan y) (tan z)))) (tan a)) x))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return ((((sin(z) / cos(z)) + tan(y)) / (1.0 - (tan(y) * tan(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 = ((((sin(z) / cos(z)) + tan(y)) / (1.0d0 - (tan(y) * tan(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.sin(z) / Math.cos(z)) + Math.tan(y)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a)) + x;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return ((((math.sin(z) / math.cos(z)) + math.tan(y)) / (1.0 - (math.tan(y) * math.tan(z)))) - 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(sin(z) / cos(z)) + tan(y)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a)) + x) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = ((((sin(z) / cos(z)) + tan(y)) / (1.0 - (tan(y) * tan(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[(N[(N[(N[Sin[z], $MachinePrecision] / N[Cos[z], $MachinePrecision]), $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] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(\frac{\frac{\sin z}{\cos z} + \tan y}{1 - \tan y \cdot \tan z} - \tan a\right) + x
\end{array}
Initial program 80.2%
+-commutative80.2%
sub-neg80.2%
associate-+l+80.1%
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.7%
*-rgt-identity99.7%
Simplified99.7%
tan-quot99.7%
frac-2neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
+-commutative99.7%
distribute-frac-neg99.7%
distribute-frac-neg299.7%
remove-double-neg99.7%
Simplified99.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 80.2%
+-commutative80.2%
sub-neg80.2%
associate-+l+80.1%
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.7%
*-rgt-identity99.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 (<= a -0.0004)
(+ x (- (/ 1.0 (/ (cos (+ z y)) (sin (+ z y)))) (tan a)))
(if (<= a 1.6e-48)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- (tan (+ z y)) (/ (sin a) (cos a)))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -0.0004) {
tmp = x + ((1.0 / (cos((z + y)) / sin((z + y)))) - tan(a));
} else if (a <= 1.6e-48) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (tan((z + y)) - (sin(a) / cos(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 (a <= (-0.0004d0)) then
tmp = x + ((1.0d0 / (cos((z + y)) / sin((z + y)))) - tan(a))
else if (a <= 1.6d-48) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (tan((z + y)) - (sin(a) / cos(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 (a <= -0.0004) {
tmp = x + ((1.0 / (Math.cos((z + y)) / Math.sin((z + y)))) - Math.tan(a));
} else if (a <= 1.6e-48) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (Math.tan((z + y)) - (Math.sin(a) / Math.cos(a)));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if a <= -0.0004: tmp = x + ((1.0 / (math.cos((z + y)) / math.sin((z + y)))) - math.tan(a)) elif a <= 1.6e-48: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (math.tan((z + y)) - (math.sin(a) / math.cos(a))) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (a <= -0.0004) tmp = Float64(x + Float64(Float64(1.0 / Float64(cos(Float64(z + y)) / sin(Float64(z + y)))) - tan(a))); elseif (a <= 1.6e-48) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(tan(Float64(z + y)) - Float64(sin(a) / cos(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 (a <= -0.0004)
tmp = x + ((1.0 / (cos((z + y)) / sin((z + y)))) - tan(a));
elseif (a <= 1.6e-48)
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
else
tmp = x + (tan((z + y)) - (sin(a) / cos(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[a, -0.0004], N[(x + N[(N[(1.0 / N[(N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6e-48], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0004:\\
\;\;\;\;x + \left(\frac{1}{\frac{\cos \left(z + y\right)}{\sin \left(z + y\right)}} - \tan a\right)\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-48}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - \frac{\sin a}{\cos a}\right)\\
\end{array}
\end{array}
if a < -4.00000000000000019e-4Initial program 80.5%
tan-quot80.6%
clear-num80.5%
Applied egg-rr80.5%
if -4.00000000000000019e-4 < a < 1.5999999999999999e-48Initial program 74.5%
Taylor expanded in a around 0 74.5%
tan-sum99.7%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if 1.5999999999999999e-48 < a Initial program 87.2%
Taylor expanded in a around inf 87.3%
Final simplification90.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)) (/ (sin a) (cos a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (tan((z + y)) - (sin(a) / cos(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)) - (sin(a) / cos(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)) - (Math.sin(a) / Math.cos(a)));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan((z + y)) - (math.sin(a) / math.cos(a)))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(z + y)) - Float64(sin(a) / cos(a)))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan((z + y)) - (sin(a) / cos(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[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(z + y\right) - \frac{\sin a}{\cos a}\right)
\end{array}
Initial program 80.2%
Taylor expanded in a around inf 80.2%
Final simplification80.2%
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 (<= a -7.8e-25) (not (<= a 0.00056))) (+ x (- (tan y) (tan a))) (+ x (- (tan (+ z y)) a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -7.8e-25) || !(a <= 0.00056)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + (tan((z + y)) - 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 ((a <= (-7.8d-25)) .or. (.not. (a <= 0.00056d0))) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + (tan((z + y)) - 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 ((a <= -7.8e-25) || !(a <= 0.00056)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + (Math.tan((z + y)) - a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (a <= -7.8e-25) or not (a <= 0.00056): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + (math.tan((z + y)) - a) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if ((a <= -7.8e-25) || !(a <= 0.00056)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(Float64(z + y)) - 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 ((a <= -7.8e-25) || ~((a <= 0.00056)))
tmp = x + (tan(y) - tan(a));
else
tmp = x + (tan((z + y)) - 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[a, -7.8e-25], N[Not[LessEqual[a, 0.00056]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.8 \cdot 10^{-25} \lor \neg \left(a \leq 0.00056\right):\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\end{array}
\end{array}
if a < -7.8e-25 or 5.5999999999999995e-4 < a Initial program 82.7%
Taylor expanded in y around inf 60.3%
if -7.8e-25 < a < 5.5999999999999995e-4Initial program 77.2%
Taylor expanded in a around 0 77.2%
Final simplification68.2%
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 (<= a -1.65) (not (<= a 1.55))) (exp (log x)) (+ x (- (tan (+ z y)) a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.65) || !(a <= 1.55)) {
tmp = exp(log(x));
} else {
tmp = x + (tan((z + y)) - 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 ((a <= (-1.65d0)) .or. (.not. (a <= 1.55d0))) then
tmp = exp(log(x))
else
tmp = x + (tan((z + y)) - 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 ((a <= -1.65) || !(a <= 1.55)) {
tmp = Math.exp(Math.log(x));
} else {
tmp = x + (Math.tan((z + y)) - a);
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (a <= -1.65) or not (a <= 1.55): tmp = math.exp(math.log(x)) else: tmp = x + (math.tan((z + y)) - a) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if ((a <= -1.65) || !(a <= 1.55)) tmp = exp(log(x)); else tmp = Float64(x + Float64(tan(Float64(z + y)) - 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 ((a <= -1.65) || ~((a <= 1.55)))
tmp = exp(log(x));
else
tmp = x + (tan((z + y)) - 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[a, -1.65], N[Not[LessEqual[a, 1.55]], $MachinePrecision]], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65 \lor \neg \left(a \leq 1.55\right):\\
\;\;\;\;e^{\log x}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\end{array}
\end{array}
if a < -1.6499999999999999 or 1.55000000000000004 < a Initial program 82.8%
Taylor expanded in a around 0 3.0%
add-exp-log2.4%
Applied egg-rr2.4%
Taylor expanded in x around inf 23.7%
mul-1-neg23.7%
log-rec23.7%
remove-double-neg23.7%
Simplified23.7%
if -1.6499999999999999 < a < 1.55000000000000004Initial program 77.4%
Taylor expanded in a around 0 77.4%
Final simplification49.5%
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 -2.0) (exp (- (log (/ 1.0 x)))) (if (<= a 1.55) (+ x (- (tan (+ z y)) a)) (exp (log x)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.0) {
tmp = exp(-log((1.0 / x)));
} else if (a <= 1.55) {
tmp = x + (tan((z + y)) - a);
} else {
tmp = exp(log(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 <= (-2.0d0)) then
tmp = exp(-log((1.0d0 / x)))
else if (a <= 1.55d0) then
tmp = x + (tan((z + y)) - a)
else
tmp = exp(log(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 <= -2.0) {
tmp = Math.exp(-Math.log((1.0 / x)));
} else if (a <= 1.55) {
tmp = x + (Math.tan((z + y)) - a);
} else {
tmp = Math.exp(Math.log(x));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if a <= -2.0: tmp = math.exp(-math.log((1.0 / x))) elif a <= 1.55: tmp = x + (math.tan((z + y)) - a) else: tmp = math.exp(math.log(x)) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (a <= -2.0) tmp = exp(Float64(-log(Float64(1.0 / x)))); elseif (a <= 1.55) tmp = Float64(x + Float64(tan(Float64(z + y)) - a)); else tmp = exp(log(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 <= -2.0)
tmp = exp(-log((1.0 / x)));
elseif (a <= 1.55)
tmp = x + (tan((z + y)) - a);
else
tmp = exp(log(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, -2.0], N[Exp[(-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[a, 1.55], N[(x + N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2:\\
\;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log x}\\
\end{array}
\end{array}
if a < -2Initial program 80.5%
Taylor expanded in a around 0 5.1%
add-exp-log5.1%
Applied egg-rr5.1%
Taylor expanded in x around inf 23.7%
if -2 < a < 1.55000000000000004Initial program 77.4%
Taylor expanded in a around 0 77.4%
if 1.55000000000000004 < a Initial program 84.8%
Taylor expanded in a around 0 1.2%
add-exp-log0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 23.7%
mul-1-neg23.7%
log-rec23.7%
remove-double-neg23.7%
Simplified23.7%
Final simplification49.5%
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 -6.5e-8) (+ 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 <= -6.5e-8) {
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 <= (-6.5d-8)) 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 <= -6.5e-8) {
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 <= -6.5e-8: 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 (y <= -6.5e-8) 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 <= -6.5e-8)
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[y, -6.5e-8], 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 \leq -6.5 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if y < -6.49999999999999997e-8Initial program 63.7%
Taylor expanded in y around inf 62.4%
if -6.49999999999999997e-8 < y Initial program 87.0%
Taylor expanded in y around 0 77.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 (+ 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)) - 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)) - 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)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan((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(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)) - 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[(z + y), $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(z + y\right) - \tan a\right)
\end{array}
Initial program 80.2%
Final simplification80.2%
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.8) x (if (<= a 1.55) (+ x (- (tan (+ z 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.8) {
tmp = x;
} else if (a <= 1.55) {
tmp = x + (tan((z + 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.8d0)) then
tmp = x
else if (a <= 1.55d0) then
tmp = x + (tan((z + 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.8) {
tmp = x;
} else if (a <= 1.55) {
tmp = x + (Math.tan((z + 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.8: tmp = x elif a <= 1.55: tmp = x + (math.tan((z + 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.8) tmp = x; elseif (a <= 1.55) tmp = Float64(x + Float64(tan(Float64(z + 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.8)
tmp = x;
elseif (a <= 1.55)
tmp = x + (tan((z + 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.8], x, If[LessEqual[a, 1.55], N[(x + N[(N[Tan[N[(z + y), $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.8:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;x + \left(\tan \left(z + y\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.80000000000000004 or 1.55000000000000004 < a Initial program 82.8%
Taylor expanded in x around inf 23.7%
if -1.80000000000000004 < a < 1.55000000000000004Initial program 77.4%
Taylor expanded in a around 0 77.4%
Final simplification49.5%
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.65) x (if (<= a 4.4e-5) (+ 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.65) {
tmp = x;
} else if (a <= 4.4e-5) {
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.65d0)) then
tmp = x
else if (a <= 4.4d-5) 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.65) {
tmp = x;
} else if (a <= 4.4e-5) {
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.65: tmp = x elif a <= 4.4e-5: 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.65) tmp = x; elseif (a <= 4.4e-5) 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.65)
tmp = x;
elseif (a <= 4.4e-5)
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.65], x, If[LessEqual[a, 4.4e-5], 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.65:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 4.4 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.6499999999999999 or 4.3999999999999999e-5 < a Initial program 82.9%
Taylor expanded in x around inf 23.7%
if -1.6499999999999999 < a < 4.3999999999999999e-5Initial program 77.2%
Taylor expanded in a around 0 77.2%
Taylor expanded in y around inf 62.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 80.2%
Taylor expanded in x around inf 33.4%
herbie shell --seed 2024145
(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))))