
(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 18 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 (fma (fma (fma (tan y) (tan z) -1.0) (sin a) (* (+ (tan z) (tan y)) (cos a))) (/ 1.0 (* (fma (- (tan z)) (tan y) 1.0) (cos a))) x))
double code(double x, double y, double z, double a) {
return fma(fma(fma(tan(y), tan(z), -1.0), sin(a), ((tan(z) + tan(y)) * cos(a))), (1.0 / (fma(-tan(z), tan(y), 1.0) * cos(a))), x);
}
function code(x, y, z, a) return fma(fma(fma(tan(y), tan(z), -1.0), sin(a), Float64(Float64(tan(z) + tan(y)) * cos(a))), Float64(1.0 / Float64(fma(Float64(-tan(z)), tan(y), 1.0) * cos(a))), x) end
code[x_, y_, z_, a_] := N[(N[(N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision] * N[Sin[a], $MachinePrecision] + N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\tan y, \tan z, -1\right), \sin a, \left(\tan z + \tan y\right) \cdot \cos a\right), \frac{1}{\mathsf{fma}\left(-\tan z, \tan y, 1\right) \cdot \cos a}, x\right)
\end{array}
Initial program 78.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lift-tan.f64N/A
tan-quotN/A
frac-subN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
cancel-sign-sub-invN/A
+-commutativeN/A
lift-neg.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ (fma (+ (tan z) (tan y)) (/ -1.0 (fma (tan y) (tan z) -1.0)) (- (tan a))) x))
double code(double x, double y, double z, double a) {
return fma((tan(z) + tan(y)), (-1.0 / fma(tan(y), tan(z), -1.0)), -tan(a)) + x;
}
function code(x, y, z, a) return Float64(fma(Float64(tan(z) + tan(y)), Float64(-1.0 / fma(tan(y), tan(z), -1.0)), Float64(-tan(a))) + x) end
code[x_, y_, z_, a_] := N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\tan z + \tan y, \frac{-1}{\mathsf{fma}\left(\tan y, \tan z, -1\right)}, -\tan a\right) + x
\end{array}
Initial program 78.6%
lift--.f64N/A
sub-negN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-fma.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (- x (- (tan a) (/ (+ (tan z) (tan y)) (fma (- (tan z)) (tan y) 1.0)))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(z) + tan(y)) / fma(-tan(z), tan(y), 1.0)));
}
function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(z) + tan(y)) / fma(Float64(-tan(z)), tan(y), 1.0)))) end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[((-N[Tan[z], $MachinePrecision]) * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \frac{\tan z + \tan y}{\mathsf{fma}\left(-\tan z, \tan y, 1\right)}\right)
\end{array}
Initial program 78.6%
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
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-tan.f64N/A
lower-tan.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (x y z a) :precision binary64 (- (- x (tan a)) (/ (+ (tan z) (tan y)) (fma (tan z) (tan y) -1.0))))
double code(double x, double y, double z, double a) {
return (x - tan(a)) - ((tan(z) + tan(y)) / fma(tan(z), tan(y), -1.0));
}
function code(x, y, z, a) return Float64(Float64(x - tan(a)) - Float64(Float64(tan(z) + tan(y)) / fma(tan(z), tan(y), -1.0))) end
code[x_, y_, z_, a_] := N[(N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[z], $MachinePrecision] * N[Tan[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \tan a\right) - \frac{\tan z + \tan y}{\mathsf{fma}\left(\tan z, \tan y, -1\right)}
\end{array}
Initial program 78.6%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.6%
lift-neg.f64N/A
neg-sub0N/A
lift-fma.f64N/A
associate--r+N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-tan.f64N/A
lift-tan.f64N/A
remove-double-negN/A
lower--.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-fma.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
unsub-negN/A
lower--.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.6
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites99.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- (tan z))))
(if (<= a -0.0125)
(fma (- (sin (+ z y))) (/ -1.0 (cos (+ z y))) (- x (tan a)))
(if (<= a 0.0125)
(fma
(- t_0 (tan y))
(/ -1.0 (fma t_0 (tan y) 1.0))
(- x (* (fma 0.3333333333333333 (* a a) 1.0) a)))
(- x (+ (/ (+ (tan z) (tan y)) -1.0) (tan a)))))))
double code(double x, double y, double z, double a) {
double t_0 = -tan(z);
double tmp;
if (a <= -0.0125) {
tmp = fma(-sin((z + y)), (-1.0 / cos((z + y))), (x - tan(a)));
} else if (a <= 0.0125) {
tmp = fma((t_0 - tan(y)), (-1.0 / fma(t_0, tan(y), 1.0)), (x - (fma(0.3333333333333333, (a * a), 1.0) * a)));
} else {
tmp = x - (((tan(z) + tan(y)) / -1.0) + tan(a));
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(-tan(z)) tmp = 0.0 if (a <= -0.0125) tmp = fma(Float64(-sin(Float64(z + y))), Float64(-1.0 / cos(Float64(z + y))), Float64(x - tan(a))); elseif (a <= 0.0125) tmp = fma(Float64(t_0 - tan(y)), Float64(-1.0 / fma(t_0, tan(y), 1.0)), Float64(x - Float64(fma(0.3333333333333333, Float64(a * a), 1.0) * a))); else tmp = Float64(x - Float64(Float64(Float64(tan(z) + tan(y)) / -1.0) + tan(a))); end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = (-N[Tan[z], $MachinePrecision])}, If[LessEqual[a, -0.0125], N[((-N[Sin[N[(z + y), $MachinePrecision]], $MachinePrecision]) * N[(-1.0 / N[Cos[N[(z + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0125], N[(N[(t$95$0 - N[Tan[y], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(t$95$0 * N[Tan[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x - N[(N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan z\\
\mathbf{if}\;a \leq -0.0125:\\
\;\;\;\;\mathsf{fma}\left(-\sin \left(z + y\right), \frac{-1}{\cos \left(z + y\right)}, x - \tan a\right)\\
\mathbf{elif}\;a \leq 0.0125:\\
\;\;\;\;\mathsf{fma}\left(t\_0 - \tan y, \frac{-1}{\mathsf{fma}\left(t\_0, \tan y, 1\right)}, x - \mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(\frac{\tan z + \tan y}{-1} + \tan a\right)\\
\end{array}
\end{array}
if a < -0.012500000000000001Initial program 74.8%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
tan-quotN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6474.8
Applied rewrites74.8%
if -0.012500000000000001 < a < 0.012500000000000001Initial program 77.8%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
if 0.012500000000000001 < a Initial program 84.3%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.5%
lift-neg.f64N/A
neg-sub0N/A
lift-fma.f64N/A
associate--r+N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-tan.f64N/A
lift-tan.f64N/A
remove-double-negN/A
lower--.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.7
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites99.7%
Taylor expanded in z around 0
Applied rewrites84.8%
Final simplification89.9%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= (tan a) -0.15)
t_0
(if (<= (tan a) 0.07) (- (tan (+ z y)) (- x)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (tan(a) <= -0.15) {
tmp = t_0;
} else if (tan(a) <= 0.07) {
tmp = tan((z + y)) - -x;
} 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 (tan(a) <= (-0.15d0)) then
tmp = t_0
else if (tan(a) <= 0.07d0) then
tmp = tan((z + y)) - -x
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 (Math.tan(a) <= -0.15) {
tmp = t_0;
} else if (Math.tan(a) <= 0.07) {
tmp = Math.tan((z + y)) - -x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if math.tan(a) <= -0.15: tmp = t_0 elif math.tan(a) <= 0.07: tmp = math.tan((z + y)) - -x else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (tan(a) <= -0.15) tmp = t_0; elseif (tan(a) <= 0.07) tmp = Float64(tan(Float64(z + y)) - Float64(-x)); 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 (tan(a) <= -0.15) tmp = t_0; elseif (tan(a) <= 0.07) tmp = tan((z + y)) - -x; 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[N[Tan[a], $MachinePrecision], -0.15], t$95$0, If[LessEqual[N[Tan[a], $MachinePrecision], 0.07], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;\tan a \leq -0.15:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\tan a \leq 0.07:\\
\;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (tan.f64 a) < -0.149999999999999994 or 0.070000000000000007 < (tan.f64 a) Initial program 79.1%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6458.1
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites42.2%
Applied rewrites42.2%
if -0.149999999999999994 < (tan.f64 a) < 0.070000000000000007Initial program 78.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--.f6478.2
Applied rewrites78.2%
Taylor expanded in a around 0
mul-1-negN/A
lower-neg.f6471.7
Applied rewrites71.7%
(FPCore (x y z a) :precision binary64 (- x (+ (/ (+ (tan z) (tan y)) -1.0) (tan a))))
double code(double x, double y, double z, double a) {
return x - (((tan(z) + tan(y)) / -1.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
code = x - (((tan(z) + tan(y)) / (-1.0d0)) + 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(a));
}
def code(x, y, z, a): return x - (((math.tan(z) + math.tan(y)) / -1.0) + math.tan(a))
function code(x, y, z, a) return Float64(x - Float64(Float64(Float64(tan(z) + tan(y)) / -1.0) + tan(a))) end
function tmp = code(x, y, z, a) tmp = x - (((tan(z) + tan(y)) / -1.0) + tan(a)); end
code[x_, y_, z_, a_] := N[(x - N[(N[(N[(N[Tan[z], $MachinePrecision] + N[Tan[y], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision] + N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\frac{\tan z + \tan y}{-1} + \tan a\right)
\end{array}
Initial program 78.6%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.6%
lift-neg.f64N/A
neg-sub0N/A
lift-fma.f64N/A
associate--r+N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-tan.f64N/A
lift-tan.f64N/A
remove-double-negN/A
lower--.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.6
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
metadata-evalN/A
Applied rewrites99.6%
Taylor expanded in z around 0
Applied rewrites78.7%
Final simplification78.7%
(FPCore (x y z a) :precision binary64 (fma (- (- (tan z)) (tan y)) -1.0 (- x (tan a))))
double code(double x, double y, double z, double a) {
return fma((-tan(z) - tan(y)), -1.0, (x - tan(a)));
}
function code(x, y, z, a) return fma(Float64(Float64(-tan(z)) - tan(y)), -1.0, Float64(x - tan(a))) end
code[x_, y_, z_, a_] := N[(N[((-N[Tan[z], $MachinePrecision]) - N[Tan[y], $MachinePrecision]), $MachinePrecision] * -1.0 + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\tan z\right) - \tan y, -1, x - \tan a\right)
\end{array}
Initial program 78.6%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
+-commutativeN/A
associate--l+N/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
frac-2negN/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
Applied rewrites78.7%
Final simplification78.7%
(FPCore (x y z a) :precision binary64 (if (<= y -8e-13) (- (tan (+ z y)) (- x)) (- x (- (tan a) (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if (y <= -8e-13) {
tmp = tan((z + y)) - -x;
} else {
tmp = x - (tan(a) - 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) :: tmp
if (y <= (-8d-13)) then
tmp = tan((z + y)) - -x
else
tmp = x - (tan(a) - tan(z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (y <= -8e-13) {
tmp = Math.tan((z + y)) - -x;
} else {
tmp = x - (Math.tan(a) - Math.tan(z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if y <= -8e-13: tmp = math.tan((z + y)) - -x else: tmp = x - (math.tan(a) - math.tan(z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (y <= -8e-13) tmp = Float64(tan(Float64(z + y)) - Float64(-x)); else tmp = Float64(x - Float64(tan(a) - tan(z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (y <= -8e-13) tmp = tan((z + y)) - -x; else tmp = x - (tan(a) - tan(z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[y, -8e-13], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - (-x)), $MachinePrecision], N[(x - N[(N[Tan[a], $MachinePrecision] - N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-13}:\\
\;\;\;\;\tan \left(z + y\right) - \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(\tan a - \tan z\right)\\
\end{array}
\end{array}
if y < -8.0000000000000002e-13Initial program 60.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6460.0
Applied rewrites60.0%
Taylor expanded in a around 0
mul-1-negN/A
lower-neg.f6436.8
Applied rewrites36.8%
if -8.0000000000000002e-13 < y Initial program 85.3%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6473.9
Applied rewrites73.9%
Applied rewrites73.9%
Final simplification64.1%
(FPCore (x y z a) :precision binary64 (+ (- (tan (+ z y)) (tan a)) x))
double code(double x, double y, double z, double a) {
return (tan((z + y)) - tan(a)) + 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 = (tan((z + y)) - tan(a)) + x
end function
public static double code(double x, double y, double z, double a) {
return (Math.tan((z + y)) - Math.tan(a)) + x;
}
def code(x, y, z, a): return (math.tan((z + y)) - math.tan(a)) + x
function code(x, y, z, a) return Float64(Float64(tan(Float64(z + y)) - tan(a)) + x) end
function tmp = code(x, y, z, a) tmp = (tan((z + y)) - tan(a)) + x; end
code[x_, y_, z_, a_] := N[(N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\tan \left(z + y\right) - \tan a\right) + x
\end{array}
Initial program 78.6%
Final simplification78.6%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= a -0.62)
t_0
(if (<= a 0.75)
(-
(tan (+ z y))
(-
(*
(fma
(fma
(fma 0.05396825396825397 (* a a) 0.13333333333333333)
(* a a)
0.3333333333333333)
(* a a)
1.0)
a)
x))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.62) {
tmp = t_0;
} else if (a <= 0.75) {
tmp = tan((z + y)) - ((fma(fma(fma(0.05396825396825397, (a * a), 0.13333333333333333), (a * a), 0.3333333333333333), (a * a), 1.0) * a) - x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.62) tmp = t_0; elseif (a <= 0.75) tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(fma(fma(0.05396825396825397, Float64(a * a), 0.13333333333333333), Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a) - x)); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.62], t$95$0, If[LessEqual[a, 0.75], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(N[(0.05396825396825397 * N[(a * a), $MachinePrecision] + 0.13333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.62:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.75:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.05396825396825397, a \cdot a, 0.13333333333333333\right), a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.619999999999999996 or 0.75 < a Initial program 79.2%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6458.1
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites39.6%
Applied rewrites39.6%
if -0.619999999999999996 < a < 0.75Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.0
Applied rewrites78.0%
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
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= a -0.31)
t_0
(if (<= a 0.72)
(-
(tan (+ z y))
(-
(*
(fma
(fma 0.13333333333333333 (* a a) 0.3333333333333333)
(* a a)
1.0)
a)
x))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.31) {
tmp = t_0;
} else if (a <= 0.72) {
tmp = tan((z + y)) - ((fma(fma(0.13333333333333333, (a * a), 0.3333333333333333), (a * a), 1.0) * a) - x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.31) tmp = t_0; elseif (a <= 0.72) tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(fma(0.13333333333333333, Float64(a * a), 0.3333333333333333), Float64(a * a), 1.0) * a) - x)); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.31], t$95$0, If[LessEqual[a, 0.72], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(N[(0.13333333333333333 * N[(a * a), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.31:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.72:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(\mathsf{fma}\left(0.13333333333333333, a \cdot a, 0.3333333333333333\right), a \cdot a, 1\right) \cdot a - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.309999999999999998 or 0.71999999999999997 < a Initial program 79.2%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6458.1
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites39.6%
Applied rewrites39.6%
if -0.309999999999999998 < a < 0.71999999999999997Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.0
Applied rewrites78.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.9
Applied rewrites77.9%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (- x (tan a))))
(if (<= a -0.07)
t_0
(if (<= a 0.076)
(- (tan (+ z y)) (- (* (fma 0.3333333333333333 (* a a) 1.0) a) x))
t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.07) {
tmp = t_0;
} else if (a <= 0.076) {
tmp = tan((z + y)) - ((fma(0.3333333333333333, (a * a), 1.0) * a) - x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.07) tmp = t_0; elseif (a <= 0.076) tmp = Float64(tan(Float64(z + y)) - Float64(Float64(fma(0.3333333333333333, Float64(a * a), 1.0) * a) - x)); else tmp = t_0; end return tmp end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.07], t$95$0, If[LessEqual[a, 0.076], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(0.3333333333333333 * N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.07:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.076:\\
\;\;\;\;\tan \left(z + y\right) - \left(\mathsf{fma}\left(0.3333333333333333, a \cdot a, 1\right) \cdot a - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.070000000000000007 or 0.0759999999999999981 < a Initial program 79.2%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6458.1
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites39.6%
Applied rewrites39.6%
if -0.070000000000000007 < a < 0.0759999999999999981Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.0
Applied rewrites78.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.8
Applied rewrites77.8%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (- x (tan a)))) (if (<= a -0.031) t_0 (if (<= a 0.04) (- (tan (+ z y)) (- a x)) t_0))))
double code(double x, double y, double z, double a) {
double t_0 = x - tan(a);
double tmp;
if (a <= -0.031) {
tmp = t_0;
} else if (a <= 0.04) {
tmp = tan((z + y)) - (a - x);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = x - tan(a)
if (a <= (-0.031d0)) then
tmp = t_0
else if (a <= 0.04d0) then
tmp = tan((z + y)) - (a - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = x - Math.tan(a);
double tmp;
if (a <= -0.031) {
tmp = t_0;
} else if (a <= 0.04) {
tmp = Math.tan((z + y)) - (a - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z, a): t_0 = x - math.tan(a) tmp = 0 if a <= -0.031: tmp = t_0 elif a <= 0.04: tmp = math.tan((z + y)) - (a - x) else: tmp = t_0 return tmp
function code(x, y, z, a) t_0 = Float64(x - tan(a)) tmp = 0.0 if (a <= -0.031) tmp = t_0; elseif (a <= 0.04) tmp = Float64(tan(Float64(z + y)) - Float64(a - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = x - tan(a); tmp = 0.0; if (a <= -0.031) tmp = t_0; elseif (a <= 0.04) tmp = tan((z + y)) - (a - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.031], t$95$0, If[LessEqual[a, 0.04], N[(N[Tan[N[(z + y), $MachinePrecision]], $MachinePrecision] - N[(a - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \tan a\\
\mathbf{if}\;a \leq -0.031:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.04:\\
\;\;\;\;\tan \left(z + y\right) - \left(a - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.031 or 0.0400000000000000008 < a Initial program 79.2%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6458.1
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites39.6%
Applied rewrites39.6%
if -0.031 < a < 0.0400000000000000008Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6478.0
Applied rewrites78.0%
Taylor expanded in a around 0
lower--.f6477.6
Applied rewrites77.6%
(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 78.6%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.8
Applied rewrites60.8%
Taylor expanded in z around 0
Applied rewrites39.9%
Applied rewrites39.9%
(FPCore (x y z a) :precision binary64 (/ 1.0 (/ 1.0 x)))
double code(double x, double y, double z, double a) {
return 1.0 / (1.0 / 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 = 1.0d0 / (1.0d0 / x)
end function
public static double code(double x, double y, double z, double a) {
return 1.0 / (1.0 / x);
}
def code(x, y, z, a): return 1.0 / (1.0 / x)
function code(x, y, z, a) return Float64(1.0 / Float64(1.0 / x)) end
function tmp = code(x, y, z, a) tmp = 1.0 / (1.0 / x); end
code[x_, y_, z_, a_] := N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{x}}
\end{array}
Initial program 78.6%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6478.4
Applied rewrites78.4%
Taylor expanded in x around inf
lower-/.f6430.7
Applied rewrites30.7%
(FPCore (x y z a) :precision binary64 (- x a))
double code(double x, double y, double z, double a) {
return x - 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 - a
end function
public static double code(double x, double y, double z, double a) {
return x - a;
}
def code(x, y, z, a): return x - a
function code(x, y, z, a) return Float64(x - a) end
function tmp = code(x, y, z, a) tmp = x - a; end
code[x_, y_, z_, a_] := N[(x - a), $MachinePrecision]
\begin{array}{l}
\\
x - a
\end{array}
Initial program 78.6%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.8
Applied rewrites60.8%
Taylor expanded in z around 0
Applied rewrites39.9%
Taylor expanded in a around 0
Applied rewrites22.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 78.6%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6460.8
Applied rewrites60.8%
Taylor expanded in z around 0
Applied rewrites39.9%
Taylor expanded in a around 0
Applied rewrites22.0%
Taylor expanded in a around inf
Applied rewrites3.3%
herbie shell --seed 2024271
(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))))