
(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 13 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
(let* ((t_0 (* (tan y) (tan z))))
(+
x
(-
(* (/ (+ (tan y) (tan z)) (- 1.0 (pow t_0 2.0))) (+ 1.0 t_0))
(tan a)))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) * tan(z);
return x + ((((tan(y) + tan(z)) / (1.0 - pow(t_0, 2.0))) * (1.0 + t_0)) - 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
real(8) :: t_0
t_0 = tan(y) * tan(z)
code = x + ((((tan(y) + tan(z)) / (1.0d0 - (t_0 ** 2.0d0))) * (1.0d0 + t_0)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) * Math.tan(z);
return x + ((((Math.tan(y) + Math.tan(z)) / (1.0 - Math.pow(t_0, 2.0))) * (1.0 + t_0)) - Math.tan(a));
}
def code(x, y, z, a): t_0 = math.tan(y) * math.tan(z) return x + ((((math.tan(y) + math.tan(z)) / (1.0 - math.pow(t_0, 2.0))) * (1.0 + t_0)) - math.tan(a))
function code(x, y, z, a) t_0 = Float64(tan(y) * tan(z)) return Float64(x + Float64(Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - (t_0 ^ 2.0))) * Float64(1.0 + t_0)) - tan(a))) end
function tmp = code(x, y, z, a) t_0 = tan(y) * tan(z); tmp = x + ((((tan(y) + tan(z)) / (1.0 - (t_0 ^ 2.0))) * (1.0 + t_0)) - tan(a)); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y \cdot \tan z\\
x + \left(\frac{\tan y + \tan z}{1 - {t\_0}^{2}} \cdot \left(1 + t\_0\right) - \tan a\right)
\end{array}
\end{array}
Initial program 81.7%
tan-sumN/A
flip--N/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (/ (tan y) (cos z)) (sin z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - ((tan(y) / cos(z)) * sin(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) / cos(z)) * sin(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.cos(z)) * Math.sin(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.tan(y) / math.cos(z)) * math.sin(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(Float64(tan(y) / cos(z)) * sin(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - ((tan(y) / cos(z)) * sin(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[(N[Tan[y], $MachinePrecision] / N[Cos[z], $MachinePrecision]), $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\tan y}{\cos z} \cdot \sin z} - \tan a\right)
\end{array}
Initial program 81.7%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
*-commutativeN/A
tan-quotN/A
tan-quotN/A
frac-timesN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.7%
Applied egg-rr99.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/r*N/A
tan-quotN/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
cos-lowering-cos.f64N/A
sin-lowering-sin.f6499.7%
Applied egg-rr99.7%
(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 81.7%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (<= a -0.0002)
(+ x (- t_0 (/ (sin a) (cos a))))
(if (<= a 1.65e-32)
(+ 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 (a <= -0.0002) {
tmp = x + (t_0 - (sin(a) / cos(a)));
} else if (a <= 1.65e-32) {
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 (a <= (-0.0002d0)) then
tmp = x + (t_0 - (sin(a) / cos(a)))
else if (a <= 1.65d-32) 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 (a <= -0.0002) {
tmp = x + (t_0 - (Math.sin(a) / Math.cos(a)));
} else if (a <= 1.65e-32) {
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 a <= -0.0002: tmp = x + (t_0 - (math.sin(a) / math.cos(a))) elif a <= 1.65e-32: 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 (a <= -0.0002) tmp = Float64(x + Float64(t_0 - Float64(sin(a) / cos(a)))); elseif (a <= 1.65e-32) 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 (a <= -0.0002) tmp = x + (t_0 - (sin(a) / cos(a))); elseif (a <= 1.65e-32) 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[a, -0.0002], N[(x + N[(t$95$0 - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.65e-32], 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}\;a \leq -0.0002:\\
\;\;\;\;x + \left(t\_0 - \frac{\sin a}{\cos a}\right)\\
\mathbf{elif}\;a \leq 1.65 \cdot 10^{-32}:\\
\;\;\;\;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 a < -2.0000000000000001e-4Initial program 87.8%
tan-quotN/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6487.8%
Applied egg-rr87.8%
if -2.0000000000000001e-4 < a < 1.65000000000000013e-32Initial program 81.1%
Taylor expanded in a around 0
Simplified81.1%
tan-sumN/A
tan-quotN/A
un-div-invN/A
+-commutativeN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
un-div-invN/A
tan-quotN/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
tan-quotN/A
un-div-invN/A
*-commutativeN/A
*-lowering-*.f64N/A
un-div-invN/A
tan-quotN/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
if 1.65000000000000013e-32 < a Initial program 76.7%
Final simplification90.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ x (- (tan y) (tan a)))))
(if (<= (tan a) -0.05)
t_0
(if (<= (tan a) 2e-26)
(+ x (+ (tan (+ y z)) (* a (- -1.0 (* a (* a 0.3333333333333333))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x + (tan(y) - tan(a));
double tmp;
if (tan(a) <= -0.05) {
tmp = t_0;
} else if (tan(a) <= 2e-26) {
tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333)))));
} else {
tmp = t_0;
}
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 = x + (tan(y) - tan(a))
if (tan(a) <= (-0.05d0)) then
tmp = t_0
else if (tan(a) <= 2d-26) then
tmp = x + (tan((y + z)) + (a * ((-1.0d0) - (a * (a * 0.3333333333333333d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x + (Math.tan(y) - Math.tan(a));
double tmp;
if (Math.tan(a) <= -0.05) {
tmp = t_0;
} else if (Math.tan(a) <= 2e-26) {
tmp = x + (Math.tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x + (math.tan(y) - math.tan(a)) tmp = 0 if math.tan(a) <= -0.05: tmp = t_0 elif math.tan(a) <= 2e-26: tmp = x + (math.tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333))))) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x + Float64(tan(y) - tan(a))) tmp = 0.0 if (tan(a) <= -0.05) tmp = t_0; elseif (tan(a) <= 2e-26) tmp = Float64(x + Float64(tan(Float64(y + z)) + Float64(a * Float64(-1.0 - Float64(a * Float64(a * 0.3333333333333333)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x + (tan(y) - tan(a)); tmp = 0.0; if (tan(a) <= -0.05) tmp = t_0; elseif (tan(a) <= 2e-26) tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 2e-26], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(a * N[(-1.0 - N[(a * N[(a * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(\tan y - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-26}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) + a \cdot \left(-1 - a \cdot \left(a \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003 or 2.0000000000000001e-26 < (tan.f64 a) Initial program 81.9%
Taylor expanded in y around inf
Simplified65.3%
if -0.050000000000000003 < (tan.f64 a) < 2.0000000000000001e-26Initial program 81.5%
Taylor expanded in a around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6481.5%
Simplified81.5%
Final simplification72.7%
(FPCore (x y z a) :precision binary64 (if (<= z 4.5e-20) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 4.5e-20) {
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 (z <= 4.5d-20) 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 (z <= 4.5e-20) {
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 z <= 4.5e-20: 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 (z <= 4.5e-20) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= 4.5e-20) 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[z, 4.5e-20], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if z < 4.5000000000000001e-20Initial program 88.2%
Taylor expanded in y around inf
Simplified77.5%
if 4.5000000000000001e-20 < z Initial program 59.6%
Taylor expanded in y around 0
Simplified58.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 81.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= a -0.125)
t_0
(if (<= a 0.16)
(+
x
(+
(tan (+ y z))
(*
a
(-
-1.0
(*
a
(* a (+ 0.3333333333333333 (* (* a a) 0.13333333333333333))))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.125) {
tmp = t_0;
} else if (a <= 0.16) {
tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * (0.3333333333333333 + ((a * a) * 0.13333333333333333)))))));
} else {
tmp = t_0;
}
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 = x - tan(a)
if (a <= (-0.125d0)) then
tmp = t_0
else if (a <= 0.16d0) then
tmp = x + (tan((y + z)) + (a * ((-1.0d0) - (a * (a * (0.3333333333333333d0 + ((a * a) * 0.13333333333333333d0)))))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan(a);
double tmp;
if (a <= -0.125) {
tmp = t_0;
} else if (a <= 0.16) {
tmp = x + (Math.tan((y + z)) + (a * (-1.0 - (a * (a * (0.3333333333333333 + ((a * a) * 0.13333333333333333)))))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -0.125: tmp = t_0 elif a <= 0.16: tmp = x + (math.tan((y + z)) + (a * (-1.0 - (a * (a * (0.3333333333333333 + ((a * a) * 0.13333333333333333))))))) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.125) tmp = t_0; elseif (a <= 0.16) tmp = Float64(x + Float64(tan(Float64(y + z)) + Float64(a * Float64(-1.0 - Float64(a * Float64(a * Float64(0.3333333333333333 + Float64(Float64(a * a) * 0.13333333333333333)))))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x - tan(a); tmp = 0.0; if (a <= -0.125) tmp = t_0; elseif (a <= 0.16) tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * (0.3333333333333333 + ((a * a) * 0.13333333333333333))))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.125], t$95$0, If[LessEqual[a, 0.16], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(a * N[(-1.0 - N[(a * N[(a * N[(0.3333333333333333 + N[(N[(a * a), $MachinePrecision] * 0.13333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.125:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.16:\\
\;\;\;\;x + \left(\tan \left(y + z\right) + a \cdot \left(-1 - a \cdot \left(a \cdot \left(0.3333333333333333 + \left(a \cdot a\right) \cdot 0.13333333333333333\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.125 or 0.160000000000000003 < a Initial program 81.5%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
+-commutativeN/A
tan-quotN/A
div-invN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
tan-lowering-tan.f6499.6%
Applied egg-rr99.6%
associate-+r-N/A
+-commutativeN/A
un-div-invN/A
tan-quotN/A
tan-sumN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
tan-lowering-tan.f6481.3%
Applied egg-rr81.3%
Taylor expanded in x around inf
Simplified49.7%
if -0.125 < a < 0.160000000000000003Initial program 82.0%
Taylor expanded in a around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6482.0%
Simplified82.0%
Final simplification64.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= a -0.06)
t_0
(if (<= a 0.125)
(+ x (+ (tan (+ y z)) (* a (- -1.0 (* a (* a 0.3333333333333333))))))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.06) {
tmp = t_0;
} else if (a <= 0.125) {
tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333)))));
} else {
tmp = t_0;
}
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 = x - tan(a)
if (a <= (-0.06d0)) then
tmp = t_0
else if (a <= 0.125d0) then
tmp = x + (tan((y + z)) + (a * ((-1.0d0) - (a * (a * 0.3333333333333333d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan(a);
double tmp;
if (a <= -0.06) {
tmp = t_0;
} else if (a <= 0.125) {
tmp = x + (Math.tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -0.06: tmp = t_0 elif a <= 0.125: tmp = x + (math.tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333))))) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.06) tmp = t_0; elseif (a <= 0.125) tmp = Float64(x + Float64(tan(Float64(y + z)) + Float64(a * Float64(-1.0 - Float64(a * Float64(a * 0.3333333333333333)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x - tan(a); tmp = 0.0; if (a <= -0.06) tmp = t_0; elseif (a <= 0.125) tmp = x + (tan((y + z)) + (a * (-1.0 - (a * (a * 0.3333333333333333))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.06], t$95$0, If[LessEqual[a, 0.125], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(a * N[(-1.0 - N[(a * N[(a * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.06:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.125:\\
\;\;\;\;x + \left(\tan \left(y + z\right) + a \cdot \left(-1 - a \cdot \left(a \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.059999999999999998 or 0.125 < a Initial program 81.5%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
+-commutativeN/A
tan-quotN/A
div-invN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
tan-lowering-tan.f6499.6%
Applied egg-rr99.6%
associate-+r-N/A
+-commutativeN/A
un-div-invN/A
tan-quotN/A
tan-sumN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
tan-lowering-tan.f6481.3%
Applied egg-rr81.3%
Taylor expanded in x around inf
Simplified49.7%
if -0.059999999999999998 < a < 0.125Initial program 82.0%
Taylor expanded in a around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6482.0%
Simplified82.0%
Final simplification64.8%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan a)))) (if (<= a -0.0142) t_0 (if (<= a 0.009) (+ x (- (tan (+ y z)) a)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.0142) {
tmp = t_0;
} else if (a <= 0.009) {
tmp = x + (tan((y + z)) - a);
} else {
tmp = t_0;
}
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 = x - tan(a)
if (a <= (-0.0142d0)) then
tmp = t_0
else if (a <= 0.009d0) then
tmp = x + (tan((y + z)) - a)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan(a);
double tmp;
if (a <= -0.0142) {
tmp = t_0;
} else if (a <= 0.009) {
tmp = x + (Math.tan((y + z)) - a);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -0.0142: tmp = t_0 elif a <= 0.009: tmp = x + (math.tan((y + z)) - a) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.0142) tmp = t_0; elseif (a <= 0.009) tmp = Float64(x + Float64(tan(Float64(y + z)) - a)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x - tan(a); tmp = 0.0; if (a <= -0.0142) tmp = t_0; elseif (a <= 0.009) tmp = x + (tan((y + z)) - a); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0142], t$95$0, If[LessEqual[a, 0.009], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.0142:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.009:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.014200000000000001 or 0.00899999999999999932 < a Initial program 81.5%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
+-commutativeN/A
tan-quotN/A
div-invN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
tan-lowering-tan.f6499.6%
Applied egg-rr99.6%
associate-+r-N/A
+-commutativeN/A
un-div-invN/A
tan-quotN/A
tan-sumN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
tan-lowering-tan.f6481.3%
Applied egg-rr81.3%
Taylor expanded in x around inf
Simplified49.7%
if -0.014200000000000001 < a < 0.00899999999999999932Initial program 82.0%
Taylor expanded in a around 0
Simplified81.4%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan a)))) (if (<= a -0.0046) t_0 (if (<= a 0.0125) (+ x (- (tan y) a)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.0046) {
tmp = t_0;
} else if (a <= 0.0125) {
tmp = x + (tan(y) - a);
} else {
tmp = t_0;
}
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 = x - tan(a)
if (a <= (-0.0046d0)) then
tmp = t_0
else if (a <= 0.0125d0) then
tmp = x + (tan(y) - a)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan(a);
double tmp;
if (a <= -0.0046) {
tmp = t_0;
} else if (a <= 0.0125) {
tmp = x + (Math.tan(y) - a);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -0.0046: tmp = t_0 elif a <= 0.0125: tmp = x + (math.tan(y) - a) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.0046) tmp = t_0; elseif (a <= 0.0125) tmp = Float64(x + Float64(tan(y) - a)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x - tan(a); tmp = 0.0; if (a <= -0.0046) tmp = t_0; elseif (a <= 0.0125) tmp = x + (tan(y) - a); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.0046], t$95$0, If[LessEqual[a, 0.0125], N[(x + N[(N[Tan[y], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.0046:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.0125:\\
\;\;\;\;x + \left(\tan y - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.0045999999999999999 or 0.012500000000000001 < a Initial program 81.5%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
+-commutativeN/A
tan-quotN/A
div-invN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
tan-lowering-tan.f6499.6%
Applied egg-rr99.6%
associate-+r-N/A
+-commutativeN/A
un-div-invN/A
tan-quotN/A
tan-sumN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
tan-lowering-tan.f6481.3%
Applied egg-rr81.3%
Taylor expanded in x around inf
Simplified49.7%
if -0.0045999999999999999 < a < 0.012500000000000001Initial program 82.0%
Taylor expanded in a around 0
Simplified81.4%
Taylor expanded in y around inf
Simplified65.1%
(FPCore (x y z a) :precision binary64 (- x (tan a)))
double code(double x, double y, double z, double a) {
return x - 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(a)
end function
public static double code(double x, double y, double z, double a) {
return x - Math.tan(a);
}
def code(x, y, z, a): return x - math.tan(a)
function code(x, y, z, a) return Float64(x - tan(a)) end
function tmp = code(x, y, z, a) tmp = x - tan(a); end
code[x_, y_, z_, a_] := N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \tan a
\end{array}
Initial program 81.7%
tan-sumN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
+-commutativeN/A
tan-quotN/A
div-invN/A
fma-defineN/A
fma-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
tan-lowering-tan.f6499.7%
Applied egg-rr99.7%
associate-+r-N/A
+-commutativeN/A
un-div-invN/A
tan-quotN/A
tan-sumN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
tan-lowering-tan.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
tan-lowering-tan.f6481.6%
Applied egg-rr81.6%
Taylor expanded in x around inf
Simplified47.3%
(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 81.7%
Taylor expanded in x around inf
Simplified32.6%
herbie shell --seed 2024139
(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))))