
(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 (let* ((t_0 (- 1.0 (* (tan z) (tan y))))) (+ x (+ (/ (tan y) t_0) (- (/ (tan z) t_0) (tan a))))))
double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (tan(z) * tan(y));
return x + ((tan(y) / t_0) + ((tan(z) / 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 = 1.0d0 - (tan(z) * tan(y))
code = x + ((tan(y) / t_0) + ((tan(z) / t_0) - tan(a)))
end function
public static double code(double x, double y, double z, double a) {
double t_0 = 1.0 - (Math.tan(z) * Math.tan(y));
return x + ((Math.tan(y) / t_0) + ((Math.tan(z) / t_0) - Math.tan(a)));
}
def code(x, y, z, a): t_0 = 1.0 - (math.tan(z) * math.tan(y)) return x + ((math.tan(y) / t_0) + ((math.tan(z) / t_0) - math.tan(a)))
function code(x, y, z, a) t_0 = Float64(1.0 - Float64(tan(z) * tan(y))) return Float64(x + Float64(Float64(tan(y) / t_0) + Float64(Float64(tan(z) / t_0) - tan(a)))) end
function tmp = code(x, y, z, a) t_0 = 1.0 - (tan(z) * tan(y)); tmp = x + ((tan(y) / t_0) + ((tan(z) / t_0) - tan(a))); end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[Tan[y], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Tan[z], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan z \cdot \tan y\\
x + \left(\frac{\tan y}{t\_0} + \left(\frac{\tan z}{t\_0} - \tan a\right)\right)
\end{array}
\end{array}
Initial program 84.0%
lift--.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
div-addN/A
associate--l+N/A
lower-+.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
Applied rewrites99.6%
(FPCore (x y z a)
:precision binary64
(if (<= (tan a) -0.002)
(fma (/ (- (/ (sin (+ z y)) (cos (+ z y))) (/ (sin a) (cos a))) x) x x)
(if (<= (tan a) 4e-34)
(-
(fma
(- (+ (/ (+ (tan y) (tan z)) (* (fma (- (tan z)) (tan y) 1.0) x)) 1.0))
x
a))
(+ x (- (tan (+ y z)) (tan a))))))
double code(double x, double y, double z, double a) {
double tmp;
if (tan(a) <= -0.002) {
tmp = fma((((sin((z + y)) / cos((z + y))) - (sin(a) / cos(a))) / x), x, x);
} else if (tan(a) <= 4e-34) {
tmp = -fma(-(((tan(y) + tan(z)) / (fma(-tan(z), tan(y), 1.0) * x)) + 1.0), x, a);
} else {
tmp = x + (tan((y + z)) - tan(a));
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if (tan(a) <= -0.002) tmp = fma(Float64(Float64(Float64(sin(Float64(z + y)) / cos(Float64(z + y))) - Float64(sin(a) / cos(a))) / x), x, x); elseif (tan(a) <= 4e-34) tmp = Float64(-fma(Float64(-Float64(Float64(Float64(tan(y) + tan(z)) / Float64(fma(Float64(-tan(z)), tan(y), 1.0) * x)) + 1.0)), x, a)); else tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); end return tmp end
code[x_, y_, z_, a_] := If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(N[(N[(N[(N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision] / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 4e-34], (-N[((-N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]) * x + a), $MachinePrecision]), N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} - \frac{\sin a}{\cos a}}{x}, x, x\right)\\
\mathbf{elif}\;\tan a \leq 4 \cdot 10^{-34}:\\
\;\;\;\;-\mathsf{fma}\left(-\left(\frac{\tan y + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\right) \cdot x} + 1\right), x, a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 a) < -2e-3Initial program 90.5%
Taylor expanded in x around inf
associate--l+N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites90.6%
if -2e-3 < (tan.f64 a) < 3.99999999999999971e-34Initial program 81.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites81.6%
Taylor expanded in a around 0
Applied rewrites81.5%
Applied rewrites99.5%
if 3.99999999999999971e-34 < (tan.f64 a) Initial program 81.0%
Final simplification92.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan z) (tan y)) (- 1.0 (* (tan z) (tan y)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - 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(z) + tan(y)) / (1.0d0 - (tan(z) * tan(y)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(z) + Math.tan(y)) / (1.0 - (Math.tan(z) * Math.tan(y)))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(z) + math.tan(y)) / (1.0 - (math.tan(z) * math.tan(y)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(z) + tan(y)) / Float64(1.0 - Float64(tan(z) * tan(y)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(z) + tan(y)) / (1.0 - (tan(z) * tan(y)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y} - \tan a\right)
\end{array}
Initial program 84.0%
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-tan.f64N/A
lower-tan.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-tan.f64N/A
lower-tan.f6499.6
Applied rewrites99.6%
(FPCore (x y z a)
:precision binary64
(if (or (<= a -0.00018) (not (<= a 1e-31)))
(+ x (- (tan (+ y z)) (tan a)))
(-
(fma
(- (+ (/ (+ (tan y) (tan z)) (* (fma (- (tan z)) (tan y) 1.0) x)) 1.0))
x
a))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -0.00018) || !(a <= 1e-31)) {
tmp = x + (tan((y + z)) - tan(a));
} else {
tmp = -fma(-(((tan(y) + tan(z)) / (fma(-tan(z), tan(y), 1.0) * x)) + 1.0), x, a);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -0.00018) || !(a <= 1e-31)) tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a))); else tmp = Float64(-fma(Float64(-Float64(Float64(Float64(tan(y) + tan(z)) / Float64(fma(Float64(-tan(z)), tan(y), 1.0) * x)) + 1.0)), x, a)); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.00018], N[Not[LessEqual[a, 1e-31]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[((-N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]) * x + a), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00018 \lor \neg \left(a \leq 10^{-31}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(-\left(\frac{\tan y + \tan z}{\mathsf{fma}\left(-\tan z, \tan y, 1\right) \cdot x} + 1\right), x, a\right)\\
\end{array}
\end{array}
if a < -1.80000000000000011e-4 or 1e-31 < a Initial program 86.0%
if -1.80000000000000011e-4 < a < 1e-31Initial program 81.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites81.6%
Taylor expanded in a around 0
Applied rewrites81.5%
Applied rewrites99.5%
Final simplification92.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 84.0%
(FPCore (x y z a)
:precision binary64
(if (or (<= a -1.55) (not (<= a 1.55)))
(- (- x))
(-
(tan (+ z y))
(-
(*
(fma
(fma
(fma (* a a) 0.05396825396825397 0.13333333333333333)
(* a a)
0.3333333333333333)
(* a a)
1.0)
a)
x))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.55) || !(a <= 1.55)) {
tmp = -(-x);
} else {
tmp = tan((z + y)) - ((fma(fma(fma((a * a), 0.05396825396825397, 0.13333333333333333), (a * a), 0.3333333333333333), (a * a), 1.0) * a) - x);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.55) || !(a <= 1.55)) tmp = Float64(-Float64(-x)); else tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(fma(fma(Float64(a * a), 0.05396825396825397, 0.13333333333333333), Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a) - x)); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.55], N[Not[LessEqual[a, 1.55]], $MachinePrecision]], (-(-x)), N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(N[(N[(a * a), $MachinePrecision] * 0.05396825396825397 + 0.13333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55 \lor \neg \left(a \leq 1.55\right):\\
\;\;\;\;-\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.05396825396825397, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a - x\right)\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.55000000000000004 < a Initial program 84.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites84.6%
Taylor expanded in a around 0
Applied rewrites3.5%
Taylor expanded in y around 0
Applied rewrites3.5%
Taylor expanded in x around inf
Applied rewrites22.8%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6483.2
Applied rewrites83.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.1
Applied rewrites83.1%
Final simplification55.0%
(FPCore (x y z a)
:precision binary64
(if (or (<= a -1.55) (not (<= a 1.55)))
(- (- x))
(-
(tan (+ z y))
(-
(*
(fma (fma (* a a) 0.13333333333333333 0.3333333333333333) (* a a) 1.0)
a)
x))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.55) || !(a <= 1.55)) {
tmp = -(-x);
} else {
tmp = tan((z + y)) - ((fma(fma((a * a), 0.13333333333333333, 0.3333333333333333), (a * a), 1.0) * a) - x);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.55) || !(a <= 1.55)) tmp = Float64(-Float64(-x)); else tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(fma(Float64(a * a), 0.13333333333333333, 0.3333333333333333), Float64(a * a), 1.0) * a) - x)); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.55], N[Not[LessEqual[a, 1.55]], $MachinePrecision]], (-(-x)), N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(N[(a * a), $MachinePrecision] * 0.13333333333333333 + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55 \lor \neg \left(a \leq 1.55\right):\\
\;\;\;\;-\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot a, 0.13333333333333333, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a - x\right)\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.55000000000000004 < a Initial program 84.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites84.6%
Taylor expanded in a around 0
Applied rewrites3.5%
Taylor expanded in y around 0
Applied rewrites3.5%
Taylor expanded in x around inf
Applied rewrites22.8%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6483.2
Applied rewrites83.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
Final simplification55.0%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.55) (not (<= a 1.55))) (- (- x)) (- (tan (+ z y)) (- (* (fma (* a a) 0.3333333333333333 1.0) a) x))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.55) || !(a <= 1.55)) {
tmp = -(-x);
} else {
tmp = tan((z + y)) - ((fma((a * a), 0.3333333333333333, 1.0) * a) - x);
}
return tmp;
}
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.55) || !(a <= 1.55)) tmp = Float64(-Float64(-x)); else tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(Float64(a * a), 0.3333333333333333, 1.0) * a) - x)); end return tmp end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.55], N[Not[LessEqual[a, 1.55]], $MachinePrecision]], (-(-x)), N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(a * a), $MachinePrecision] * 0.3333333333333333 + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55 \lor \neg \left(a \leq 1.55\right):\\
\;\;\;\;-\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(a \cdot a, 0.3333333333333333, 1\right) \cdot a - x\right)\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.55000000000000004 < a Initial program 84.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites84.6%
Taylor expanded in a around 0
Applied rewrites3.5%
Taylor expanded in y around 0
Applied rewrites3.5%
Taylor expanded in x around inf
Applied rewrites22.8%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6483.2
Applied rewrites83.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.7
Applied rewrites82.7%
Final simplification54.8%
(FPCore (x y z a) :precision binary64 (if (or (<= a -1.55) (not (<= a 1.55))) (- (- x)) (- (tan (+ z y)) (- a x))))
double code(double x, double y, double z, double a) {
double tmp;
if ((a <= -1.55) || !(a <= 1.55)) {
tmp = -(-x);
} else {
tmp = tan((z + y)) - (a - 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)) .or. (.not. (a <= 1.55d0))) then
tmp = -(-x)
else
tmp = tan((z + y)) - (a - 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) || !(a <= 1.55)) {
tmp = -(-x);
} else {
tmp = Math.tan((z + y)) - (a - x);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (a <= -1.55) or not (a <= 1.55): tmp = -(-x) else: tmp = math.tan((z + y)) - (a - x) return tmp
function code(x, y, z, a) tmp = 0.0 if ((a <= -1.55) || !(a <= 1.55)) tmp = Float64(-Float64(-x)); else tmp = Float64(tan(Float64(z + y)) - Float64(a - x)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((a <= -1.55) || ~((a <= 1.55))) tmp = -(-x); else tmp = tan((z + y)) - (a - x); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -1.55], N[Not[LessEqual[a, 1.55]], $MachinePrecision]], (-(-x)), N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(a - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.55 \lor \neg \left(a \leq 1.55\right):\\
\;\;\;\;-\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(z + y\right) - \left(a - x\right)\\
\end{array}
\end{array}
if a < -1.55000000000000004 or 1.55000000000000004 < a Initial program 84.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites84.6%
Taylor expanded in a around 0
Applied rewrites3.5%
Taylor expanded in y around 0
Applied rewrites3.5%
Taylor expanded in x around inf
Applied rewrites22.8%
if -1.55000000000000004 < a < 1.55000000000000004Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6483.2
Applied rewrites83.2%
Taylor expanded in a around 0
lower--.f6482.1
Applied rewrites82.1%
Final simplification54.5%
(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 Float64(-Float64(-x)) end
function tmp = code(x, y, z, a) tmp = -(-x); end
code[x_, y_, z_, a_] := (-(-x))
\begin{array}{l}
\\
-\left(-x\right)
\end{array}
Initial program 84.0%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites83.7%
Taylor expanded in a around 0
Applied rewrites45.4%
Taylor expanded in y around 0
Applied rewrites35.4%
Taylor expanded in x around inf
Applied rewrites33.0%
(FPCore (x y z a) :precision binary64 (- a))
double code(double x, double y, double z, double a) {
return -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 = -a
end function
public static double code(double x, double y, double z, double a) {
return -a;
}
def code(x, y, z, a): return -a
function code(x, y, z, a) return Float64(-a) end
function tmp = code(x, y, z, a) tmp = -a; end
code[x_, y_, z_, a_] := (-a)
\begin{array}{l}
\\
-a
\end{array}
Initial program 84.0%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites83.7%
Taylor expanded in a around 0
Applied rewrites45.4%
Taylor expanded in a around inf
Applied rewrites3.7%
herbie shell --seed 2024326
(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))))