
(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 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (+ 1.0 (- -1.0 (fma (tan y) (tan z) -1.0)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 + (-1.0 - fma(tan(y), tan(z), -1.0)))) - tan(a));
}
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 + Float64(-1.0 - fma(tan(y), tan(z), -1.0)))) - 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[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 + \left(-1 - \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)} - \tan a\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%
expm1-log1p-u95.0%
expm1-udef95.0%
log1p-udef95.0%
add-exp-log99.7%
Applied egg-rr99.7%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -5e-11)
(+ x (- (tan (+ y z)) (tan a)))
(if (<= (tan a) 1e-21)
(+ (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))) (- x a))
(+ x (- (* (sin (+ y z)) (/ 1.0 (cos (+ y z)))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -5e-11) {
tmp = x + (tan((y + z)) - tan(a));
} else if (tan(a) <= 1e-21) {
tmp = ((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) + (x - a);
} else {
tmp = x + ((sin((y + z)) * (1.0 / cos((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 + (tan((y + z)) - tan(a))
else if (tan(a) <= 1d-21) then
tmp = ((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z))))) + (x - a)
else
tmp = x + ((sin((y + z)) * (1.0d0 / cos((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 + (Math.tan((y + z)) - Math.tan(a));
} else if (Math.tan(a) <= 1e-21) {
tmp = ((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z))))) + (x - a);
} else {
tmp = x + ((Math.sin((y + z)) * (1.0 / Math.cos((y + z)))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -5e-11: tmp = x + (math.tan((y + z)) - math.tan(a)) elif math.tan(a) <= 1e-21: tmp = ((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) + (x - a) else: tmp = x + ((math.sin((y + z)) * (1.0 / math.cos((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(tan(Float64(y + z)) - tan(a))); elseif (tan(a) <= 1e-21) tmp = Float64(Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))) + Float64(x - a)); else tmp = Float64(x + Float64(Float64(sin(Float64(y + z)) * Float64(1.0 / cos(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 + (tan((y + z)) - tan(a)); elseif (tan(a) <= 1e-21) tmp = ((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) + (x - a); else tmp = x + ((sin((y + z)) * (1.0 / cos((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[Tan[N[(y + z), $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[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $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(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{elif}\;\tan a \leq 10^{-21}:\\
\;\;\;\;\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\sin \left(y + z\right) \cdot \frac{1}{\cos \left(y + z\right)} - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000018e-11Initial program 86.0%
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%
if 9.99999999999999908e-22 < (tan.f64 a) Initial program 83.4%
tan-quot83.4%
div-inv83.4%
Applied egg-rr83.5%
Final simplification92.0%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -5e-11)
(+ x (- (tan (+ y z)) (tan a)))
(if (<= (tan a) 1e-21)
(+ (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (- x a))
(+ x (- (* (sin (+ y z)) (/ 1.0 (cos (+ y z)))) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -5e-11) {
tmp = x + (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 + ((sin((y + z)) * (1.0 / cos((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 + (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 + ((sin((y + z)) * (1.0d0 / cos((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 + (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 + ((Math.sin((y + z)) * (1.0 / Math.cos((y + z)))) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if math.tan(a) <= -5e-11: tmp = x + (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 + ((math.sin((y + z)) * (1.0 / math.cos((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(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(sin(Float64(y + z)) * Float64(1.0 / cos(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 + (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 + ((sin((y + z)) * (1.0 / cos((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[Tan[N[(y + z), $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[Sin[N[(y + z), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[N[(y + z), $MachinePrecision]], $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(\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(\sin \left(y + z\right) \cdot \frac{1}{\cos \left(y + z\right)} - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -5.00000000000000018e-11Initial program 86.0%
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%
fma-def99.8%
Applied egg-rr99.8%
fma-udef99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
if 9.99999999999999908e-22 < (tan.f64 a) Initial program 83.4%
tan-quot83.4%
div-inv83.4%
Applied egg-rr83.5%
Final simplification92.0%
(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 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 (or (<= (tan a) -0.05) (not (<= (tan a) 0.02))) (+ (sin z) (- x (tan a))) (+ (tan (+ y z)) (- x a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.05) || !(tan(a) <= 0.02)) {
tmp = sin(z) + (x - tan(a));
} else {
tmp = tan((y + z)) + (x - 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.05d0)) .or. (.not. (tan(a) <= 0.02d0))) then
tmp = sin(z) + (x - tan(a))
else
tmp = tan((y + z)) + (x - 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.05) || !(Math.tan(a) <= 0.02)) {
tmp = Math.sin(z) + (x - Math.tan(a));
} else {
tmp = Math.tan((y + z)) + (x - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.05) or not (math.tan(a) <= 0.02): tmp = math.sin(z) + (x - math.tan(a)) else: tmp = math.tan((y + z)) + (x - a) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.05) || !(tan(a) <= 0.02)) tmp = Float64(sin(z) + Float64(x - tan(a))); else tmp = Float64(tan(Float64(y + z)) + Float64(x - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.05) || ~((tan(a) <= 0.02))) tmp = sin(z) + (x - tan(a)); else tmp = tan((y + z)) + (x - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.05], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.02]], $MachinePrecision]], N[(N[Sin[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.05 \lor \neg \left(\tan a \leq 0.02\right):\\
\;\;\;\;\sin z + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(y + z\right) + \left(x - a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -0.050000000000000003 or 0.0200000000000000004 < (tan.f64 a) Initial program 83.5%
associate-+r-83.4%
+-commutative83.4%
associate--l+83.4%
Simplified83.4%
tan-quot83.4%
div-inv83.4%
Applied egg-rr83.4%
Taylor expanded in z around 0 64.4%
mul-1-neg64.4%
unsub-neg64.4%
Simplified64.4%
Taylor expanded in y around 0 42.4%
if -0.050000000000000003 < (tan.f64 a) < 0.0200000000000000004Initial 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 simplification62.7%
(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 82.6%
Final simplification82.6%
(FPCore (x y z a) :precision binary64 (if (<= a -1.25) x (if (<= a 1.55) (+ (tan (+ y z)) (- x a)) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (a <= -1.25) {
tmp = x;
} else if (a <= 1.55) {
tmp = tan((y + z)) + (x - a);
} 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.25d0)) then
tmp = x
else if (a <= 1.55d0) then
tmp = tan((y + z)) + (x - a)
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.25) {
tmp = x;
} else if (a <= 1.55) {
tmp = Math.tan((y + z)) + (x - a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if a <= -1.25: tmp = x elif a <= 1.55: tmp = math.tan((y + z)) + (x - a) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (a <= -1.25) tmp = x; elseif (a <= 1.55) tmp = Float64(tan(Float64(y + z)) + Float64(x - a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (a <= -1.25) tmp = x; elseif (a <= 1.55) tmp = tan((y + z)) + (x - a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[a, -1.25], x, If[LessEqual[a, 1.55], N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(x - a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.25:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55:\\
\;\;\;\;\tan \left(y + z\right) + \left(x - a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.25 or 1.55000000000000004 < a Initial program 83.5%
Taylor expanded in x around inf 21.5%
if -1.25 < 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 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))))