
(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 11 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}
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan 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));
}
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
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));
}
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))
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
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a)); end
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 + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 74.2%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.002)
(fabs (+ t_0 (- x (tan a))))
(if (<= (tan a) 2e-11)
(+ x (- (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))) a))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.002) {
tmp = fabs((t_0 + (x - tan(a))));
} else if (tan(a) <= 2e-11) {
tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a);
} else {
tmp = x + (t_0 - tan(a));
}
return tmp;
}
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 + z))
if (tan(a) <= (-0.002d0)) then
tmp = abs((t_0 + (x - tan(a))))
else if (tan(a) <= 2d-11) then
tmp = x + (((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z))))) - a)
else
tmp = x + (t_0 - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = Math.abs((t_0 + (x - Math.tan(a))));
} else if (Math.tan(a) <= 2e-11) {
tmp = x + (((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z))))) - a);
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.002: tmp = math.fabs((t_0 + (x - math.tan(a)))) elif math.tan(a) <= 2e-11: tmp = x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) - a) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.002) tmp = abs(Float64(t_0 + Float64(x - tan(a)))); elseif (tan(a) <= 2e-11) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))) - a)); else tmp = Float64(x + Float64(t_0 - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.002) tmp = abs((t_0 + (x - tan(a)))); elseif (tan(a) <= 2e-11) tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Abs[N[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-11], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;\left|t\_0 + \left(x - \tan a\right)\right|\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 80.2%
+-commutative80.2%
sub-neg80.2%
associate-+l+80.2%
tan-quot80.2%
div-inv80.1%
fma-define80.1%
neg-mul-180.1%
fma-define80.1%
Applied egg-rr80.1%
fma-undefine80.1%
associate-*r/80.2%
*-rgt-identity80.2%
+-commutative80.2%
+-commutative80.2%
fma-undefine80.2%
neg-mul-180.2%
+-commutative80.2%
sub-neg80.2%
Simplified80.2%
add-sqr-sqrt79.8%
sqrt-unprod80.4%
pow280.4%
+-commutative80.4%
quot-tan80.4%
+-commutative80.4%
Applied egg-rr80.4%
unpow280.4%
rem-sqrt-square80.4%
+-commutative80.4%
Simplified80.4%
if -2e-3 < (tan.f64 a) < 1.99999999999999988e-11Initial program 76.2%
Taylor expanded in a around 0 76.2%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
if 1.99999999999999988e-11 < (tan.f64 a) Initial program 64.1%
Final simplification86.3%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= (tan a) -0.002)
(fabs (+ t_0 (- x (tan a))))
(if (<= (tan a) 2e-11)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- t_0 (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if (tan(a) <= -0.002) {
tmp = fabs((t_0 + (x - tan(a))));
} else if (tan(a) <= 2e-11) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (t_0 - tan(a));
}
return tmp;
}
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 + z))
if (tan(a) <= (-0.002d0)) then
tmp = abs((t_0 + (x - tan(a))))
else if (tan(a) <= 2d-11) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (t_0 - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if (Math.tan(a) <= -0.002) {
tmp = Math.abs((t_0 + (x - Math.tan(a))));
} else if (Math.tan(a) <= 2e-11) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (t_0 - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if math.tan(a) <= -0.002: tmp = math.fabs((t_0 + (x - math.tan(a)))) elif math.tan(a) <= 2e-11: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (t_0 - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if (tan(a) <= -0.002) tmp = abs(Float64(t_0 + Float64(x - tan(a)))); elseif (tan(a) <= 2e-11) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(t_0 - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if (tan(a) <= -0.002) tmp = abs((t_0 + (x - tan(a)))); elseif (tan(a) <= 2e-11) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + (t_0 - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Abs[N[(t$95$0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-11], 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[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;\left|t\_0 + \left(x - \tan a\right)\right|\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 80.2%
+-commutative80.2%
sub-neg80.2%
associate-+l+80.2%
tan-quot80.2%
div-inv80.1%
fma-define80.1%
neg-mul-180.1%
fma-define80.1%
Applied egg-rr80.1%
fma-undefine80.1%
associate-*r/80.2%
*-rgt-identity80.2%
+-commutative80.2%
+-commutative80.2%
fma-undefine80.2%
neg-mul-180.2%
+-commutative80.2%
sub-neg80.2%
Simplified80.2%
add-sqr-sqrt79.8%
sqrt-unprod80.4%
pow280.4%
+-commutative80.4%
quot-tan80.4%
+-commutative80.4%
Applied egg-rr80.4%
unpow280.4%
rem-sqrt-square80.4%
+-commutative80.4%
Simplified80.4%
if -2e-3 < (tan.f64 a) < 1.99999999999999988e-11Initial program 76.2%
Taylor expanded in a around 0 76.2%
tan-sum99.7%
div-inv99.7%
fma-neg99.7%
Applied egg-rr99.7%
fma-undefine99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
if 1.99999999999999988e-11 < (tan.f64 a) Initial program 64.1%
Final simplification86.3%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.002) (not (<= (tan a) 2e-17))) (+ x (- (tan y) (tan a))) (- (+ x (tan (+ y z))) a)))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.002) || !(tan(a) <= 2e-17)) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (x + tan((y + z))) - a;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((tan(a) <= (-0.002d0)) .or. (.not. (tan(a) <= 2d-17))) then
tmp = x + (tan(y) - tan(a))
else
tmp = (x + tan((y + z))) - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.002) || !(Math.tan(a) <= 2e-17)) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (x + Math.tan((y + z))) - a;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.002) or not (math.tan(a) <= 2e-17): tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (x + math.tan((y + z))) - a return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.002) || !(tan(a) <= 2e-17)) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(x + tan(Float64(y + z))) - a); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.002) || ~((tan(a) <= 2e-17))) tmp = x + (tan(y) - tan(a)); else tmp = (x + tan((y + z))) - a; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 2e-17]], $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}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.002 \lor \neg \left(\tan a \leq 2 \cdot 10^{-17}\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) < -2e-3 or 2.00000000000000014e-17 < (tan.f64 a) Initial program 71.8%
Taylor expanded in z around 0 57.3%
tan-quot57.3%
*-un-lft-identity57.3%
Applied egg-rr57.3%
*-lft-identity57.3%
Simplified57.3%
if -2e-3 < (tan.f64 a) < 2.00000000000000014e-17Initial program 76.5%
Taylor expanded in a around 0 76.5%
associate-+r-76.6%
Applied egg-rr76.6%
Final simplification67.1%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -500.0) (+ x (- (tan y) (tan a))) (+ (tan z) (- x (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -500.0) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = tan(z) + (x - tan(a));
}
return tmp;
}
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) <= (-500.0d0)) then
tmp = x + (tan(y) - tan(a))
else
tmp = tan(z) + (x - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -500.0) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = Math.tan(z) + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -500.0: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = math.tan(z) + (x - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -500.0) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(tan(z) + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -500.0) tmp = x + (tan(y) - tan(a)); else tmp = tan(z) + (x - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -500.0], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -500:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan z + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -500Initial program 56.1%
Taylor expanded in z around 0 43.2%
tan-quot43.3%
*-un-lft-identity43.3%
Applied egg-rr43.3%
*-lft-identity43.3%
Simplified43.3%
if -500 < (+.f64 y z) Initial program 83.7%
Taylor expanded in y around 0 70.3%
+-commutative70.3%
associate--l+70.3%
Simplified70.3%
tan-quot70.3%
tan-quot70.3%
associate-+r-70.3%
Applied egg-rr70.3%
associate-+r-70.3%
Simplified70.3%
Final simplification61.0%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -500.0) (+ x (- (tan y) (tan a))) (- (+ x (tan z)) (tan a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -500.0) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = (x + tan(z)) - tan(a);
}
return tmp;
}
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) <= (-500.0d0)) then
tmp = x + (tan(y) - tan(a))
else
tmp = (x + tan(z)) - tan(a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -500.0) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = (x + Math.tan(z)) - Math.tan(a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -500.0: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = (x + math.tan(z)) - math.tan(a) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -500.0) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(Float64(x + tan(z)) - tan(a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -500.0) tmp = x + (tan(y) - tan(a)); else tmp = (x + tan(z)) - tan(a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -500.0], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -500:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \tan z\right) - \tan a\\
\end{array}
\end{array}
if (+.f64 y z) < -500Initial program 56.1%
Taylor expanded in z around 0 43.2%
tan-quot43.3%
*-un-lft-identity43.3%
Applied egg-rr43.3%
*-lft-identity43.3%
Simplified43.3%
if -500 < (+.f64 y z) Initial program 83.7%
Taylor expanded in y around 0 70.3%
+-commutative70.3%
associate--l+70.3%
Simplified70.3%
tan-quot70.3%
tan-quot70.3%
associate-+r-70.3%
Applied egg-rr70.3%
Final simplification61.0%
(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}
Initial program 74.2%
Final simplification74.2%
(FPCore (x y z a) :precision binary64 (if (or (<= a -0.165) (not (<= a 0.035))) (+ x (- y (tan a))) (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.165) || !(a <= 0.035)) {
tmp = x + (y - tan(a));
} else {
tmp = x + (tan((y + z)) - a);
}
return tmp;
}
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.165d0)) .or. (.not. (a <= 0.035d0))) then
tmp = x + (y - tan(a))
else
tmp = x + (tan((y + z)) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.165) || !(a <= 0.035)) {
tmp = x + (y - Math.tan(a));
} else {
tmp = x + (Math.tan((y + z)) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -0.165) or not (a <= 0.035): tmp = x + (y - math.tan(a)) else: tmp = x + (math.tan((y + z)) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.165) || !(a <= 0.035)) tmp = Float64(x + Float64(y - tan(a))); else tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -0.165) || ~((a <= 0.035))) tmp = x + (y - tan(a)); else tmp = x + (tan((y + z)) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.165], N[Not[LessEqual[a, 0.035]], $MachinePrecision]], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.165 \lor \neg \left(a \leq 0.035\right):\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\end{array}
\end{array}
if a < -0.165000000000000008 or 0.035000000000000003 < a Initial program 71.9%
Taylor expanded in z around 0 57.2%
Taylor expanded in y around 0 31.4%
if -0.165000000000000008 < a < 0.035000000000000003Initial program 76.3%
Taylor expanded in a around 0 76.1%
Final simplification54.4%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.46) (not (<= a 3.1))) (+ x (- y (tan a))) (- (+ x (tan (+ y z))) a)))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.46) || !(a <= 3.1)) {
tmp = x + (y - tan(a));
} else {
tmp = (x + tan((y + z))) - a;
}
return tmp;
}
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.46d0)) .or. (.not. (a <= 3.1d0))) then
tmp = x + (y - tan(a))
else
tmp = (x + tan((y + z))) - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.46) || !(a <= 3.1)) {
tmp = x + (y - Math.tan(a));
} else {
tmp = (x + Math.tan((y + z))) - a;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -1.46) or not (a <= 3.1): tmp = x + (y - math.tan(a)) else: tmp = (x + math.tan((y + z))) - a return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.46) || !(a <= 3.1)) tmp = Float64(x + Float64(y - tan(a))); else tmp = Float64(Float64(x + tan(Float64(y + z))) - a); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -1.46) || ~((a <= 3.1))) tmp = x + (y - tan(a)); else tmp = (x + tan((y + z))) - a; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.46], N[Not[LessEqual[a, 3.1]], $MachinePrecision]], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.46 \lor \neg \left(a \leq 3.1\right):\\
\;\;\;\;x + \left(y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\
\end{array}
\end{array}
if a < -1.46 or 3.10000000000000009 < a Initial program 71.9%
Taylor expanded in z around 0 57.2%
Taylor expanded in y around 0 31.4%
if -1.46 < a < 3.10000000000000009Initial program 76.3%
Taylor expanded in a around 0 76.1%
associate-+r-76.1%
Applied egg-rr76.1%
Final simplification54.5%
(FPCore (x y z a) :precision binary64 (if (<= y -1.45) x (+ x (- y (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.45) {
tmp = x;
} else {
tmp = x + (y - tan(a));
}
return tmp;
}
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 <= (-1.45d0)) then
tmp = x
else
tmp = x + (y - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -1.45) {
tmp = x;
} else {
tmp = x + (y - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -1.45: tmp = x else: tmp = x + (y - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -1.45) tmp = x; else tmp = Float64(x + Float64(y - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -1.45) tmp = x; else tmp = x + (y - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -1.45], x, N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - \tan a\right)\\
\end{array}
\end{array}
if y < -1.44999999999999996Initial program 49.0%
Taylor expanded in x around inf 22.9%
if -1.44999999999999996 < y Initial program 83.5%
Taylor expanded in z around 0 63.7%
Taylor expanded in y around 0 45.7%
Final simplification39.6%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
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
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 74.2%
Taylor expanded in x around inf 34.7%
Final simplification34.7%
herbie shell --seed 2024036
(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))))