
(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 12 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
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* z (cos y)) (+ x (sin y)))))
(if (<= t_0 -40.0)
(+ x z)
(if (<= t_0 -0.04)
(sin y)
(if (<= t_0 2e-15) (+ (+ x y) z) (if (<= t_0 2.0) (sin y) (+ x z)))))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (x + sin(y));
double tmp;
if (t_0 <= -40.0) {
tmp = x + z;
} else if (t_0 <= -0.04) {
tmp = sin(y);
} else if (t_0 <= 2e-15) {
tmp = (x + y) + z;
} else if (t_0 <= 2.0) {
tmp = sin(y);
} 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 = (z * cos(y)) + (x + sin(y))
if (t_0 <= (-40.0d0)) then
tmp = x + z
else if (t_0 <= (-0.04d0)) then
tmp = sin(y)
else if (t_0 <= 2d-15) then
tmp = (x + y) + z
else if (t_0 <= 2.0d0) then
tmp = sin(y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * Math.cos(y)) + (x + Math.sin(y));
double tmp;
if (t_0 <= -40.0) {
tmp = x + z;
} else if (t_0 <= -0.04) {
tmp = Math.sin(y);
} else if (t_0 <= 2e-15) {
tmp = (x + y) + z;
} else if (t_0 <= 2.0) {
tmp = Math.sin(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * math.cos(y)) + (x + math.sin(y)) tmp = 0 if t_0 <= -40.0: tmp = x + z elif t_0 <= -0.04: tmp = math.sin(y) elif t_0 <= 2e-15: tmp = (x + y) + z elif t_0 <= 2.0: tmp = math.sin(y) else: tmp = x + z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(x + sin(y))) tmp = 0.0 if (t_0 <= -40.0) tmp = Float64(x + z); elseif (t_0 <= -0.04) tmp = sin(y); elseif (t_0 <= 2e-15) tmp = Float64(Float64(x + y) + z); elseif (t_0 <= 2.0) tmp = sin(y); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * cos(y)) + (x + sin(y)); tmp = 0.0; if (t_0 <= -40.0) tmp = x + z; elseif (t_0 <= -0.04) tmp = sin(y); elseif (t_0 <= 2e-15) tmp = (x + y) + z; elseif (t_0 <= 2.0) tmp = sin(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -40.0], N[(x + z), $MachinePrecision], If[LessEqual[t$95$0, -0.04], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 2e-15], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[Sin[y], $MachinePrecision], N[(x + z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \left(x + \sin y\right)\\
\mathbf{if}\;t\_0 \leq -40:\\
\;\;\;\;x + z\\
\mathbf{elif}\;t\_0 \leq -0.04:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -40 or 2 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6477.1
Applied rewrites77.1%
if -40 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.0400000000000000008 or 2.0000000000000002e-15 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 2Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites94.1%
if -0.0400000000000000008 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 2.0000000000000002e-15Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification81.9%
(FPCore (x y z) :precision binary64 (if (<= y -0.28) (fma (cos y) z (sin y)) (if (<= y 1.8e+140) (fma (cos y) z (+ x y)) (+ x (sin y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.28) {
tmp = fma(cos(y), z, sin(y));
} else if (y <= 1.8e+140) {
tmp = fma(cos(y), z, (x + y));
} else {
tmp = x + sin(y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -0.28) tmp = fma(cos(y), z, sin(y)); elseif (y <= 1.8e+140) tmp = fma(cos(y), z, Float64(x + y)); else tmp = Float64(x + sin(y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -0.28], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+140], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.28:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \sin y\\
\end{array}
\end{array}
if y < -0.28000000000000003Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f6468.3
Applied rewrites68.3%
if -0.28000000000000003 < y < 1.8e140Initial 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 y around 0
+-commutativeN/A
lower-+.f6495.6
Applied rewrites95.6%
if 1.8e140 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6484.7
Applied rewrites84.7%
Final simplification87.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -4.7e+129)
t_0
(if (<= z -2e-45)
(+ x z)
(if (<= z 2.9e-16) (+ x (sin y)) (if (<= z 2.8e+206) (+ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -4.7e+129) {
tmp = t_0;
} else if (z <= -2e-45) {
tmp = x + z;
} else if (z <= 2.9e-16) {
tmp = x + sin(y);
} else if (z <= 2.8e+206) {
tmp = x + z;
} 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 = z * cos(y)
if (z <= (-4.7d+129)) then
tmp = t_0
else if (z <= (-2d-45)) then
tmp = x + z
else if (z <= 2.9d-16) then
tmp = x + sin(y)
else if (z <= 2.8d+206) then
tmp = x + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -4.7e+129) {
tmp = t_0;
} else if (z <= -2e-45) {
tmp = x + z;
} else if (z <= 2.9e-16) {
tmp = x + Math.sin(y);
} else if (z <= 2.8e+206) {
tmp = x + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -4.7e+129: tmp = t_0 elif z <= -2e-45: tmp = x + z elif z <= 2.9e-16: tmp = x + math.sin(y) elif z <= 2.8e+206: tmp = x + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -4.7e+129) tmp = t_0; elseif (z <= -2e-45) tmp = Float64(x + z); elseif (z <= 2.9e-16) tmp = Float64(x + sin(y)); elseif (z <= 2.8e+206) tmp = Float64(x + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -4.7e+129) tmp = t_0; elseif (z <= -2e-45) tmp = x + z; elseif (z <= 2.9e-16) tmp = x + sin(y); elseif (z <= 2.8e+206) tmp = x + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e+129], t$95$0, If[LessEqual[z, -2e-45], N[(x + z), $MachinePrecision], If[LessEqual[z, 2.9e-16], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e+206], N[(x + z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-45}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-16}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+206}:\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.70000000000000008e129 or 2.7999999999999998e206 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6489.8
Applied rewrites89.8%
if -4.70000000000000008e129 < z < -1.99999999999999997e-45 or 2.8999999999999998e-16 < z < 2.7999999999999998e206Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6478.4
Applied rewrites78.4%
if -1.99999999999999997e-45 < z < 2.8999999999999998e-16Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6494.6
Applied rewrites94.6%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(if (<= z -4.7e+129)
(* z (cos y))
(if (<= z -2e-45)
(+ x z)
(if (<= z 3.3e+67) (+ x (sin y)) (fma (cos y) z (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.7e+129) {
tmp = z * cos(y);
} else if (z <= -2e-45) {
tmp = x + z;
} else if (z <= 3.3e+67) {
tmp = x + sin(y);
} else {
tmp = fma(cos(y), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -4.7e+129) tmp = Float64(z * cos(y)); elseif (z <= -2e-45) tmp = Float64(x + z); elseif (z <= 3.3e+67) tmp = Float64(x + sin(y)); else tmp = fma(cos(y), z, Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -4.7e+129], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2e-45], N[(x + z), $MachinePrecision], If[LessEqual[z, 3.3e+67], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{+129}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-45}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+67}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\end{array}
\end{array}
if z < -4.70000000000000008e129Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6489.6
Applied rewrites89.6%
if -4.70000000000000008e129 < z < -1.99999999999999997e-45Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6497.1
Applied rewrites97.1%
if -1.99999999999999997e-45 < z < 3.3000000000000003e67Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if 3.3000000000000003e67 < z 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%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6484.5
Applied rewrites84.5%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (sin y)))) (if (<= y -0.00016) t_0 (if (<= y 520000.0) (+ (+ x y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.00016) {
tmp = t_0;
} else if (y <= 520000.0) {
tmp = (x + y) + z;
} 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 = x + sin(y)
if (y <= (-0.00016d0)) then
tmp = t_0
else if (y <= 520000.0d0) then
tmp = (x + y) + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + Math.sin(y);
double tmp;
if (y <= -0.00016) {
tmp = t_0;
} else if (y <= 520000.0) {
tmp = (x + y) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.sin(y) tmp = 0 if y <= -0.00016: tmp = t_0 elif y <= 520000.0: tmp = (x + y) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.00016) tmp = t_0; elseif (y <= 520000.0) tmp = Float64(Float64(x + y) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + sin(y); tmp = 0.0; if (y <= -0.00016) tmp = t_0; elseif (y <= 520000.0) tmp = (x + y) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.00016], t$95$0, If[LessEqual[y, 520000.0], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.00016:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 520000:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.60000000000000013e-4 or 5.2e5 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6462.1
Applied rewrites62.1%
if -1.60000000000000013e-4 < y < 5.2e5Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Final simplification81.6%
(FPCore (x y z)
:precision binary64
(if (<= y -1.05e+38)
(+ x z)
(if (<= y 1.4e-6)
(fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ x z))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+38) {
tmp = x + z;
} else if (y <= 1.4e-6) {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+38) tmp = Float64(x + z); elseif (y <= 1.4e-6) tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(x + z)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+38], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.4e-6], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(x + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+38}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.05e38 or 1.39999999999999994e-6 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.7
Applied rewrites40.7%
if -1.05e38 < y < 1.39999999999999994e-6Initial 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-+.f6495.8
Applied rewrites95.8%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (<= y -1.05e+38) (+ x z) (if (<= y 1.4e-6) (fma (fma (* -0.5 y) z 1.0) y (+ x z)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+38) {
tmp = x + z;
} else if (y <= 1.4e-6) {
tmp = fma(fma((-0.5 * y), z, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+38) tmp = Float64(x + z); elseif (y <= 1.4e-6) tmp = fma(fma(Float64(-0.5 * y), z, 1.0), y, Float64(x + z)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+38], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.4e-6], N[(N[(N[(-0.5 * y), $MachinePrecision] * z + 1.0), $MachinePrecision] * y + N[(x + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+38}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.05e38 or 1.39999999999999994e-6 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.7
Applied rewrites40.7%
if -1.05e38 < y < 1.39999999999999994e-6Initial 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-+.f6495.7
Applied rewrites95.7%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (<= y -4.9e+67) (+ x z) (if (<= y 6e-27) (+ (+ x y) z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.9e+67) {
tmp = x + z;
} else if (y <= 6e-27) {
tmp = (x + y) + 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) :: tmp
if (y <= (-4.9d+67)) then
tmp = x + z
else if (y <= 6d-27) then
tmp = (x + y) + z
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.9e+67) {
tmp = x + z;
} else if (y <= 6e-27) {
tmp = (x + y) + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.9e+67: tmp = x + z elif y <= 6e-27: tmp = (x + y) + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.9e+67) tmp = Float64(x + z); elseif (y <= 6e-27) tmp = Float64(Float64(x + y) + z); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.9e+67) tmp = x + z; elseif (y <= 6e-27) tmp = (x + y) + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.9e+67], N[(x + z), $MachinePrecision], If[LessEqual[y, 6e-27], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.9 \cdot 10^{+67}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-27}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -4.8999999999999999e67 or 6.0000000000000002e-27 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6442.8
Applied rewrites42.8%
if -4.8999999999999999e67 < y < 6.0000000000000002e-27Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6495.0
Applied rewrites95.0%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.15e-21) (+ x y) (if (<= x 1.2e+60) (+ z y) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e-21) {
tmp = x + y;
} else if (x <= 1.2e+60) {
tmp = z + y;
} else {
tmp = x + y;
}
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 <= (-2.15d-21)) then
tmp = x + y
else if (x <= 1.2d+60) then
tmp = z + y
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e-21) {
tmp = x + y;
} else if (x <= 1.2e+60) {
tmp = z + y;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.15e-21: tmp = x + y elif x <= 1.2e+60: tmp = z + y else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.15e-21) tmp = Float64(x + y); elseif (x <= 1.2e+60) tmp = Float64(z + y); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.15e-21) tmp = x + y; elseif (x <= 1.2e+60) tmp = z + y; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.15e-21], N[(x + y), $MachinePrecision], If[LessEqual[x, 1.2e+60], N[(z + y), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-21}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+60}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if x < -2.1499999999999999e-21 or 1.2e60 < x Initial 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-+.f6464.4
Applied rewrites64.4%
Taylor expanded in z around 0
Applied rewrites62.3%
if -2.1499999999999999e-21 < x < 1.2e60Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6445.2
Applied rewrites45.2%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6451.9
Applied rewrites51.9%
Taylor expanded in x around 0
Applied rewrites42.7%
Final simplification53.5%
(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%
(FPCore (x y z) :precision binary64 (+ x y))
double code(double x, double y, double z) {
return x + 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 + y
end function
public static double code(double x, double y, double z) {
return x + y;
}
def code(x, y, z): return x + y
function code(x, y, z) return Float64(x + y) end
function tmp = code(x, y, z) tmp = x + y; end
code[x_, y_, z_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
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-+.f6457.9
Applied rewrites57.9%
Taylor expanded in z around 0
Applied rewrites43.4%
Final simplification43.4%
herbie shell --seed 2024249
(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))))