
(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 9 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 (+ x (- (/ (+ (/ (sin y) (cos y)) (tan z)) (fma (- (tan z)) (tan y) 1.0)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + ((((sin(y) / cos(y)) + tan(z)) / fma(-tan(z), tan(y), 1.0)) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(Float64(sin(y) / cos(y)) + tan(z)) / fma(Float64(-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[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\frac{\sin y}{\cos y} + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - \tan a\right)
\end{array}
Initial program 76.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
+-commutativeN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-/.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.f6499.7
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
lift-tan.f64N/A
tan-quotN/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (fma (- (tan z)) (tan y) 1.0)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / fma(-tan(z), tan(y), 1.0)) - tan(a));
}
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / fma(Float64(-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[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan y + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)} - \tan a\right)
\end{array}
Initial program 76.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
+-commutativeN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-/.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.f6499.7
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) 1.0) (tan 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(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(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(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(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)) / 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(y) + tan(z)) / 1.0) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / 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 y + \tan z}{1} - \tan a\right)
\end{array}
Initial program 76.9%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
+-commutativeN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-/.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.f6499.7
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites77.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 z) 1e-35) (+ x (- (tan y) (tan a))) (- (tan (* z (- (/ y z) -1.0))) (- x))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 1e-35) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = tan((z * ((y / z) - -1.0))) - -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) <= 1d-35) then
tmp = x + (tan(y) - tan(a))
else
tmp = tan((z * ((y / z) - (-1.0d0)))) - -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) <= 1e-35) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = Math.tan((z * ((y / z) - -1.0))) - -x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= 1e-35: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = math.tan((z * ((y / z) - -1.0))) - -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) <= 1e-35) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(tan(Float64(z * Float64(Float64(y / z) - -1.0))) - Float64(-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) <= 1e-35)
tmp = x + (tan(y) - tan(a));
else
tmp = tan((z * ((y / z) - -1.0))) - -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], 1e-35], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(z * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 10^{-35}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z \cdot \left(\frac{y}{z} - -1\right)\right) - \left(-x\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 1.00000000000000001e-35Initial program 79.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6466.3
Applied rewrites66.3%
Applied rewrites66.3%
if 1.00000000000000001e-35 < (+.f64 y z) Initial program 72.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--.f6472.7
Applied rewrites72.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6448.4
Applied rewrites48.4%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6437.4
Applied rewrites37.4%
Final simplification53.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 (<= z 6.4e-8) (+ x (- (tan y) (tan a))) (+ (- (tan z) (tan a)) x)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 6.4e-8) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (tan(z) - tan(a)) + 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 (z <= 6.4d-8) then
tmp = x + (tan(y) - tan(a))
else
tmp = (tan(z) - tan(a)) + 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 (z <= 6.4e-8) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (Math.tan(z) - Math.tan(a)) + x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if z <= 6.4e-8: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (math.tan(z) - math.tan(a)) + x return tmp
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) tmp = 0.0 if (z <= 6.4e-8) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(tan(z) - tan(a)) + 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 (z <= 6.4e-8)
tmp = x + (tan(y) - tan(a));
else
tmp = (tan(z) - tan(a)) + 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[z, 6.4e-8], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.4 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan z - \tan a\right) + x\\
\end{array}
\end{array}
if z < 6.4000000000000004e-8Initial program 83.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6473.0
Applied rewrites73.0%
Applied rewrites73.0%
if 6.4000000000000004e-8 < z Initial program 59.3%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
+-commutativeN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-/.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lower-+.f6499.7
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.2
Applied rewrites59.2%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6459.2
Applied rewrites59.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 (- (tan (+ y z)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan((y + z)) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 76.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 (<= (+ y z) -1.0)
(- (tan (+ z y)) (- x))
(if (<= (+ y z) 1e-35)
(- (+ y x) (tan a))
(- (tan (* z (- (/ y z) -1.0))) (- x)))))assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -1.0) {
tmp = tan((z + y)) - -x;
} else if ((y + z) <= 1e-35) {
tmp = (y + x) - tan(a);
} else {
tmp = tan((z * ((y / z) - -1.0))) - -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) <= (-1.0d0)) then
tmp = tan((z + y)) - -x
else if ((y + z) <= 1d-35) then
tmp = (y + x) - tan(a)
else
tmp = tan((z * ((y / z) - (-1.0d0)))) - -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) <= -1.0) {
tmp = Math.tan((z + y)) - -x;
} else if ((y + z) <= 1e-35) {
tmp = (y + x) - Math.tan(a);
} else {
tmp = Math.tan((z * ((y / z) - -1.0))) - -x;
}
return tmp;
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): tmp = 0 if (y + z) <= -1.0: tmp = math.tan((z + y)) - -x elif (y + z) <= 1e-35: tmp = (y + x) - math.tan(a) else: tmp = math.tan((z * ((y / z) - -1.0))) - -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) <= -1.0) tmp = Float64(tan(Float64(z + y)) - Float64(-x)); elseif (Float64(y + z) <= 1e-35) tmp = Float64(Float64(y + x) - tan(a)); else tmp = Float64(tan(Float64(z * Float64(Float64(y / z) - -1.0))) - Float64(-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) <= -1.0)
tmp = tan((z + y)) - -x;
elseif ((y + z) <= 1e-35)
tmp = (y + x) - tan(a);
else
tmp = tan((z * ((y / z) - -1.0))) - -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], -1.0], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 1e-35], N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(z * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -1:\\
\;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\
\mathbf{elif}\;y + z \leq 10^{-35}:\\
\;\;\;\;\left(y + x\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z \cdot \left(\frac{y}{z} - -1\right)\right) - \left(-x\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -1Initial program 68.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--.f6468.7
Applied rewrites68.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6441.0
Applied rewrites41.0%
if -1 < (+.f64 y z) < 1.00000000000000001e-35Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites99.8%
Applied rewrites99.8%
if 1.00000000000000001e-35 < (+.f64 y z) Initial program 72.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--.f6472.7
Applied rewrites72.7%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6448.4
Applied rewrites48.4%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6437.4
Applied rewrites37.4%
Final simplification51.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 (or (<= (+ y z) -1.0) (not (<= (+ y z) 1e-35))) (- (tan (+ z y)) (- x)) (- (+ y x) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
double tmp;
if (((y + z) <= -1.0) || !((y + z) <= 1e-35)) {
tmp = tan((z + y)) - -x;
} else {
tmp = (y + x) - 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) <= (-1.0d0)) .or. (.not. ((y + z) <= 1d-35))) then
tmp = tan((z + y)) - -x
else
tmp = (y + x) - 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) <= -1.0) || !((y + z) <= 1e-35)) {
tmp = Math.tan((z + y)) - -x;
} else {
tmp = (y + x) - 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) <= -1.0) or not ((y + z) <= 1e-35): tmp = math.tan((z + y)) - -x else: tmp = (y + x) - 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) <= -1.0) || !(Float64(y + z) <= 1e-35)) tmp = Float64(tan(Float64(z + y)) - Float64(-x)); else tmp = Float64(Float64(y + x) - 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) <= -1.0) || ~(((y + z) <= 1e-35)))
tmp = tan((z + y)) - -x;
else
tmp = (y + x) - 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[Or[LessEqual[N[(y + z), $MachinePrecision], -1.0], N[Not[LessEqual[N[(y + z), $MachinePrecision], 1e-35]], $MachinePrecision]], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision], N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -1 \lor \neg \left(y + z \leq 10^{-35}\right):\\
\;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) - \tan a\\
\end{array}
\end{array}
if (+.f64 y z) < -1 or 1.00000000000000001e-35 < (+.f64 y z) Initial program 71.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--.f6470.9
Applied rewrites70.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6445.0
Applied rewrites45.0%
if -1 < (+.f64 y z) < 1.00000000000000001e-35Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites99.8%
Applied rewrites99.8%
Final simplification56.2%
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (- (+ y x) (tan a)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
return (y + x) - 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 = (y + x) - tan(a)
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
return (y + x) - Math.tan(a);
}
[x, y, z, a] = sort([x, y, z, a]) def code(x, y, z, a): return (y + x) - math.tan(a)
x, y, z, a = sort([x, y, z, a]) function code(x, y, z, a) return Float64(Float64(y + x) - tan(a)) end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
tmp = (y + x) - tan(a);
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(y + x), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\left(y + x\right) - \tan a
\end{array}
Initial program 76.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.1
Applied rewrites59.1%
Taylor expanded in y around 0
Applied rewrites30.2%
Applied rewrites30.2%
herbie shell --seed 2024340
(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))))