
(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 a) (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))));
}
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) - ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))));
}
def code(x, y, z, a): return x - (math.tan(a) - ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z))))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - 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]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}\right)
\end{array}
Initial program 82.6%
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
(if (<= (tan a) -5e-11)
(+ x (- (/ 1.0 (/ 1.0 (tan (+ y z)))) (tan a)))
(if (<= (tan a) 1e-21)
(+ (- x a) (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))))
(+ x (- (* (/ 1.0 (cos (+ y z))) (sin (+ y z))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -5e-11) {
tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a));
} else if (tan(a) <= 1e-21) {
tmp = (x - a) + ((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z)))));
} else {
tmp = x + (((1.0 / cos((y + z))) * sin((y + 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 (tan(a) <= (-5d-11)) then
tmp = x + ((1.0d0 / (1.0d0 / tan((y + z)))) - tan(a))
else if (tan(a) <= 1d-21) then
tmp = (x - a) + ((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z)))))
else
tmp = x + (((1.0d0 / cos((y + z))) * sin((y + z))) - tan(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) <= -5e-11) {
tmp = x + ((1.0 / (1.0 / Math.tan((y + z)))) - Math.tan(a));
} else if (Math.tan(a) <= 1e-21) {
tmp = (x - a) + ((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z)))));
} else {
tmp = x + (((1.0 / Math.cos((y + z))) * Math.sin((y + z))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -5e-11: tmp = x + ((1.0 / (1.0 / math.tan((y + z)))) - math.tan(a)) elif math.tan(a) <= 1e-21: tmp = (x - a) + ((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) else: tmp = x + (((1.0 / math.cos((y + z))) * math.sin((y + z))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -5e-11) tmp = Float64(x + Float64(Float64(1.0 / Float64(1.0 / tan(Float64(y + z)))) - tan(a))); elseif (tan(a) <= 1e-21) tmp = Float64(Float64(x - a) + Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))))); else tmp = Float64(x + Float64(Float64(Float64(1.0 / cos(Float64(y + z))) * sin(Float64(y + z))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -5e-11) tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a)); elseif (tan(a) <= 1e-21) tmp = (x - a) + ((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))); else tmp = x + (((1.0 / cos((y + z))) * sin((y + z))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -5e-11], N[(x + N[(N[(1.0 / N[(1.0 / N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-21], N[(N[(x - a), $MachinePrecision] + 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]), $MachinePrecision], N[(x + N[(N[(N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;\left(x - a\right) + \left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\cos \left(y + z\right)} \cdot \sin \left(y + z\right) - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000018e-11Initial program 86.0%
tan-sum99.7%
clear-num99.7%
clear-num99.7%
tan-sum86.1%
Applied egg-rr86.1%
if -5.00000000000000018e-11 < (tan.f64 a) < 9.99999999999999908e-22Initial program 80.5%
associate-+r-80.5%
+-commutative80.5%
associate--l+80.5%
Simplified80.5%
Taylor expanded in a around 0 80.5%
mul-1-neg80.5%
unsub-neg80.5%
Simplified80.5%
tan-sum99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
if 9.99999999999999908e-22 < (tan.f64 a) Initial program 83.4%
tan-quot83.5%
div-inv83.5%
*-commutative83.5%
Applied egg-rr83.5%
Final simplification92.0%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -5e-11)
(+ x (- (/ 1.0 (/ 1.0 (tan (+ y z)))) (tan a)))
(if (<= (tan a) 1e-21)
(+ (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (- x a))
(+ x (- (* (/ 1.0 (cos (+ y z))) (sin (+ y z))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -5e-11) {
tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a));
} else if (tan(a) <= 1e-21) {
tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - a);
} else {
tmp = x + (((1.0 / cos((y + z))) * sin((y + 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 (tan(a) <= (-5d-11)) then
tmp = x + ((1.0d0 / (1.0d0 / tan((y + z)))) - tan(a))
else if (tan(a) <= 1d-21) then
tmp = ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) + (x - a)
else
tmp = x + (((1.0d0 / cos((y + z))) * sin((y + z))) - tan(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) <= -5e-11) {
tmp = x + ((1.0 / (1.0 / Math.tan((y + z)))) - Math.tan(a));
} else if (Math.tan(a) <= 1e-21) {
tmp = ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - a);
} else {
tmp = x + (((1.0 / Math.cos((y + z))) * Math.sin((y + z))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -5e-11: tmp = x + ((1.0 / (1.0 / math.tan((y + z)))) - math.tan(a)) elif math.tan(a) <= 1e-21: tmp = ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) + (x - a) else: tmp = x + (((1.0 / math.cos((y + z))) * math.sin((y + z))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -5e-11) tmp = Float64(x + Float64(Float64(1.0 / Float64(1.0 / tan(Float64(y + z)))) - tan(a))); elseif (tan(a) <= 1e-21) tmp = Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - a)); else tmp = Float64(x + Float64(Float64(Float64(1.0 / cos(Float64(y + z))) * sin(Float64(y + z))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -5e-11) tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a)); elseif (tan(a) <= 1e-21) tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - a); else tmp = x + (((1.0 / cos((y + z))) * sin((y + z))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -5e-11], N[(x + N[(N[(1.0 / N[(1.0 / N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-21], 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[(x - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -5 \cdot 10^{-11}:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\cos \left(y + z\right)} \cdot \sin \left(y + z\right) - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000018e-11Initial program 86.0%
tan-sum99.7%
clear-num99.7%
clear-num99.7%
tan-sum86.1%
Applied egg-rr86.1%
if -5.00000000000000018e-11 < (tan.f64 a) < 9.99999999999999908e-22Initial program 80.5%
associate-+r-80.5%
+-commutative80.5%
associate--l+80.5%
Simplified80.5%
Taylor expanded in a around 0 80.5%
mul-1-neg80.5%
unsub-neg80.5%
Simplified80.5%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 9.99999999999999908e-22 < (tan.f64 a) Initial program 83.4%
tan-quot83.5%
div-inv83.5%
*-commutative83.5%
Applied egg-rr83.5%
Final simplification92.0%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.001)
(+ x (- (/ 1.0 (/ 1.0 (tan (+ y z)))) (tan a)))
(if (<= (tan a) 1e-21)
(+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
(+ x (- (* (/ 1.0 (cos (+ y z))) (sin (+ y z))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.001) {
tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a));
} else if (tan(a) <= 1e-21) {
tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
} else {
tmp = x + (((1.0 / cos((y + z))) * sin((y + 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 (tan(a) <= (-0.001d0)) then
tmp = x + ((1.0d0 / (1.0d0 / tan((y + z)))) - tan(a))
else if (tan(a) <= 1d-21) then
tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
else
tmp = x + (((1.0d0 / cos((y + z))) * sin((y + z))) - tan(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.001) {
tmp = x + ((1.0 / (1.0 / Math.tan((y + z)))) - Math.tan(a));
} else if (Math.tan(a) <= 1e-21) {
tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
} else {
tmp = x + (((1.0 / Math.cos((y + z))) * Math.sin((y + z))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -0.001: tmp = x + ((1.0 / (1.0 / math.tan((y + z)))) - math.tan(a)) elif math.tan(a) <= 1e-21: tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a) else: tmp = x + (((1.0 / math.cos((y + z))) * math.sin((y + z))) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.001) tmp = Float64(x + Float64(Float64(1.0 / Float64(1.0 / tan(Float64(y + z)))) - tan(a))); elseif (tan(a) <= 1e-21) tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a)); else tmp = Float64(x + Float64(Float64(Float64(1.0 / cos(Float64(y + z))) * sin(Float64(y + z))) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (tan(a) <= -0.001) tmp = x + ((1.0 / (1.0 / tan((y + z)))) - tan(a)); elseif (tan(a) <= 1e-21) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a); else tmp = x + (((1.0 / cos((y + z))) * sin((y + z))) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.001], N[(x + N[(N[(1.0 / N[(1.0 / N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 1e-21], 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[(N[(N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.001:\\
\;\;\;\;x + \left(\frac{1}{\frac{1}{\tan \left(y + z\right)}} - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{\cos \left(y + z\right)} \cdot \sin \left(y + z\right) - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -1e-3Initial program 85.6%
tan-sum99.7%
clear-num99.7%
clear-num99.7%
tan-sum85.6%
Applied egg-rr85.6%
if -1e-3 < (tan.f64 a) < 9.99999999999999908e-22Initial program 80.8%
associate-+r-80.8%
+-commutative80.8%
associate--l+80.8%
Simplified80.8%
Taylor expanded in a around 0 80.8%
mul-1-neg80.8%
unsub-neg80.8%
Simplified80.8%
+-commutative80.8%
associate-+l-80.8%
Applied egg-rr80.8%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 9.99999999999999908e-22 < (tan.f64 a) Initial program 83.4%
tan-quot83.5%
div-inv83.5%
*-commutative83.5%
Applied egg-rr83.5%
Final simplification92.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (or (<= a -5.8e-11) (not (<= a 8.5e-50)))
(+
x
(-
(/ t_0 (- 1.0 (/ (tan y) (+ (* z -0.3333333333333333) (/ 1.0 z)))))
(tan a)))
(+ (/ t_0 (fma (tan y) (- (tan z)) 1.0)) (- x a)))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if ((a <= -5.8e-11) || !(a <= 8.5e-50)) {
tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a));
} else {
tmp = (t_0 / fma(tan(y), -tan(z), 1.0)) + (x - a);
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if ((a <= -5.8e-11) || !(a <= 8.5e-50)) tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) / Float64(Float64(z * -0.3333333333333333) + Float64(1.0 / z))))) - tan(a))); else tmp = Float64(Float64(t_0 / fma(tan(y), Float64(-tan(z)), 1.0)) + Float64(x - a)); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -5.8e-11], N[Not[LessEqual[a, 8.5e-50]], $MachinePrecision]], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] / N[(N[(z * -0.3333333333333333), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(N[Tan[y], $MachinePrecision] * (-N[Tan[z], $MachinePrecision]) + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8.5 \cdot 10^{-50}\right):\\
\;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(\tan y, -\tan z, 1\right)} + \left(x - a\right)\\
\end{array}
\end{array}
if a < -5.8e-11 or 8.50000000000000012e-50 < a Initial program 85.2%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
tan-quot99.6%
clear-num99.6%
un-div-inv99.6%
clear-num99.6%
tan-quot99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 85.5%
if -5.8e-11 < a < 8.50000000000000012e-50Initial program 79.7%
associate-+r-79.7%
+-commutative79.7%
associate--l+79.7%
Simplified79.7%
Taylor expanded in a around 0 79.7%
mul-1-neg79.7%
unsub-neg79.7%
Simplified79.7%
tan-sum99.8%
div-inv99.8%
fma-def99.8%
sub-neg99.8%
+-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.8%
Applied egg-rr99.8%
fma-udef99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification92.2%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (or (<= a -5.8e-11) (not (<= a 8e-50)))
(+
x
(-
(/ t_0 (- 1.0 (/ (tan y) (+ (* z -0.3333333333333333) (/ 1.0 z)))))
(tan a)))
(+ (- x a) (* t_0 (/ 1.0 (- 1.0 (* (tan y) (tan z)))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if ((a <= -5.8e-11) || !(a <= 8e-50)) {
tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a));
} else {
tmp = (x - a) + (t_0 * (1.0 / (1.0 - (tan(y) * tan(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) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if ((a <= (-5.8d-11)) .or. (.not. (a <= 8d-50))) then
tmp = x + ((t_0 / (1.0d0 - (tan(y) / ((z * (-0.3333333333333333d0)) + (1.0d0 / z))))) - tan(a))
else
tmp = (x - a) + (t_0 * (1.0d0 / (1.0d0 - (tan(y) * tan(z)))))
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 tmp;
if ((a <= -5.8e-11) || !(a <= 8e-50)) {
tmp = x + ((t_0 / (1.0 - (Math.tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - Math.tan(a));
} else {
tmp = (x - a) + (t_0 * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z)))));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if (a <= -5.8e-11) or not (a <= 8e-50): tmp = x + ((t_0 / (1.0 - (math.tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - math.tan(a)) else: tmp = (x - a) + (t_0 * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if ((a <= -5.8e-11) || !(a <= 8e-50)) tmp = Float64(x + Float64(Float64(t_0 / Float64(1.0 - Float64(tan(y) / Float64(Float64(z * -0.3333333333333333) + Float64(1.0 / z))))) - tan(a))); else tmp = Float64(Float64(x - a) + Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(y) + tan(z); tmp = 0.0; if ((a <= -5.8e-11) || ~((a <= 8e-50))) tmp = x + ((t_0 / (1.0 - (tan(y) / ((z * -0.3333333333333333) + (1.0 / z))))) - tan(a)); else tmp = (x - a) + (t_0 * (1.0 / (1.0 - (tan(y) * tan(z))))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -5.8e-11], N[Not[LessEqual[a, 8e-50]], $MachinePrecision]], N[(x + N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] / N[(N[(z * -0.3333333333333333), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - a), $MachinePrecision] + N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;a \leq -5.8 \cdot 10^{-11} \lor \neg \left(a \leq 8 \cdot 10^{-50}\right):\\
\;\;\;\;x + \left(\frac{t_0}{1 - \frac{\tan y}{z \cdot -0.3333333333333333 + \frac{1}{z}}} - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - a\right) + t_0 \cdot \frac{1}{1 - \tan y \cdot \tan z}\\
\end{array}
\end{array}
if a < -5.8e-11 or 8.00000000000000006e-50 < a Initial program 85.2%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
tan-quot99.6%
clear-num99.6%
un-div-inv99.6%
clear-num99.6%
tan-quot99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 85.5%
if -5.8e-11 < a < 8.00000000000000006e-50Initial program 79.7%
associate-+r-79.7%
+-commutative79.7%
associate--l+79.7%
Simplified79.7%
Taylor expanded in a around 0 79.7%
mul-1-neg79.7%
unsub-neg79.7%
Simplified79.7%
tan-sum99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification92.2%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (tan (+ y z)))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - tan((y + z)));
}
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) - tan((y + z)))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - Math.tan((y + z)));
}
def code(x, y, z, a): return x - (math.tan(a) - math.tan((y + z)))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - tan(Float64(y + z)))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - tan((y + z))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \tan \left(y + z\right)\right)
\end{array}
Initial program 82.6%
Final simplification82.6%
(FPCore (x y z a) :precision binary64 (if (<= a -1.5) (exp (- (log (/ 1.0 x)))) (if (<= a 1.55) (- x (- a (tan (+ y z)))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.5) {
tmp = exp(-log((1.0 / x)));
} else if (a <= 1.55) {
tmp = x - (a - tan((y + z)));
} else {
tmp = x;
}
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.5d0)) then
tmp = exp(-log((1.0d0 / x)))
else if (a <= 1.55d0) then
tmp = x - (a - tan((y + z)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.5) {
tmp = Math.exp(-Math.log((1.0 / x)));
} else if (a <= 1.55) {
tmp = x - (a - Math.tan((y + z)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.5: tmp = math.exp(-math.log((1.0 / x))) elif a <= 1.55: tmp = x - (a - math.tan((y + z))) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.5) tmp = exp(Float64(-log(Float64(1.0 / x)))); elseif (a <= 1.55) tmp = Float64(x - Float64(a - tan(Float64(y + z)))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.5) tmp = exp(-log((1.0 / x))); elseif (a <= 1.55) tmp = x - (a - tan((y + z))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.5], N[Exp[(-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[a, 1.55], N[(x - N[(a - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5:\\
\;\;\;\;e^{-\log \left(\frac{1}{x}\right)}\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.5Initial program 83.2%
associate-+r-83.2%
+-commutative83.2%
associate--l+83.2%
Simplified83.2%
Taylor expanded in a around 0 5.5%
mul-1-neg5.5%
unsub-neg5.5%
Simplified5.5%
add-exp-log_binary645.5%
Applied rewrite-once5.5%
Taylor expanded in x around inf 20.9%
if -1.5 < a < 1.55000000000000004Initial program 81.8%
associate-+r-81.8%
+-commutative81.8%
associate--l+81.8%
Simplified81.8%
Taylor expanded in a around 0 81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
+-commutative81.2%
associate-+l-81.3%
Applied egg-rr81.3%
if 1.55000000000000004 < a Initial program 83.8%
Taylor expanded in x around inf 22.0%
Final simplification52.8%
(FPCore (x y z a) :precision binary64 (if (<= a -1.6) x (if (<= a 1.55) (+ (- x a) (tan (+ y z))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.6) {
tmp = x;
} else if (a <= 1.55) {
tmp = (x - a) + tan((y + z));
} else {
tmp = x;
}
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.6d0)) then
tmp = x
else if (a <= 1.55d0) then
tmp = (x - a) + tan((y + z))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.6) {
tmp = x;
} else if (a <= 1.55) {
tmp = (x - a) + Math.tan((y + z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.6: tmp = x elif a <= 1.55: tmp = (x - a) + math.tan((y + z)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.6) tmp = x; elseif (a <= 1.55) tmp = Float64(Float64(x - a) + tan(Float64(y + z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.6) tmp = x; elseif (a <= 1.55) tmp = (x - a) + tan((y + z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.6], x, If[LessEqual[a, 1.55], N[(N[(x - a), $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;\left(x - a\right) + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.6000000000000001 or 1.55000000000000004 < a Initial program 83.5%
Taylor expanded in x around inf 21.5%
if -1.6000000000000001 < a < 1.55000000000000004Initial program 81.8%
associate-+r-81.8%
+-commutative81.8%
associate--l+81.8%
Simplified81.8%
Taylor expanded in a around 0 81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
Final simplification52.8%
(FPCore (x y z a) :precision binary64 (if (<= a -1.55) x (if (<= a 1.55) (- x (- a (tan (+ y z)))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 1.55) {
tmp = x - (a - tan((y + z)));
} else {
tmp = x;
}
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.55d0)) then
tmp = x
else if (a <= 1.55d0) then
tmp = x - (a - tan((y + z)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.55) {
tmp = x;
} else if (a <= 1.55) {
tmp = x - (a - Math.tan((y + z)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.55: tmp = x elif a <= 1.55: tmp = x - (a - math.tan((y + z))) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.55) tmp = x; elseif (a <= 1.55) tmp = Float64(x - Float64(a - tan(Float64(y + z)))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.55) tmp = x; elseif (a <= 1.55) tmp = x - (a - tan((y + z))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.55], x, If[LessEqual[a, 1.55], N[(x - N[(a - N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;x - \left(a - \tan \left(y + z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.55000000000000004 < a Initial program 83.5%
Taylor expanded in x around inf 21.5%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 81.8%
associate-+r-81.8%
+-commutative81.8%
associate--l+81.8%
Simplified81.8%
Taylor expanded in a around 0 81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
+-commutative81.2%
associate-+l-81.3%
Applied egg-rr81.3%
Final simplification52.8%
(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 82.6%
Taylor expanded in x around inf 31.9%
Final simplification31.9%
herbie shell --seed 2023297
(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))))