
(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 8 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 (+ (tan y) (tan z)))) (+ x (- (/ 1.0 (- (/ 1.0 t_0) (* (tan y) (/ (tan z) 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);
return x + ((1.0 / ((1.0 / t_0) - (tan(y) * (tan(z) / t_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
real(8) :: t_0
t_0 = tan(y) + tan(z)
code = x + ((1.0d0 / ((1.0d0 / t_0) - (tan(y) * (tan(z) / t_0)))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) + Math.tan(z);
return x + ((1.0 / ((1.0 / t_0) - (Math.tan(y) * (Math.tan(z) / t_0)))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) return x + ((1.0 / ((1.0 / t_0) - (math.tan(y) * (math.tan(z) / t_0)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) return Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 / t_0) - Float64(tan(y) * Float64(tan(z) / t_0)))) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
t_0 = tan(y) + tan(z);
tmp = x + ((1.0 / ((1.0 / t_0) - (tan(y) * (tan(z) / t_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_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] - N[(N[Tan[y], $MachinePrecision] * N[(N[Tan[z], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $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 := \tan y + \tan z\\
x + \left(\frac{1}{\frac{1}{t\_0} - \tan y \cdot \frac{\tan z}{t\_0}} - \tan a\right)
\end{array}
\end{array}
Initial program 81.8%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
div-sub99.7%
Applied egg-rr99.7%
associate-/l*99.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 (+ 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 81.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.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
(let* ((t_0 (+ (tan y) (tan z))))
(if (<= z 0.0146)
(+ x (- (/ 1.0 (/ (- 1.0 (* (tan y) z)) t_0)) (tan a)))
(+ x (- (/ 1.0 (- (/ 1.0 t_0) y)) (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 (z <= 0.0146) {
tmp = x + ((1.0 / ((1.0 - (tan(y) * z)) / t_0)) - tan(a));
} else {
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - 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) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if (z <= 0.0146d0) then
tmp = x + ((1.0d0 / ((1.0d0 - (tan(y) * z)) / t_0)) - tan(a))
else
tmp = x + ((1.0d0 / ((1.0d0 / t_0) - y)) - 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 t_0 = Math.tan(y) + Math.tan(z);
double tmp;
if (z <= 0.0146) {
tmp = x + ((1.0 / ((1.0 - (Math.tan(y) * z)) / t_0)) - Math.tan(a));
} else {
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - Math.tan(a));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if z <= 0.0146: tmp = x + ((1.0 / ((1.0 - (math.tan(y) * z)) / t_0)) - math.tan(a)) else: tmp = x + ((1.0 / ((1.0 / t_0) - y)) - math.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 (z <= 0.0146) tmp = Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 - Float64(tan(y) * z)) / t_0)) - tan(a))); else tmp = Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 / t_0) - y)) - tan(a))); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
t_0 = tan(y) + tan(z);
tmp = 0.0;
if (z <= 0.0146)
tmp = x + ((1.0 / ((1.0 - (tan(y) * z)) / t_0)) - tan(a));
else
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - 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_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 0.0146], N[(x + N[(N[(1.0 / N[(N[(1.0 - N[(N[Tan[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] - 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 := \tan y + \tan z\\
\mathbf{if}\;z \leq 0.0146:\\
\;\;\;\;x + \left(\frac{1}{\frac{1 - \tan y \cdot z}{t\_0}} - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{t\_0} - y} - \tan a\right)\\
\end{array}
\end{array}
if z < 0.0146000000000000001Initial program 87.3%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in z around 0 80.0%
clear-num79.9%
inv-pow79.9%
associate-/l*79.9%
tan-quot79.9%
Applied egg-rr79.9%
unpow-179.9%
Simplified79.9%
if 0.0146000000000000001 < z Initial program 62.8%
tan-sum99.5%
clear-num99.5%
Applied egg-rr99.5%
div-sub99.6%
Applied egg-rr99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 64.5%
Final simplification76.5%
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 (<= z 0.0146)
(- (+ x (/ t_0 (- 1.0 (* (tan y) z)))) (tan a))
(+ x (- (/ 1.0 (- (/ 1.0 t_0) y)) (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 (z <= 0.0146) {
tmp = (x + (t_0 / (1.0 - (tan(y) * z)))) - tan(a);
} else {
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - 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) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if (z <= 0.0146d0) then
tmp = (x + (t_0 / (1.0d0 - (tan(y) * z)))) - tan(a)
else
tmp = x + ((1.0d0 / ((1.0d0 / t_0) - y)) - 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 t_0 = Math.tan(y) + Math.tan(z);
double tmp;
if (z <= 0.0146) {
tmp = (x + (t_0 / (1.0 - (Math.tan(y) * z)))) - Math.tan(a);
} else {
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - Math.tan(a));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if z <= 0.0146: tmp = (x + (t_0 / (1.0 - (math.tan(y) * z)))) - math.tan(a) else: tmp = x + ((1.0 / ((1.0 / t_0) - y)) - math.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 (z <= 0.0146) tmp = Float64(Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * z)))) - tan(a)); else tmp = Float64(x + Float64(Float64(1.0 / Float64(Float64(1.0 / t_0) - y)) - tan(a))); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
t_0 = tan(y) + tan(z);
tmp = 0.0;
if (z <= 0.0146)
tmp = (x + (t_0 / (1.0 - (tan(y) * z)))) - tan(a);
else
tmp = x + ((1.0 / ((1.0 / t_0) - y)) - 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_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 0.0146], N[(N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(N[(1.0 / t$95$0), $MachinePrecision] - 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 := \tan y + \tan z\\
\mathbf{if}\;z \leq 0.0146:\\
\;\;\;\;\left(x + \frac{t\_0}{1 - \tan y \cdot z}\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{t\_0} - y} - \tan a\right)\\
\end{array}
\end{array}
if z < 0.0146000000000000001Initial program 87.3%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in z around 0 80.0%
associate-+r-79.9%
associate-/l*79.9%
tan-quot79.9%
Applied egg-rr79.9%
if 0.0146000000000000001 < z Initial program 62.8%
tan-sum99.5%
clear-num99.5%
Applied egg-rr99.5%
div-sub99.6%
Applied egg-rr99.6%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 64.5%
Final simplification76.5%
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 (/ 1.0 (+ (tan y) (tan z)))))
(if (<= y -300000000.0)
(+ x (- (/ 1.0 (- t_0 z)) (tan a)))
(+ x (- (/ 1.0 (- t_0 y)) (tan a))))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double t_0 = 1.0 / (tan(y) + tan(z));
double tmp;
if (y <= -300000000.0) {
tmp = x + ((1.0 / (t_0 - z)) - tan(a));
} else {
tmp = x + ((1.0 / (t_0 - y)) - 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / (tan(y) + tan(z))
if (y <= (-300000000.0d0)) then
tmp = x + ((1.0d0 / (t_0 - z)) - tan(a))
else
tmp = x + ((1.0d0 / (t_0 - y)) - 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 t_0 = 1.0 / (Math.tan(y) + Math.tan(z));
double tmp;
if (y <= -300000000.0) {
tmp = x + ((1.0 / (t_0 - z)) - Math.tan(a));
} else {
tmp = x + ((1.0 / (t_0 - y)) - Math.tan(a));
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): t_0 = 1.0 / (math.tan(y) + math.tan(z)) tmp = 0 if y <= -300000000.0: tmp = x + ((1.0 / (t_0 - z)) - math.tan(a)) else: tmp = x + ((1.0 / (t_0 - y)) - math.tan(a)) return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) t_0 = Float64(1.0 / Float64(tan(y) + tan(z))) tmp = 0.0 if (y <= -300000000.0) tmp = Float64(x + Float64(Float64(1.0 / Float64(t_0 - z)) - tan(a))); else tmp = Float64(x + Float64(Float64(1.0 / Float64(t_0 - y)) - tan(a))); end return tmp end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
t_0 = 1.0 / (tan(y) + tan(z));
tmp = 0.0;
if (y <= -300000000.0)
tmp = x + ((1.0 / (t_0 - z)) - tan(a));
else
tmp = x + ((1.0 / (t_0 - y)) - 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_] := Block[{t$95$0 = N[(1.0 / N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -300000000.0], N[(x + N[(N[(1.0 / N[(t$95$0 - z), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 / N[(t$95$0 - 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 := \frac{1}{\tan y + \tan z}\\
\mathbf{if}\;y \leq -300000000:\\
\;\;\;\;x + \left(\frac{1}{t\_0 - z} - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{t\_0 - y} - \tan a\right)\\
\end{array}
\end{array}
if y < -3e8Initial program 63.3%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
div-sub99.7%
Applied egg-rr99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 66.1%
if -3e8 < y Initial program 87.2%
tan-sum99.7%
clear-num99.7%
Applied egg-rr99.7%
div-sub99.7%
Applied egg-rr99.7%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 76.1%
Final simplification73.8%
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.8%
Final simplification81.8%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- x (/ (sin a) (cos a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x - (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 - (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.sin(a) / Math.cos(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x - (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(sin(a) / cos(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x - (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[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x - \frac{\sin a}{\cos a}
\end{array}
Initial program 81.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in z around 0 73.7%
Taylor expanded in z around inf 41.2%
Final simplification41.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)
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.8%
Taylor expanded in x around inf 31.6%
Final simplification31.6%
herbie shell --seed 2024066
(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))))