
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Initial program 99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ x (sin y)) (* z (cos y))))) (if (<= t_0 -0.5) (+ x z) (if (<= t_0 0.4) (+ y (+ x z)) (+ x z)))))
double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + (z * cos(y));
double tmp;
if (t_0 <= -0.5) {
tmp = x + z;
} else if (t_0 <= 0.4) {
tmp = y + (x + z);
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + sin(y)) + (z * cos(y))
if (t_0 <= (-0.5d0)) then
tmp = x + z
else if (t_0 <= 0.4d0) then
tmp = y + (x + z)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.sin(y)) + (z * Math.cos(y));
double tmp;
if (t_0 <= -0.5) {
tmp = x + z;
} else if (t_0 <= 0.4) {
tmp = y + (x + z);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.sin(y)) + (z * math.cos(y)) tmp = 0 if t_0 <= -0.5: tmp = x + z elif t_0 <= 0.4: tmp = y + (x + z) else: tmp = x + z return tmp
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + Float64(z * cos(y))) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(x + z); elseif (t_0 <= 0.4) tmp = Float64(y + Float64(x + z)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + sin(y)) + (z * cos(y)); tmp = 0.0; if (t_0 <= -0.5) tmp = x + z; elseif (t_0 <= 0.4) tmp = y + (x + z); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, 0.4], N[(y + N[(x + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \sin y\right) + z \cdot \cos y\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq 0.4:\\
\;\;\;\;y + \left(x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.5 or 0.40000000000000002 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6469.2
Applied rewrites69.2%
if -0.5 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 0.40000000000000002Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6479.6
Applied rewrites79.6%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ x (sin y))))
double code(double x, double y, double z) {
return fma(cos(y), z, (x + sin(y)));
}
function code(x, y, z) return fma(cos(y), z, Float64(x + sin(y))) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, x + \sin y\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -2.95e+97)
t_0
(if (<= z 4.8e+115) (fma 1.0 z (fma x (/ (sin y) x) x)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -2.95e+97) {
tmp = t_0;
} else if (z <= 4.8e+115) {
tmp = fma(1.0, z, fma(x, (sin(y) / x), x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -2.95e+97) tmp = t_0; elseif (z <= 4.8e+115) tmp = fma(1.0, z, fma(x, Float64(sin(y) / x), x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.95e+97], t$95$0, If[LessEqual[z, 4.8e+115], N[(1.0 * z + N[(x * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -2.95 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(x, \frac{\sin y}{x}, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.95000000000000005e97 or 4.8000000000000001e115 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6489.0
Applied rewrites89.0%
if -2.95000000000000005e97 < z < 4.8000000000000001e115Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites95.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -2.95e+97)
t_0
(if (<= z -1.1e-11)
(+ x z)
(if (<= z 5.7e-30)
(+ x (sin y))
(if (<= z 4e+115) (fma x (/ z x) x) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -2.95e+97) {
tmp = t_0;
} else if (z <= -1.1e-11) {
tmp = x + z;
} else if (z <= 5.7e-30) {
tmp = x + sin(y);
} else if (z <= 4e+115) {
tmp = fma(x, (z / x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -2.95e+97) tmp = t_0; elseif (z <= -1.1e-11) tmp = Float64(x + z); elseif (z <= 5.7e-30) tmp = Float64(x + sin(y)); elseif (z <= 4e+115) tmp = fma(x, Float64(z / x), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.95e+97], t$95$0, If[LessEqual[z, -1.1e-11], N[(x + z), $MachinePrecision], If[LessEqual[z, 5.7e-30], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e+115], N[(x * N[(z / x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -2.95 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.1 \cdot 10^{-11}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{-30}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.95000000000000005e97 or 4.0000000000000001e115 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6489.0
Applied rewrites89.0%
if -2.95000000000000005e97 < z < -1.1000000000000001e-11Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6487.1
Applied rewrites87.1%
if -1.1000000000000001e-11 < z < 5.69999999999999977e-30Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6494.9
Applied rewrites94.9%
if 5.69999999999999977e-30 < z < 4.0000000000000001e115Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6486.6
Applied rewrites86.6%
Taylor expanded in x around inf
Applied rewrites86.6%
Final simplification91.0%
(FPCore (x y z)
:precision binary64
(if (<= z -1.3e-11)
(fma (cos y) z (+ x y))
(if (<= z 5.7e-30)
(+ x (sin y))
(if (<= z 4e+115) (fma x (/ z x) x) (* z (cos y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.3e-11) {
tmp = fma(cos(y), z, (x + y));
} else if (z <= 5.7e-30) {
tmp = x + sin(y);
} else if (z <= 4e+115) {
tmp = fma(x, (z / x), x);
} else {
tmp = z * cos(y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.3e-11) tmp = fma(cos(y), z, Float64(x + y)); elseif (z <= 5.7e-30) tmp = Float64(x + sin(y)); elseif (z <= 4e+115) tmp = fma(x, Float64(z / x), x); else tmp = Float64(z * cos(y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.3e-11], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.7e-30], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e+115], N[(x * N[(z / x), $MachinePrecision] + x), $MachinePrecision], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{-30}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \cos y\\
\end{array}
\end{array}
if z < -1.3e-11Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6482.0
Applied rewrites82.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.0
Applied rewrites82.0%
if -1.3e-11 < z < 5.69999999999999977e-30Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6494.9
Applied rewrites94.9%
if 5.69999999999999977e-30 < z < 4.0000000000000001e115Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6486.6
Applied rewrites86.6%
Taylor expanded in x around inf
Applied rewrites86.6%
if 4.0000000000000001e115 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6492.5
Applied rewrites92.5%
Final simplification89.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (sin y))))
(if (<= y -0.008)
t_0
(if (<= y 5.6e+14)
(fma
(fma
(* y y)
(fma
y
(* y (fma (* y y) -0.001388888888888889 0.041666666666666664))
-0.5)
1.0)
z
(+ x y))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.008) {
tmp = t_0;
} else if (y <= 5.6e+14) {
tmp = fma(fma((y * y), fma(y, (y * fma((y * y), -0.001388888888888889, 0.041666666666666664)), -0.5), 1.0), z, (x + y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.008) tmp = t_0; elseif (y <= 5.6e+14) tmp = fma(fma(Float64(y * y), fma(y, Float64(y * fma(Float64(y * y), -0.001388888888888889, 0.041666666666666664)), -0.5), 1.0), z, Float64(x + y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.008], t$95$0, If[LessEqual[y, 5.6e+14], N[(N[(N[(y * y), $MachinePrecision] * N[(y * N[(y * N[(N[(y * y), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.008:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, -0.001388888888888889, 0.041666666666666664\right), -0.5\right), 1\right), z, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0080000000000000002 or 5.6e14 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6461.2
Applied rewrites61.2%
if -0.0080000000000000002 < y < 5.6e14Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.7
Applied rewrites98.7%
Final simplification80.7%
(FPCore (x y z)
:precision binary64
(if (<= y -11.0)
(+ x z)
(if (<= y 7.6e+17)
(fma
(fma
(* y y)
(fma
y
(* y (fma (* y y) -0.001388888888888889 0.041666666666666664))
-0.5)
1.0)
z
(+ x y))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 7.6e+17) {
tmp = fma(fma((y * y), fma(y, (y * fma((y * y), -0.001388888888888889, 0.041666666666666664)), -0.5), 1.0), z, (x + y));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -11.0) tmp = Float64(x + z); elseif (y <= 7.6e+17) tmp = fma(fma(Float64(y * y), fma(y, Float64(y * fma(Float64(y * y), -0.001388888888888889, 0.041666666666666664)), -0.5), 1.0), z, Float64(x + y)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -11.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 7.6e+17], N[(N[(N[(y * y), $MachinePrecision] * N[(y * N[(y * N[(N[(y * y), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, -0.001388888888888889, 0.041666666666666664\right), -0.5\right), 1\right), z, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -11 or 7.6e17 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6441.9
Applied rewrites41.9%
if -11 < y < 7.6e17Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.6
Applied rewrites98.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.3
Applied rewrites97.3%
Final simplification71.1%
(FPCore (x y z)
:precision binary64
(if (<= y -3.1)
(+ x z)
(if (<= y 6.5e+17)
(fma (fma (* y y) (fma y (* y 0.041666666666666664) -0.5) 1.0) z (+ x y))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1) {
tmp = x + z;
} else if (y <= 6.5e+17) {
tmp = fma(fma((y * y), fma(y, (y * 0.041666666666666664), -0.5), 1.0), z, (x + y));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3.1) tmp = Float64(x + z); elseif (y <= 6.5e+17) tmp = fma(fma(Float64(y * y), fma(y, Float64(y * 0.041666666666666664), -0.5), 1.0), z, Float64(x + y)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3.1], N[(x + z), $MachinePrecision], If[LessEqual[y, 6.5e+17], N[(N[(N[(y * y), $MachinePrecision] * N[(y * N[(y * 0.041666666666666664), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot 0.041666666666666664, -0.5\right), 1\right), z, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -3.10000000000000009 or 6.5e17 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6441.9
Applied rewrites41.9%
if -3.10000000000000009 < y < 6.5e17Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.6
Applied rewrites98.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (<= y -11.0) (+ x z) (if (<= y 2.6e+20) (+ z (fma y (fma y (* z -0.5) 1.0) x)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 2.6e+20) {
tmp = z + fma(y, fma(y, (z * -0.5), 1.0), x);
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -11.0) tmp = Float64(x + z); elseif (y <= 2.6e+20) tmp = Float64(z + fma(y, fma(y, Float64(z * -0.5), 1.0), x)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -11.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 2.6e+20], N[(z + N[(y * N[(y * N[(z * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+20}:\\
\;\;\;\;z + \mathsf{fma}\left(y, \mathsf{fma}\left(y, z \cdot -0.5, 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -11 or 2.6e20 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6441.9
Applied rewrites41.9%
if -11 < y < 2.6e20Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.2
Applied rewrites97.2%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
\begin{array}{l}
\\
x + z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6466.5
Applied rewrites66.5%
Final simplification66.5%
herbie shell --seed 2024234
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))