
(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 (+ 1.0 t_0))
(/ (* (pow (tan z) 2.0) (pow (tan y) 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 / (1.0 + t_0)) + ((pow(tan(z), 2.0) * pow(tan(y), 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 / (1.0d0 + t_0)) + (((tan(z) ** 2.0d0) * (tan(y) ** 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 / (1.0 + t_0)) + ((Math.pow(Math.tan(z), 2.0) * Math.pow(Math.tan(y), 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 / (1.0 + t_0)) + ((math.pow(math.tan(z), 2.0) * math.pow(math.tan(y), 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(tan(y) + tan(z)) / Float64(Float64(1.0 / Float64(1.0 + t_0)) + Float64(Float64((tan(z) ^ 2.0) * (tan(y) ^ 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 / (1.0 + t_0)) + (((tan(z) ^ 2.0) * (tan(y) ^ 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[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Tan[z], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Tan[y], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $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}{\frac{1}{1 + t\_0} + \frac{{\tan z}^{2} \cdot {\tan y}^{2}}{-1 - t\_0}} - \tan a\right)
\end{array}
\end{array}
Initial program 83.2%
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.8%
Applied egg-rr99.8%
flip--N/A
metadata-evalN/A
div-subN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
tan-lowering-tan.f64N/A
/-lowering-/.f64N/A
Applied egg-rr99.8%
pow-prod-downN/A
pow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
pow2N/A
pow-lowering-pow.f64N/A
tan-lowering-tan.f64N/A
pow-lowering-pow.f64N/A
tan-lowering-tan.f6499.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))) (t_1 (+ x (- t_0 (tan a)))))
(if (<= (tan a) -0.05)
t_1
(if (<= (tan a) 2e-39)
(+ x (- (/ t_0 (fma (tan y) (- 0.0 (tan z)) 1.0)) a))
t_1))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double t_1 = x + (t_0 - tan(a));
double tmp;
if (tan(a) <= -0.05) {
tmp = t_1;
} else if (tan(a) <= 2e-39) {
tmp = x + ((t_0 / fma(tan(y), (0.0 - tan(z)), 1.0)) - a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) t_1 = Float64(x + Float64(t_0 - tan(a))) tmp = 0.0 if (tan(a) <= -0.05) tmp = t_1; elseif (tan(a) <= 2e-39) tmp = Float64(x + Float64(Float64(t_0 / fma(tan(y), Float64(0.0 - tan(z)), 1.0)) - a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.05], t$95$1, If[LessEqual[N[Tan[a], $MachinePrecision], 2e-39], N[(x + N[(N[(t$95$0 / N[(N[Tan[y], $MachinePrecision] * N[(0.0 - N[Tan[z], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
t_1 := x + \left(t\_0 - \tan a\right)\\
\mathbf{if}\;\tan a \leq -0.05:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-39}:\\
\;\;\;\;x + \left(\frac{t\_0}{\mathsf{fma}\left(\tan y, 0 - \tan z, 1\right)} - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003 or 1.99999999999999986e-39 < (tan.f64 a) Initial program 85.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.8%
Applied egg-rr99.8%
Taylor expanded in y around 0
Simplified85.8%
if -0.050000000000000003 < (tan.f64 a) < 1.99999999999999986e-39Initial program 81.1%
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.8%
Applied egg-rr99.8%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
fma-defineN/A
fma-lowering-fma.f64N/A
tan-lowering-tan.f64N/A
neg-lowering-neg.f64N/A
tan-lowering-tan.f6499.8%
Applied egg-rr99.8%
Taylor expanded in a around 0
Simplified99.8%
Final simplification93.1%
(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 83.2%
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.8%
Applied egg-rr99.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))) (t_1 (+ x (- t_0 (tan a)))))
(if (<= a -5e-10)
t_1
(if (<= a 4.8e-39) (+ x (/ t_0 (- 1.0 (* (tan y) (tan z))))) t_1))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double t_1 = x + (t_0 - tan(a));
double tmp;
if (a <= -5e-10) {
tmp = t_1;
} else if (a <= 4.8e-39) {
tmp = x + (t_0 / (1.0 - (tan(y) * tan(z))));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = tan(y) + tan(z)
t_1 = x + (t_0 - tan(a))
if (a <= (-5d-10)) then
tmp = t_1
else if (a <= 4.8d-39) then
tmp = x + (t_0 / (1.0d0 - (tan(y) * tan(z))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan(y) + Math.tan(z);
double t_1 = x + (t_0 - Math.tan(a));
double tmp;
if (a <= -5e-10) {
tmp = t_1;
} else if (a <= 4.8e-39) {
tmp = x + (t_0 / (1.0 - (Math.tan(y) * Math.tan(z))));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) t_1 = x + (t_0 - math.tan(a)) tmp = 0 if a <= -5e-10: tmp = t_1 elif a <= 4.8e-39: tmp = x + (t_0 / (1.0 - (math.tan(y) * math.tan(z)))) else: tmp = t_1 return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) t_1 = Float64(x + Float64(t_0 - tan(a))) tmp = 0.0 if (a <= -5e-10) tmp = t_1; elseif (a <= 4.8e-39) tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z))))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(y) + tan(z); t_1 = x + (t_0 - tan(a)); tmp = 0.0; if (a <= -5e-10) tmp = t_1; elseif (a <= 4.8e-39) tmp = x + (t_0 / (1.0 - (tan(y) * tan(z)))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(t$95$0 - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -5e-10], t$95$1, If[LessEqual[a, 4.8e-39], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
t_1 := x + \left(t\_0 - \tan a\right)\\
\mathbf{if}\;a \leq -5 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 4.8 \cdot 10^{-39}:\\
\;\;\;\;x + \frac{t\_0}{1 - \tan y \cdot \tan z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.00000000000000031e-10 or 4.80000000000000031e-39 < a Initial program 85.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.8%
Applied egg-rr99.8%
Taylor expanded in y around 0
Simplified85.8%
if -5.00000000000000031e-10 < a < 4.80000000000000031e-39Initial program 81.1%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6480.8%
Simplified80.8%
quot-tanN/A
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.3%
Applied egg-rr99.3%
Final simplification92.8%
(FPCore (x y z a) :precision binary64 (+ x (- (+ (tan y) (tan z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((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)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((Math.tan(y) + Math.tan(z)) - Math.tan(a));
}
def code(x, y, z, a): return x + ((math.tan(y) + math.tan(z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(tan(y) + tan(z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((tan(y) + tan(z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) - \tan a\right)
\end{array}
Initial program 83.2%
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.8%
Applied egg-rr99.8%
Taylor expanded in y around 0
Simplified83.5%
Final simplification83.5%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 1e-35) (+ x (- (tan y) (tan a))) (+ x (tan (+ y z)))))
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 = x + tan((y + z));
}
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) <= 1d-35) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + tan((y + z))
end if
code = tmp
end function
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 = x + Math.tan((y + z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 1e-35: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + math.tan((y + z)) return tmp
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(x + tan(Float64(y + z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 1e-35) tmp = x + (tan(y) - tan(a)); else tmp = x + tan((y + z)); end tmp_2 = tmp; end
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[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 10^{-35}:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 1.00000000000000001e-35Initial program 87.9%
Taylor expanded in y around inf
Simplified74.5%
if 1.00000000000000001e-35 < (+.f64 y z) Initial program 76.5%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6449.1%
Simplified49.1%
+-lowering-+.f64N/A
quot-tanN/A
tan-lowering-tan.f64N/A
+-lowering-+.f6449.1%
Applied egg-rr49.1%
Final simplification64.0%
(FPCore (x y z a) :precision binary64 (if (<= z 0.0045) (+ x (- (tan y) (tan a))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= 0.0045) {
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 <= 0.0045d0) 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 <= 0.0045) {
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 <= 0.0045: 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 <= 0.0045) 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 <= 0.0045) 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, 0.0045], 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 0.0045:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if z < 0.00449999999999999966Initial program 89.5%
Taylor expanded in y around inf
Simplified79.3%
if 0.00449999999999999966 < z Initial program 61.5%
Taylor expanded in y around 0
Simplified61.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 83.2%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan a)))) (if (<= a -3.4e-11) t_0 (if (<= a 3.7e-5) (+ 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 <= -3.4e-11) {
tmp = t_0;
} else if (a <= 3.7e-5) {
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 <= (-3.4d-11)) then
tmp = t_0
else if (a <= 3.7d-5) 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 <= -3.4e-11) {
tmp = t_0;
} else if (a <= 3.7e-5) {
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 <= -3.4e-11: tmp = t_0 elif a <= 3.7e-5: 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 <= -3.4e-11) tmp = t_0; elseif (a <= 3.7e-5) 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 <= -3.4e-11) tmp = t_0; elseif (a <= 3.7e-5) 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, -3.4e-11], t$95$0, If[LessEqual[a, 3.7e-5], 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 -3.4 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 3.7 \cdot 10^{-5}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -3.3999999999999999e-11 or 3.69999999999999981e-5 < a Initial program 84.3%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6456.8%
Simplified56.8%
Taylor expanded in z around 0
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6439.6%
Simplified39.6%
tan-quotN/A
--lowering--.f64N/A
tan-lowering-tan.f6439.7%
Applied egg-rr39.7%
if -3.3999999999999999e-11 < a < 3.69999999999999981e-5Initial program 82.2%
Taylor expanded in a around 0
Simplified82.2%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan a)))) (if (<= a -3.4e-11) t_0 (if (<= a 1.45e-5) (+ x (tan (+ y z))) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -3.4e-11) {
tmp = t_0;
} else if (a <= 1.45e-5) {
tmp = x + tan((y + z));
} 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 <= (-3.4d-11)) then
tmp = t_0
else if (a <= 1.45d-5) then
tmp = x + tan((y + z))
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 <= -3.4e-11) {
tmp = t_0;
} else if (a <= 1.45e-5) {
tmp = x + Math.tan((y + z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -3.4e-11: tmp = t_0 elif a <= 1.45e-5: tmp = x + math.tan((y + z)) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -3.4e-11) tmp = t_0; elseif (a <= 1.45e-5) tmp = Float64(x + tan(Float64(y + z))); 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 <= -3.4e-11) tmp = t_0; elseif (a <= 1.45e-5) tmp = x + tan((y + z)); 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, -3.4e-11], t$95$0, If[LessEqual[a, 1.45e-5], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -3.4 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -3.3999999999999999e-11 or 1.45e-5 < a Initial program 84.3%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6456.8%
Simplified56.8%
Taylor expanded in z around 0
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6439.6%
Simplified39.6%
tan-quotN/A
--lowering--.f64N/A
tan-lowering-tan.f6439.7%
Applied egg-rr39.7%
if -3.3999999999999999e-11 < a < 1.45e-5Initial program 82.2%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6481.9%
Simplified81.9%
+-lowering-+.f64N/A
quot-tanN/A
tan-lowering-tan.f64N/A
+-lowering-+.f6481.9%
Applied egg-rr81.9%
Final simplification62.5%
(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 83.2%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6457.5%
Simplified57.5%
Taylor expanded in z around 0
--lowering--.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6441.5%
Simplified41.5%
tan-quotN/A
--lowering--.f64N/A
tan-lowering-tan.f6441.5%
Applied egg-rr41.5%
(FPCore (x y z a) :precision binary64 (+ x (sin y)))
double code(double x, double y, double z, double a) {
return x + sin(y);
}
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)
end function
public static double code(double x, double y, double z, double a) {
return x + Math.sin(y);
}
def code(x, y, z, a): return x + math.sin(y)
function code(x, y, z, a) return Float64(x + sin(y)) end
function tmp = code(x, y, z, a) tmp = x + sin(y); end
code[x_, y_, z_, a_] := N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \sin y
\end{array}
Initial program 83.2%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6454.8%
Simplified54.8%
Taylor expanded in y around 0
Simplified41.6%
Taylor expanded in z around 0
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6433.3%
Simplified33.3%
Final simplification33.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 83.2%
Taylor expanded in x around inf
Simplified33.2%
herbie shell --seed 2024148
(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))))