
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (/ (sin y) (cos y)) (tan z)) (- 1.0 (* (tan z) (tan y)))) (tan a))))
assert(y < z);
double code(double x, double y, double z, double a) {
return x + ((((sin(y) / cos(y)) + tan(z)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
}
NOTE: y and z 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(y) / cos(y)) + tan(z)) / (1.0d0 - (tan(z) * tan(y)))) - tan(a))
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
return x + ((((Math.sin(y) / Math.cos(y)) + Math.tan(z)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
[y, z] = sort([y, z]) def code(x, y, z, a): return x + ((((math.sin(y) / math.cos(y)) + math.tan(z)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
y, z = sort([y, z]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(Float64(sin(y) / cos(y)) + tan(z)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a))) end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z, a)
tmp = x + ((((sin(y) / cos(y)) + tan(z)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
end
NOTE: y and z 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[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
x + \left(\frac{\frac{\sin y}{\cos y} + \tan z}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 78.3%
tan-sum99.7%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
tan-quot99.6%
div-inv99.6%
fma-def99.7%
Applied egg-rr99.7%
fma-udef99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
NOTE: y and z should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan z) (tan y))))
(if (or (<= (tan a) -0.005) (not (<= (tan a) 0.00015)))
(fma t_0 1.0 (- x (tan a)))
(+ (/ t_0 (- 1.0 (* (tan z) (tan y)))) (- x a)))))assert(y < z);
double code(double x, double y, double z, double a) {
double t_0 = tan(z) + tan(y);
double tmp;
if ((tan(a) <= -0.005) || !(tan(a) <= 0.00015)) {
tmp = fma(t_0, 1.0, (x - tan(a)));
} else {
tmp = (t_0 / (1.0 - (tan(z) * tan(y)))) + (x - a);
}
return tmp;
}
y, z = sort([y, z]) function code(x, y, z, a) t_0 = Float64(tan(z) + tan(y)) tmp = 0.0 if ((tan(a) <= -0.005) || !(tan(a) <= 0.00015)) tmp = fma(t_0, 1.0, Float64(x - tan(a))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(z) * tan(y)))) + Float64(x - a)); end return tmp end
NOTE: y and z should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.005], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.00015]], $MachinePrecision]], N[(t$95$0 * 1.0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
t_0 := \tan z + \tan y\\
\mathbf{if}\;\tan a \leq -0.005 \lor \neg \left(\tan a \leq 0.00015\right):\\
\;\;\;\;\mathsf{fma}\left(t_0, 1, x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \tan z \cdot \tan y} + \left(x - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0050000000000000001 or 1.49999999999999987e-4 < (tan.f64 a) Initial program 78.0%
associate-+r-77.8%
+-commutative77.8%
associate--l+77.9%
Simplified77.9%
add-cbrt-cube77.5%
pow377.5%
Applied egg-rr77.5%
tan-sum98.8%
rem-cbrt-cube99.4%
div-inv99.4%
fma-def99.4%
+-commutative99.4%
*-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 78.3%
if -0.0050000000000000001 < (tan.f64 a) < 1.49999999999999987e-4Initial program 78.7%
associate-+r-78.7%
+-commutative78.7%
associate--l+78.7%
Simplified78.7%
Taylor expanded in a around 0 78.7%
mul-1-neg78.7%
unsub-neg78.7%
Simplified78.7%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.7%
Final simplification88.1%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (tan a))))
assert(y < z);
double code(double x, double y, double z, double a) {
return x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
}
NOTE: y and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - tan(a))
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
[y, z] = sort([y, z]) def code(x, y, z, a): return x + (((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
y, z = sort([y, z]) function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a))) end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z, a)
tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a));
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 78.3%
tan-sum99.7%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.005) (not (<= (tan a) 0.0002))) (+ x (- (tan y) (tan a))) (- (+ x (tan (+ y z))) a)))
assert(y < z);
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.005) || !(tan(a) <= 0.0002)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (x + tan((y + z))) - a;
}
return tmp;
}
NOTE: y and z 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.005d0)) .or. (.not. (tan(a) <= 0.0002d0))) then
tmp = x + (tan(y) - tan(a))
else
tmp = (x + tan((y + z))) - a
end if
code = tmp
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.005) || !(Math.tan(a) <= 0.0002)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (x + Math.tan((y + z))) - a;
}
return tmp;
}
[y, z] = sort([y, z]) def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.005) or not (math.tan(a) <= 0.0002): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (x + math.tan((y + z))) - a return tmp
y, z = sort([y, z]) function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.005) || !(tan(a) <= 0.0002)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(x + tan(Float64(y + z))) - a); end return tmp end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if ((tan(a) <= -0.005) || ~((tan(a) <= 0.0002)))
tmp = x + (tan(y) - tan(a));
else
tmp = (x + tan((y + z))) - a;
end
tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.005], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.0002]], $MachinePrecision]], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.005 \lor \neg \left(\tan a \leq 0.0002\right):\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0050000000000000001 or 2.0000000000000001e-4 < (tan.f64 a) Initial program 77.8%
Taylor expanded in z around 0 60.4%
tan-quot60.4%
tan-quot60.5%
associate--l+60.5%
Applied egg-rr60.5%
if -0.0050000000000000001 < (tan.f64 a) < 2.0000000000000001e-4Initial program 78.8%
associate-+r-78.8%
+-commutative78.8%
associate--l+78.8%
Simplified78.8%
Taylor expanded in a around 0 78.7%
mul-1-neg78.7%
unsub-neg78.7%
Simplified78.7%
associate-+r-78.7%
Applied egg-rr78.7%
Final simplification68.9%
NOTE: y and z should be sorted in increasing order before calling this function.
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.005)
(+ x (- (tan y) (tan a)))
(if (<= (tan a) 0.0002)
(- (+ x (tan (+ y z))) a)
(+ (tan y) (- x (tan a))))))assert(y < z);
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.005) {
tmp = x + (tan(y) - tan(a));
} else if (tan(a) <= 0.0002) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = tan(y) + (x - tan(a));
}
return tmp;
}
NOTE: y and z 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.005d0)) then
tmp = x + (tan(y) - tan(a))
else if (tan(a) <= 0.0002d0) then
tmp = (x + tan((y + z))) - a
else
tmp = tan(y) + (x - tan(a))
end if
code = tmp
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
double tmp;
if (Math.tan(a) <= -0.005) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else if (Math.tan(a) <= 0.0002) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = Math.tan(y) + (x - Math.tan(a));
}
return tmp;
}
[y, z] = sort([y, z]) def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.005: tmp = x + (math.tan(y) - math.tan(a)) elif math.tan(a) <= 0.0002: tmp = (x + math.tan((y + z))) - a else: tmp = math.tan(y) + (x - math.tan(a)) return tmp
y, z = sort([y, z]) function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.005) tmp = Float64(x + Float64(tan(y) - tan(a))); elseif (tan(a) <= 0.0002) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = Float64(tan(y) + Float64(x - tan(a))); end return tmp end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (tan(a) <= -0.005)
tmp = x + (tan(y) - tan(a));
elseif (tan(a) <= 0.0002)
tmp = (x + tan((y + z))) - a;
else
tmp = tan(y) + (x - tan(a));
end
tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.005], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 0.0002], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], N[(N[Tan[y], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.005:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 0.0002:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;\tan y + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0050000000000000001Initial program 81.1%
Taylor expanded in z around 0 62.0%
tan-quot62.1%
tan-quot62.1%
associate--l+62.2%
Applied egg-rr62.2%
if -0.0050000000000000001 < (tan.f64 a) < 2.0000000000000001e-4Initial program 78.8%
associate-+r-78.8%
+-commutative78.8%
associate--l+78.8%
Simplified78.8%
Taylor expanded in a around 0 78.7%
mul-1-neg78.7%
unsub-neg78.7%
Simplified78.7%
associate-+r-78.7%
Applied egg-rr78.7%
if 2.0000000000000001e-4 < (tan.f64 a) Initial program 73.8%
Taylor expanded in z around 0 58.4%
tan-quot58.4%
tan-quot58.5%
associate--l+58.5%
Applied egg-rr58.5%
associate-+r-58.5%
+-commutative58.5%
associate--l+58.5%
Simplified58.5%
Final simplification68.9%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (fma (+ (tan z) (tan y)) 1.0 (- x (tan a))))
assert(y < z);
double code(double x, double y, double z, double a) {
return fma((tan(z) + tan(y)), 1.0, (x - tan(a)));
}
y, z = sort([y, z]) function code(x, y, z, a) return fma(Float64(tan(z) + tan(y)), 1.0, Float64(x - tan(a))) end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] * 1.0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\mathsf{fma}\left(\tan z + \tan y, 1, x - \tan a\right)
\end{array}
Initial program 78.3%
associate-+r-78.2%
+-commutative78.2%
associate--l+78.2%
Simplified78.2%
add-cbrt-cube77.8%
pow377.8%
Applied egg-rr77.8%
tan-sum99.0%
rem-cbrt-cube99.6%
div-inv99.6%
fma-def99.6%
+-commutative99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 78.7%
Final simplification78.7%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
assert(y < z);
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
NOTE: y and z 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 y < z;
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
[y, z] = sort([y, z]) def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
y, z = sort([y, z]) function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z, a)
tmp = x + (tan((y + z)) - tan(a));
end
NOTE: y and z 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}
[y, z] = \mathsf{sort}([y, z])\\
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 78.3%
Final simplification78.3%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= a -1.55) x (if (<= a 0.059) (+ (- x a) (tan (+ y z))) x)))
assert(y < z);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 0.059) {
tmp = (x - a) + tan((y + z));
} else {
tmp = x;
}
return tmp;
}
NOTE: y and z 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 <= 0.059d0) then
tmp = (x - a) + tan((y + z))
else
tmp = x
end if
code = tmp
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 0.059) {
tmp = (x - a) + Math.tan((y + z));
} else {
tmp = x;
}
return tmp;
}
[y, z] = sort([y, z]) def code(x, y, z, a): tmp = 0 if a <= -1.55: tmp = x elif a <= 0.059: tmp = (x - a) + math.tan((y + z)) else: tmp = x return tmp
y, z = sort([y, z]) function code(x, y, z, a) tmp = 0.0 if (a <= -1.55) tmp = x; elseif (a <= 0.059) tmp = Float64(Float64(x - a) + tan(Float64(y + z))); else tmp = x; end return tmp end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (a <= -1.55)
tmp = x;
elseif (a <= 0.059)
tmp = (x - a) + tan((y + z));
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[a, -1.55], x, If[LessEqual[a, 0.059], N[(N[(x - a), $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 0.059:\\
\;\;\;\;\left(x - a\right) + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 0.058999999999999997 < a Initial program 77.8%
Taylor expanded in x around inf 22.5%
if -1.55000000000000004 < a < 0.058999999999999997Initial program 78.8%
associate-+r-78.8%
+-commutative78.8%
associate--l+78.8%
Simplified78.8%
Taylor expanded in a around 0 78.7%
mul-1-neg78.7%
unsub-neg78.7%
Simplified78.7%
Final simplification48.4%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 (if (<= a -2.2) x (if (<= a 0.059) (- (+ x (tan (+ y z))) a) x)))
assert(y < z);
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2) {
tmp = x;
} else if (a <= 0.059) {
tmp = (x + tan((y + z))) - a;
} else {
tmp = x;
}
return tmp;
}
NOTE: y and z 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.2d0)) then
tmp = x
else if (a <= 0.059d0) then
tmp = (x + tan((y + z))) - a
else
tmp = x
end if
code = tmp
end function
assert y < z;
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -2.2) {
tmp = x;
} else if (a <= 0.059) {
tmp = (x + Math.tan((y + z))) - a;
} else {
tmp = x;
}
return tmp;
}
[y, z] = sort([y, z]) def code(x, y, z, a): tmp = 0 if a <= -2.2: tmp = x elif a <= 0.059: tmp = (x + math.tan((y + z))) - a else: tmp = x return tmp
y, z = sort([y, z]) function code(x, y, z, a) tmp = 0.0 if (a <= -2.2) tmp = x; elseif (a <= 0.059) tmp = Float64(Float64(x + tan(Float64(y + z))) - a); else tmp = x; end return tmp end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z, a)
tmp = 0.0;
if (a <= -2.2)
tmp = x;
elseif (a <= 0.059)
tmp = (x + tan((y + z))) - a;
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := If[LessEqual[a, -2.2], x, If[LessEqual[a, 0.059], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision], x]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 0.059:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.2000000000000002 or 0.058999999999999997 < a Initial program 77.8%
Taylor expanded in x around inf 22.5%
if -2.2000000000000002 < a < 0.058999999999999997Initial program 78.8%
associate-+r-78.8%
+-commutative78.8%
associate--l+78.8%
Simplified78.8%
Taylor expanded in a around 0 78.7%
mul-1-neg78.7%
unsub-neg78.7%
Simplified78.7%
associate-+r-78.7%
Applied egg-rr78.7%
Final simplification48.4%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z a) :precision binary64 x)
assert(y < z);
double code(double x, double y, double z, double a) {
return x;
}
NOTE: y and z 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 y < z;
public static double code(double x, double y, double z, double a) {
return x;
}
[y, z] = sort([y, z]) def code(x, y, z, a): return x
y, z = sort([y, z]) function code(x, y, z, a) return x end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z, a)
tmp = x;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, a_] := x
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
x
\end{array}
Initial program 78.3%
Taylor expanded in x around inf 29.7%
Final simplification29.7%
herbie shell --seed 2023278
(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))))