
(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 13 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 (+ (+ (sin y) x) (* (cos y) z)))
double code(double x, double y, double z) {
return (sin(y) + x) + (cos(y) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (sin(y) + x) + (cos(y) * z)
end function
public static double code(double x, double y, double z) {
return (Math.sin(y) + x) + (Math.cos(y) * z);
}
def code(x, y, z): return (math.sin(y) + x) + (math.cos(y) * z)
function code(x, y, z) return Float64(Float64(sin(y) + x) + Float64(cos(y) * z)) end
function tmp = code(x, y, z) tmp = (sin(y) + x) + (cos(y) * z); end
code[x_, y_, z_] := N[(N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin y + x\right) + \cos y \cdot z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ (sin y) x) (* (cos y) z)))) (if (<= t_0 -5e-29) (+ z x) (if (<= t_0 1e-130) (+ y x) (+ z x)))))
double code(double x, double y, double z) {
double t_0 = (sin(y) + x) + (cos(y) * z);
double tmp;
if (t_0 <= -5e-29) {
tmp = z + x;
} else if (t_0 <= 1e-130) {
tmp = y + x;
} else {
tmp = z + x;
}
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 = (sin(y) + x) + (cos(y) * z)
if (t_0 <= (-5d-29)) then
tmp = z + x
else if (t_0 <= 1d-130) then
tmp = y + x
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.sin(y) + x) + (Math.cos(y) * z);
double tmp;
if (t_0 <= -5e-29) {
tmp = z + x;
} else if (t_0 <= 1e-130) {
tmp = y + x;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): t_0 = (math.sin(y) + x) + (math.cos(y) * z) tmp = 0 if t_0 <= -5e-29: tmp = z + x elif t_0 <= 1e-130: tmp = y + x else: tmp = z + x return tmp
function code(x, y, z) t_0 = Float64(Float64(sin(y) + x) + Float64(cos(y) * z)) tmp = 0.0 if (t_0 <= -5e-29) tmp = Float64(z + x); elseif (t_0 <= 1e-130) tmp = Float64(y + x); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (sin(y) + x) + (cos(y) * z); tmp = 0.0; if (t_0 <= -5e-29) tmp = z + x; elseif (t_0 <= 1e-130) tmp = y + x; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-29], N[(z + x), $MachinePrecision], If[LessEqual[t$95$0, 1e-130], N[(y + x), $MachinePrecision], N[(z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin y + x\right) + \cos y \cdot z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-29}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;t\_0 \leq 10^{-130}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -4.99999999999999986e-29 or 1.0000000000000001e-130 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6468.6
Applied rewrites68.6%
if -4.99999999999999986e-29 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1.0000000000000001e-130Initial program 100.0%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
inv-powN/A
lower-pow.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
Applied rewrites100.0%
Final simplification70.8%
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (cos y) z (+ y x))))
(if (<= z -3.6e+177)
t_0
(if (<= z -8.8e+87)
(* (cos y) z)
(if (<= z 1.65e+108) (fma 1.0 z (fma (/ (sin y) x) x x)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (y + x));
double tmp;
if (z <= -3.6e+177) {
tmp = t_0;
} else if (z <= -8.8e+87) {
tmp = cos(y) * z;
} else if (z <= 1.65e+108) {
tmp = fma(1.0, z, fma((sin(y) / x), x, x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(y + x)) tmp = 0.0 if (z <= -3.6e+177) tmp = t_0; elseif (z <= -8.8e+87) tmp = Float64(cos(y) * z); elseif (z <= 1.65e+108) tmp = fma(1.0, z, fma(Float64(sin(y) / x), x, x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+177], t$95$0, If[LessEqual[z, -8.8e+87], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1.65e+108], N[(1.0 * z + N[(N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, y + x\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -8.8 \cdot 10^{+87}:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(\frac{\sin y}{x}, x, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.60000000000000003e177 or 1.6500000000000001e108 < z Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6491.4
Applied rewrites91.4%
if -3.60000000000000003e177 < z < -8.8000000000000003e87Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6484.2
Applied rewrites84.2%
if -8.8000000000000003e87 < z < 1.6500000000000001e108Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites94.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (cos y) z (+ y x))))
(if (<= z -3.6e+177)
t_0
(if (<= z -8.8e+87)
(* (cos y) z)
(if (<= z -3.7e-31)
(+ z x)
(if (<= z 3.5e-50)
(+ (sin y) x)
(if (<= z 1.65e+108) (+ z x) t_0)))))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (y + x));
double tmp;
if (z <= -3.6e+177) {
tmp = t_0;
} else if (z <= -8.8e+87) {
tmp = cos(y) * z;
} else if (z <= -3.7e-31) {
tmp = z + x;
} else if (z <= 3.5e-50) {
tmp = sin(y) + x;
} else if (z <= 1.65e+108) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(y + x)) tmp = 0.0 if (z <= -3.6e+177) tmp = t_0; elseif (z <= -8.8e+87) tmp = Float64(cos(y) * z); elseif (z <= -3.7e-31) tmp = Float64(z + x); elseif (z <= 3.5e-50) tmp = Float64(sin(y) + x); elseif (z <= 1.65e+108) tmp = Float64(z + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+177], t$95$0, If[LessEqual[z, -8.8e+87], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -3.7e-31], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.5e-50], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.65e+108], N[(z + x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, y + x\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -8.8 \cdot 10^{+87}:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-31}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-50}:\\
\;\;\;\;\sin y + x\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+108}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.60000000000000003e177 or 1.6500000000000001e108 < z Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6491.4
Applied rewrites91.4%
if -3.60000000000000003e177 < z < -8.8000000000000003e87Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6484.2
Applied rewrites84.2%
if -8.8000000000000003e87 < z < -3.6999999999999998e-31 or 3.49999999999999997e-50 < z < 1.6500000000000001e108Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6482.1
Applied rewrites82.1%
if -3.6999999999999998e-31 < z < 3.49999999999999997e-50Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6498.1
Applied rewrites98.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) z)))
(if (<= z -8.8e+87)
t_0
(if (<= z -3.7e-31)
(+ z x)
(if (<= z 3.5e-50) (+ (sin y) x) (if (<= z 5.2e+266) (+ z x) t_0))))))
double code(double x, double y, double z) {
double t_0 = cos(y) * z;
double tmp;
if (z <= -8.8e+87) {
tmp = t_0;
} else if (z <= -3.7e-31) {
tmp = z + x;
} else if (z <= 3.5e-50) {
tmp = sin(y) + x;
} else if (z <= 5.2e+266) {
tmp = z + x;
} else {
tmp = t_0;
}
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 = cos(y) * z
if (z <= (-8.8d+87)) then
tmp = t_0
else if (z <= (-3.7d-31)) then
tmp = z + x
else if (z <= 3.5d-50) then
tmp = sin(y) + x
else if (z <= 5.2d+266) then
tmp = z + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cos(y) * z;
double tmp;
if (z <= -8.8e+87) {
tmp = t_0;
} else if (z <= -3.7e-31) {
tmp = z + x;
} else if (z <= 3.5e-50) {
tmp = Math.sin(y) + x;
} else if (z <= 5.2e+266) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) * z tmp = 0 if z <= -8.8e+87: tmp = t_0 elif z <= -3.7e-31: tmp = z + x elif z <= 3.5e-50: tmp = math.sin(y) + x elif z <= 5.2e+266: tmp = z + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cos(y) * z) tmp = 0.0 if (z <= -8.8e+87) tmp = t_0; elseif (z <= -3.7e-31) tmp = Float64(z + x); elseif (z <= 3.5e-50) tmp = Float64(sin(y) + x); elseif (z <= 5.2e+266) tmp = Float64(z + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cos(y) * z; tmp = 0.0; if (z <= -8.8e+87) tmp = t_0; elseif (z <= -3.7e-31) tmp = z + x; elseif (z <= 3.5e-50) tmp = sin(y) + x; elseif (z <= 5.2e+266) tmp = z + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -8.8e+87], t$95$0, If[LessEqual[z, -3.7e-31], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.5e-50], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 5.2e+266], N[(z + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot z\\
\mathbf{if}\;z \leq -8.8 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-31}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-50}:\\
\;\;\;\;\sin y + x\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{+266}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -8.8000000000000003e87 or 5.20000000000000027e266 < z Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.2
Applied rewrites85.2%
if -8.8000000000000003e87 < z < -3.6999999999999998e-31 or 3.49999999999999997e-50 < z < 5.20000000000000027e266Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6479.9
Applied rewrites79.9%
if -3.6999999999999998e-31 < z < 3.49999999999999997e-50Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6498.1
Applied rewrites98.1%
(FPCore (x y z) :precision binary64 (if (<= z -3.7e-31) (+ z x) (if (<= z 3.5e-50) (+ (sin y) x) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.7e-31) {
tmp = z + x;
} else if (z <= 3.5e-50) {
tmp = sin(y) + x;
} else {
tmp = z + x;
}
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) :: tmp
if (z <= (-3.7d-31)) then
tmp = z + x
else if (z <= 3.5d-50) then
tmp = sin(y) + x
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.7e-31) {
tmp = z + x;
} else if (z <= 3.5e-50) {
tmp = Math.sin(y) + x;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.7e-31: tmp = z + x elif z <= 3.5e-50: tmp = math.sin(y) + x else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.7e-31) tmp = Float64(z + x); elseif (z <= 3.5e-50) tmp = Float64(sin(y) + x); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.7e-31) tmp = z + x; elseif (z <= 3.5e-50) tmp = sin(y) + x; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.7e-31], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.5e-50], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-31}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-50}:\\
\;\;\;\;\sin y + x\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -3.6999999999999998e-31 or 3.49999999999999997e-50 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6467.0
Applied rewrites67.0%
if -3.6999999999999998e-31 < z < 3.49999999999999997e-50Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6498.1
Applied rewrites98.1%
(FPCore (x y z)
:precision binary64
(if (<= y -3.1)
(+ z x)
(if (<= y 3.15)
(+ (fma (* (fma 0.041666666666666664 (* y y) -0.5) z) (* y y) z) (+ y x))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1) {
tmp = z + x;
} else if (y <= 3.15) {
tmp = fma((fma(0.041666666666666664, (y * y), -0.5) * z), (y * y), z) + (y + x);
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3.1) tmp = Float64(z + x); elseif (y <= 3.15) tmp = Float64(fma(Float64(fma(0.041666666666666664, Float64(y * y), -0.5) * z), Float64(y * y), z) + Float64(y + x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3.1], N[(z + x), $MachinePrecision], If[LessEqual[y, 3.15], N[(N[(N[(N[(0.041666666666666664 * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * z), $MachinePrecision] * N[(y * y), $MachinePrecision] + z), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 3.15:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y \cdot y, -0.5\right) \cdot z, y \cdot y, z\right) + \left(y + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -3.10000000000000009 or 3.14999999999999991 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6445.8
Applied rewrites45.8%
if -3.10000000000000009 < y < 3.14999999999999991Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification72.4%
(FPCore (x y z)
:precision binary64
(if (<= y -2.8e+21)
(+ z x)
(if (<= y 4.7)
(fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+21) {
tmp = z + x;
} else if (y <= 4.7) {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.8e+21) tmp = Float64(z + x); elseif (y <= 4.7) tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2.8e+21], N[(z + x), $MachinePrecision], If[LessEqual[y, 4.7], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+21}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 4.7:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -2.8e21 or 4.70000000000000018 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6445.7
Applied rewrites45.7%
if -2.8e21 < y < 4.70000000000000018Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (if (<= y -3.3e+21) (+ z x) (if (<= y 4.7) (fma (fma (* -0.5 y) z 1.0) y (+ z x)) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.3e+21) {
tmp = z + x;
} else if (y <= 4.7) {
tmp = fma(fma((-0.5 * y), z, 1.0), y, (z + x));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3.3e+21) tmp = Float64(z + x); elseif (y <= 4.7) tmp = fma(fma(Float64(-0.5 * y), z, 1.0), y, Float64(z + x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3.3e+21], N[(z + x), $MachinePrecision], If[LessEqual[y, 4.7], N[(N[(N[(-0.5 * y), $MachinePrecision] * z + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+21}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 4.7:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -3.3e21 or 4.70000000000000018 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6445.7
Applied rewrites45.7%
if -3.3e21 < y < 4.70000000000000018Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.5
Applied rewrites98.5%
(FPCore (x y z)
:precision binary64
(if (<= y -3300000000.0)
(+ z x)
(if (<= y 2.3e-8)
(fma (fma (* -0.16666666666666666 y) y 1.0) y (+ z x))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3300000000.0) {
tmp = z + x;
} else if (y <= 2.3e-8) {
tmp = fma(fma((-0.16666666666666666 * y), y, 1.0), y, (z + x));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3300000000.0) tmp = Float64(z + x); elseif (y <= 2.3e-8) tmp = fma(fma(Float64(-0.16666666666666666 * y), y, 1.0), y, Float64(z + x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3300000000.0], N[(z + x), $MachinePrecision], If[LessEqual[y, 2.3e-8], N[(N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3300000000:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right), y, z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -3.3e9 or 2.3000000000000001e-8 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6446.3
Applied rewrites46.3%
if -3.3e9 < y < 2.3000000000000001e-8Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.3
Applied rewrites99.3%
Taylor expanded in z around 0
Applied rewrites99.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.1) (+ z x) (if (<= y 2.3e-8) (+ (+ y x) z) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1) {
tmp = z + x;
} else if (y <= 2.3e-8) {
tmp = (y + x) + z;
} else {
tmp = z + x;
}
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) :: tmp
if (y <= (-3.1d0)) then
tmp = z + x
else if (y <= 2.3d-8) then
tmp = (y + x) + z
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.1) {
tmp = z + x;
} else if (y <= 2.3e-8) {
tmp = (y + x) + z;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.1: tmp = z + x elif y <= 2.3e-8: tmp = (y + x) + z else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.1) tmp = Float64(z + x); elseif (y <= 2.3e-8) tmp = Float64(Float64(y + x) + z); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.1) tmp = z + x; elseif (y <= 2.3e-8) tmp = (y + x) + z; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.1], N[(z + x), $MachinePrecision], If[LessEqual[y, 2.3e-8], N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-8}:\\
\;\;\;\;\left(y + x\right) + z\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -3.10000000000000009 or 2.3000000000000001e-8 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6446.3
Applied rewrites46.3%
if -3.10000000000000009 < y < 2.3000000000000001e-8Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return z + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6466.7
Applied rewrites66.7%
herbie shell --seed 2024277
(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))))