
(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 15 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 (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 (+ (+ x (sin y)) (* (cos y) z))))
(if (<= t_0 -10.0)
(+ z x)
(if (<= t_0 -0.01)
(sin y)
(if (<= t_0 1e-5) (+ y (+ z x)) (if (<= t_0 1.0) (sin y) (+ z x)))))))
double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + (cos(y) * z);
double tmp;
if (t_0 <= -10.0) {
tmp = z + x;
} else if (t_0 <= -0.01) {
tmp = sin(y);
} else if (t_0 <= 1e-5) {
tmp = y + (z + x);
} else if (t_0 <= 1.0) {
tmp = sin(y);
} 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 = (x + sin(y)) + (cos(y) * z)
if (t_0 <= (-10.0d0)) then
tmp = z + x
else if (t_0 <= (-0.01d0)) then
tmp = sin(y)
else if (t_0 <= 1d-5) then
tmp = y + (z + x)
else if (t_0 <= 1.0d0) then
tmp = sin(y)
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.sin(y)) + (Math.cos(y) * z);
double tmp;
if (t_0 <= -10.0) {
tmp = z + x;
} else if (t_0 <= -0.01) {
tmp = Math.sin(y);
} else if (t_0 <= 1e-5) {
tmp = y + (z + x);
} else if (t_0 <= 1.0) {
tmp = Math.sin(y);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.sin(y)) + (math.cos(y) * z) tmp = 0 if t_0 <= -10.0: tmp = z + x elif t_0 <= -0.01: tmp = math.sin(y) elif t_0 <= 1e-5: tmp = y + (z + x) elif t_0 <= 1.0: tmp = math.sin(y) else: tmp = z + x return tmp
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + Float64(cos(y) * z)) tmp = 0.0 if (t_0 <= -10.0) tmp = Float64(z + x); elseif (t_0 <= -0.01) tmp = sin(y); elseif (t_0 <= 1e-5) tmp = Float64(y + Float64(z + x)); elseif (t_0 <= 1.0) tmp = sin(y); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + sin(y)) + (cos(y) * z); tmp = 0.0; if (t_0 <= -10.0) tmp = z + x; elseif (t_0 <= -0.01) tmp = sin(y); elseif (t_0 <= 1e-5) tmp = y + (z + x); elseif (t_0 <= 1.0) tmp = sin(y); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -10.0], N[(z + x), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 1e-5], N[(y + N[(z + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[y], $MachinePrecision], N[(z + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \sin y\right) + \cos y \cdot z\\
\mathbf{if}\;t\_0 \leq -10:\\
\;\;\;\;z + x\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;y + \left(z + x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -10 or 1 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6476.1
Applied rewrites76.1%
if -10 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.0100000000000000002 or 1.00000000000000008e-5 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6495.5
Applied rewrites95.5%
Taylor expanded in x around 0
Applied rewrites90.4%
if -0.0100000000000000002 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1.00000000000000008e-5Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification80.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) z)))
(if (<= z -1.55e+129)
t_0
(if (<= z -1.4e-47) (+ z x) (if (<= z 1700.0) (+ x (sin y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = cos(y) * z;
double tmp;
if (z <= -1.55e+129) {
tmp = t_0;
} else if (z <= -1.4e-47) {
tmp = z + x;
} else if (z <= 1700.0) {
tmp = x + sin(y);
} 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 <= (-1.55d+129)) then
tmp = t_0
else if (z <= (-1.4d-47)) then
tmp = z + x
else if (z <= 1700.0d0) then
tmp = x + sin(y)
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 <= -1.55e+129) {
tmp = t_0;
} else if (z <= -1.4e-47) {
tmp = z + x;
} else if (z <= 1700.0) {
tmp = x + Math.sin(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) * z tmp = 0 if z <= -1.55e+129: tmp = t_0 elif z <= -1.4e-47: tmp = z + x elif z <= 1700.0: tmp = x + math.sin(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cos(y) * z) tmp = 0.0 if (z <= -1.55e+129) tmp = t_0; elseif (z <= -1.4e-47) tmp = Float64(z + x); elseif (z <= 1700.0) tmp = Float64(x + sin(y)); 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 <= -1.55e+129) tmp = t_0; elseif (z <= -1.4e-47) tmp = z + x; elseif (z <= 1700.0) tmp = x + sin(y); 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, -1.55e+129], t$95$0, If[LessEqual[z, -1.4e-47], N[(z + x), $MachinePrecision], If[LessEqual[z, 1700.0], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot z\\
\mathbf{if}\;z \leq -1.55 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-47}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 1700:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.55e129 or 1700 < z Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6481.4
Applied rewrites81.4%
if -1.55e129 < z < -1.39999999999999996e-47Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6481.1
Applied rewrites81.1%
if -1.39999999999999996e-47 < z < 1700Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6491.2
Applied rewrites91.2%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma z (cos y) x))) (if (<= z -50000000.0) t_0 (if (<= z 2.8) (fma 1.0 z (+ x (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(z, cos(y), x);
double tmp;
if (z <= -50000000.0) {
tmp = t_0;
} else if (z <= 2.8) {
tmp = fma(1.0, z, (x + sin(y)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(z, cos(y), x) tmp = 0.0 if (z <= -50000000.0) tmp = t_0; elseif (z <= 2.8) tmp = fma(1.0, z, Float64(x + sin(y))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -50000000.0], t$95$0, If[LessEqual[z, 2.8], N[(1.0 * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(z, \cos y, x\right)\\
\mathbf{if}\;z \leq -50000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.8:\\
\;\;\;\;\mathsf{fma}\left(1, z, x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5e7 or 2.7999999999999998 < z Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6463.1
Applied rewrites63.1%
Taylor expanded in z around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
Applied rewrites99.5%
if -5e7 < z < 2.7999999999999998Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites98.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma z (cos y) x))) (if (<= z -4e-23) t_0 (if (<= z 1.25e-11) (+ x (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(z, cos(y), x);
double tmp;
if (z <= -4e-23) {
tmp = t_0;
} else if (z <= 1.25e-11) {
tmp = x + sin(y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(z, cos(y), x) tmp = 0.0 if (z <= -4e-23) tmp = t_0; elseif (z <= 1.25e-11) tmp = Float64(x + sin(y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -4e-23], t$95$0, If[LessEqual[z, 1.25e-11], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(z, \cos y, x\right)\\
\mathbf{if}\;z \leq -4 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-11}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.99999999999999984e-23 or 1.25000000000000005e-11 < z Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6465.5
Applied rewrites65.5%
Taylor expanded in z around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
Applied rewrites98.3%
if -3.99999999999999984e-23 < z < 1.25000000000000005e-11Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6492.8
Applied rewrites92.8%
Final simplification95.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (sin y))))
(if (<= y -0.014)
t_0
(if (<= y 0.48)
(+
(+ y x)
(fma
(* y y)
(fma
(* y y)
(* z (fma y (* y -0.001388888888888889) 0.041666666666666664))
(* z -0.5))
z))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.014) {
tmp = t_0;
} else if (y <= 0.48) {
tmp = (y + x) + fma((y * y), fma((y * y), (z * fma(y, (y * -0.001388888888888889), 0.041666666666666664)), (z * -0.5)), z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.014) tmp = t_0; elseif (y <= 0.48) tmp = Float64(Float64(y + x) + fma(Float64(y * y), fma(Float64(y * y), Float64(z * fma(y, Float64(y * -0.001388888888888889), 0.041666666666666664)), Float64(z * -0.5)), z)); 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.014], t$95$0, If[LessEqual[y, 0.48], N[(N[(y + x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * N[(z * N[(y * N[(y * -0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.014:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.48:\\
\;\;\;\;\left(y + x\right) + \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, z \cdot \mathsf{fma}\left(y, y \cdot -0.001388888888888889, 0.041666666666666664\right), z \cdot -0.5\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0140000000000000003 or 0.47999999999999998 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6462.7
Applied rewrites62.7%
if -0.0140000000000000003 < y < 0.47999999999999998Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification80.9%
(FPCore (x y z)
:precision binary64
(if (<= y -62.0)
(+ z x)
(if (<= y 1600.0)
(+
(+ y x)
(fma
(* y y)
(fma
(* y y)
(* z (fma y (* y -0.001388888888888889) 0.041666666666666664))
(* z -0.5))
z))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -62.0) {
tmp = z + x;
} else if (y <= 1600.0) {
tmp = (y + x) + fma((y * y), fma((y * y), (z * fma(y, (y * -0.001388888888888889), 0.041666666666666664)), (z * -0.5)), z);
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -62.0) tmp = Float64(z + x); elseif (y <= 1600.0) tmp = Float64(Float64(y + x) + fma(Float64(y * y), fma(Float64(y * y), Float64(z * fma(y, Float64(y * -0.001388888888888889), 0.041666666666666664)), Float64(z * -0.5)), z)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -62.0], N[(z + x), $MachinePrecision], If[LessEqual[y, 1600.0], N[(N[(y + x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * N[(z * N[(y * N[(y * -0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -62:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 1600:\\
\;\;\;\;\left(y + x\right) + \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, z \cdot \mathsf{fma}\left(y, y \cdot -0.001388888888888889, 0.041666666666666664\right), z \cdot -0.5\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -62 or 1600 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.6
Applied rewrites40.6%
if -62 < y < 1600Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.3%
(FPCore (x y z)
:precision binary64
(if (<= y -62.0)
(+ z x)
(if (<= y 1600.0)
(+
(+ y x)
(*
z
(fma
(* y y)
(fma
(* y y)
(fma y (* y -0.001388888888888889) 0.041666666666666664)
-0.5)
1.0)))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -62.0) {
tmp = z + x;
} else if (y <= 1600.0) {
tmp = (y + x) + (z * fma((y * y), fma((y * y), fma(y, (y * -0.001388888888888889), 0.041666666666666664), -0.5), 1.0));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -62.0) tmp = Float64(z + x); elseif (y <= 1600.0) tmp = Float64(Float64(y + x) + Float64(z * fma(Float64(y * y), fma(Float64(y * y), fma(y, Float64(y * -0.001388888888888889), 0.041666666666666664), -0.5), 1.0))); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -62.0], N[(z + x), $MachinePrecision], If[LessEqual[y, 1600.0], N[(N[(y + x), $MachinePrecision] + N[(z * N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * N[(y * N[(y * -0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -62:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 1600:\\
\;\;\;\;\left(y + x\right) + z \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot -0.001388888888888889, 0.041666666666666664\right), -0.5\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -62 or 1600 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.6
Applied rewrites40.6%
if -62 < y < 1600Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
(FPCore (x y z)
:precision binary64
(if (<= y -4.5e+33)
(+ z x)
(if (<= y 280.0)
(+
(+ y x)
(* z (fma (* y y) (fma (* y y) 0.041666666666666664 -0.5) 1.0)))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+33) {
tmp = z + x;
} else if (y <= 280.0) {
tmp = (y + x) + (z * fma((y * y), fma((y * y), 0.041666666666666664, -0.5), 1.0));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+33) tmp = Float64(z + x); elseif (y <= 280.0) tmp = Float64(Float64(y + x) + Float64(z * fma(Float64(y * y), fma(Float64(y * y), 0.041666666666666664, -0.5), 1.0))); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+33], N[(z + x), $MachinePrecision], If[LessEqual[y, 280.0], N[(N[(y + x), $MachinePrecision] + N[(z * N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * 0.041666666666666664 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+33}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 280:\\
\;\;\;\;\left(y + x\right) + z \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, 0.041666666666666664, -0.5\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -4.5e33 or 280 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6441.0
Applied rewrites41.0%
if -4.5e33 < y < 280Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6498.1
Applied rewrites98.1%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.0
Applied rewrites97.0%
(FPCore (x y z)
:precision binary64
(if (<= y -1.8e+32)
(+ z x)
(if (<= y 1600.0)
(fma y (fma y (fma y -0.16666666666666666 (* z -0.5)) 1.0) (+ z x))
(+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+32) {
tmp = z + x;
} else if (y <= 1600.0) {
tmp = fma(y, fma(y, fma(y, -0.16666666666666666, (z * -0.5)), 1.0), (z + x));
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+32) tmp = Float64(z + x); elseif (y <= 1600.0) tmp = fma(y, fma(y, fma(y, -0.16666666666666666, Float64(z * -0.5)), 1.0), Float64(z + x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+32], N[(z + x), $MachinePrecision], If[LessEqual[y, 1600.0], N[(y * N[(y * N[(y * -0.16666666666666666 + N[(z * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+32}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 1600:\\
\;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(y, -0.16666666666666666, z \cdot -0.5\right), 1\right), z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -1.7999999999999998e32 or 1600 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.7
Applied rewrites40.7%
if -1.7999999999999998e32 < y < 1600Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.5
Applied rewrites97.5%
(FPCore (x y z) :precision binary64 (if (<= y -6.8e+33) (+ z x) (if (<= y 7.5e+46) (+ z (fma y (fma y (* z -0.5) 1.0) x)) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.8e+33) {
tmp = z + x;
} else if (y <= 7.5e+46) {
tmp = z + fma(y, fma(y, (z * -0.5), 1.0), x);
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6.8e+33) tmp = Float64(z + x); elseif (y <= 7.5e+46) tmp = Float64(z + fma(y, fma(y, Float64(z * -0.5), 1.0), x)); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6.8e+33], N[(z + x), $MachinePrecision], If[LessEqual[y, 7.5e+46], N[(z + N[(y * N[(y * N[(z * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+33}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+46}:\\
\;\;\;\;z + \mathsf{fma}\left(y, \mathsf{fma}\left(y, z \cdot -0.5, 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -6.7999999999999999e33 or 7.5000000000000003e46 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.3
Applied rewrites40.3%
if -6.7999999999999999e33 < y < 7.5000000000000003e46Initial 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-*.f6492.9
Applied rewrites92.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.2) (+ z x) (if (<= y 1200000000000.0) (+ y (+ z x)) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2) {
tmp = z + x;
} else if (y <= 1200000000000.0) {
tmp = y + (z + 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 (y <= (-3.2d0)) then
tmp = z + x
else if (y <= 1200000000000.0d0) then
tmp = y + (z + x)
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.2) {
tmp = z + x;
} else if (y <= 1200000000000.0) {
tmp = y + (z + x);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2: tmp = z + x elif y <= 1200000000000.0: tmp = y + (z + x) else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2) tmp = Float64(z + x); elseif (y <= 1200000000000.0) tmp = Float64(y + Float64(z + x)); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.2) tmp = z + x; elseif (y <= 1200000000000.0) tmp = y + (z + x); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2], N[(z + x), $MachinePrecision], If[LessEqual[y, 1200000000000.0], N[(y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 1200000000000:\\
\;\;\;\;y + \left(z + x\right)\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if y < -3.2000000000000002 or 1.2e12 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6441.4
Applied rewrites41.4%
if -3.2000000000000002 < y < 1.2e12Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6496.1
Applied rewrites96.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.4e-78) (+ z x) (if (<= x 2.7e-241) (+ y z) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e-78) {
tmp = z + x;
} else if (x <= 2.7e-241) {
tmp = y + 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 (x <= (-1.4d-78)) then
tmp = z + x
else if (x <= 2.7d-241) then
tmp = y + z
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e-78) {
tmp = z + x;
} else if (x <= 2.7e-241) {
tmp = y + z;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.4e-78: tmp = z + x elif x <= 2.7e-241: tmp = y + z else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.4e-78) tmp = Float64(z + x); elseif (x <= 2.7e-241) tmp = Float64(y + z); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.4e-78) tmp = z + x; elseif (x <= 2.7e-241) tmp = y + z; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.4e-78], N[(z + x), $MachinePrecision], If[LessEqual[x, 2.7e-241], N[(y + z), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-78}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-241}:\\
\;\;\;\;y + z\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if x < -1.40000000000000012e-78 or 2.6999999999999999e-241 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6470.9
Applied rewrites70.9%
if -1.40000000000000012e-78 < x < 2.6999999999999999e-241Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6460.2
Applied rewrites60.2%
Taylor expanded in x around 0
Applied rewrites60.2%
(FPCore (x y z) :precision binary64 (if (<= x -3.1e+46) (+ y x) (if (<= x 6.7e+47) (+ y z) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.1e+46) {
tmp = y + x;
} else if (x <= 6.7e+47) {
tmp = y + z;
} else {
tmp = y + 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 (x <= (-3.1d+46)) then
tmp = y + x
else if (x <= 6.7d+47) then
tmp = y + z
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.1e+46) {
tmp = y + x;
} else if (x <= 6.7e+47) {
tmp = y + z;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.1e+46: tmp = y + x elif x <= 6.7e+47: tmp = y + z else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.1e+46) tmp = Float64(y + x); elseif (x <= 6.7e+47) tmp = Float64(y + z); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.1e+46) tmp = y + x; elseif (x <= 6.7e+47) tmp = y + z; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.1e+46], N[(y + x), $MachinePrecision], If[LessEqual[x, 6.7e+47], N[(y + z), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+46}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;x \leq 6.7 \cdot 10^{+47}:\\
\;\;\;\;y + z\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if x < -3.09999999999999975e46 or 6.69999999999999973e47 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6474.9
Applied rewrites74.9%
Taylor expanded in z around 0
Applied rewrites63.6%
if -3.09999999999999975e46 < x < 6.69999999999999973e47Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6450.4
Applied rewrites50.4%
Taylor expanded in x around 0
Applied rewrites44.0%
Final simplification52.5%
(FPCore (x y z) :precision binary64 (+ y x))
double code(double x, double y, double z) {
return y + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y + x
end function
public static double code(double x, double y, double z) {
return y + x;
}
def code(x, y, z): return y + x
function code(x, y, z) return Float64(y + x) end
function tmp = code(x, y, z) tmp = y + x; end
code[x_, y_, z_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6461.0
Applied rewrites61.0%
Taylor expanded in z around 0
Applied rewrites36.6%
Final simplification36.6%
herbie shell --seed 2024220
(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))))