
(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 (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)) (/ 1.0 (/ 1.0 x)))))
(if (<= z -680000000000.0)
t_0
(if (<= z 0.0005) (fma 1.0 z (+ x (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = (z * cos(y)) + (1.0 / (1.0 / x));
double tmp;
if (z <= -680000000000.0) {
tmp = t_0;
} else if (z <= 0.0005) {
tmp = fma(1.0, z, (x + sin(y)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * cos(y)) + Float64(1.0 / Float64(1.0 / x))) tmp = 0.0 if (z <= -680000000000.0) tmp = t_0; elseif (z <= 0.0005) 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[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -680000000000.0], t$95$0, If[LessEqual[z, 0.0005], N[(1.0 * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y + \frac{1}{\frac{1}{x}}\\
\mathbf{if}\;z \leq -680000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.0005:\\
\;\;\;\;\mathsf{fma}\left(1, z, x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6.8e11 or 5.0000000000000001e-4 < z Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in x around inf
lower-/.f6499.6
Applied rewrites99.6%
if -6.8e11 < z < 5.0000000000000001e-4Initial 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
Applied rewrites99.5%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (cos y) z (+ x y))))
(if (<= z -3.6e+83)
t_0
(if (<= z 230000.0)
(fma 1.0 z (+ x (sin y)))
(if (<= z 9e+108) (fma (* (/ (cos y) x) z) x x) t_0)))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (x + y));
double tmp;
if (z <= -3.6e+83) {
tmp = t_0;
} else if (z <= 230000.0) {
tmp = fma(1.0, z, (x + sin(y)));
} else if (z <= 9e+108) {
tmp = fma(((cos(y) / x) * z), x, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(x + y)) tmp = 0.0 if (z <= -3.6e+83) tmp = t_0; elseif (z <= 230000.0) tmp = fma(1.0, z, Float64(x + sin(y))); elseif (z <= 9e+108) tmp = fma(Float64(Float64(cos(y) / x) * z), 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[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+83], t$95$0, If[LessEqual[z, 230000.0], N[(1.0 * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e+108], N[(N[(N[(N[Cos[y], $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * x + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 230000:\\
\;\;\;\;\mathsf{fma}\left(1, z, x + \sin y\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\cos y}{x} \cdot z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.5999999999999997e83 or 9e108 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6487.1
Applied rewrites87.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6487.1
Applied rewrites87.1%
if -3.5999999999999997e83 < z < 2.3e5Initial 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
Applied rewrites95.8%
if 2.3e5 < z < 9e108Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f6491.4
Applied rewrites91.4%
Taylor expanded in x around inf
lower-/.f6499.5
Applied rewrites99.5%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6495.3
Applied rewrites95.3%
Taylor expanded in z around inf
Applied rewrites95.3%
Final simplification92.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (cos y) z (+ x y))))
(if (<= z -3.6e+83)
t_0
(if (<= z 1.45e+70) (fma 1.0 z (+ x (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (x + y));
double tmp;
if (z <= -3.6e+83) {
tmp = t_0;
} else if (z <= 1.45e+70) {
tmp = fma(1.0, z, (x + sin(y)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(x + y)) tmp = 0.0 if (z <= -3.6e+83) tmp = t_0; elseif (z <= 1.45e+70) 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[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+83], t$95$0, If[LessEqual[z, 1.45e+70], 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(\cos y, z, x + y\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+70}:\\
\;\;\;\;\mathsf{fma}\left(1, z, x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.5999999999999997e83 or 1.4499999999999999e70 < z Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6484.5
Applied rewrites84.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6484.5
Applied rewrites84.5%
if -3.5999999999999997e83 < z < 1.4499999999999999e70Initial 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
Applied rewrites93.8%
Final simplification89.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (sin y))))
(if (<= y -0.0135)
t_0
(if (<= y 86000000000.0)
(fma (fma (* -0.16666666666666666 y) y 1.0) y (+ x z))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.0135) {
tmp = t_0;
} else if (y <= 86000000000.0) {
tmp = fma(fma((-0.16666666666666666 * y), y, 1.0), y, (x + z));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.0135) tmp = t_0; elseif (y <= 86000000000.0) tmp = fma(fma(Float64(-0.16666666666666666 * y), y, 1.0), y, Float64(x + 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.0135], t$95$0, If[LessEqual[y, 86000000000.0], N[(N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(x + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.0135:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 86000000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0134999999999999998 or 8.6e10 < y Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f6475.8
Applied rewrites75.8%
Taylor expanded in x around inf
lower-/.f6476.1
Applied rewrites76.1%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6483.4
Applied rewrites83.4%
Taylor expanded in z around 0
Applied rewrites55.5%
if -0.0134999999999999998 < y < 8.6e10Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f6473.3
Applied rewrites73.3%
Taylor expanded in x around inf
lower-/.f6492.3
Applied rewrites92.3%
Taylor expanded in y around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
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-+.f6497.9
Applied rewrites97.9%
Taylor expanded in y around inf
Applied rewrites98.3%
Final simplification78.1%
(FPCore (x y z) :precision binary64 (fma 1.0 z (+ x (sin y))))
double code(double x, double y, double z) {
return fma(1.0, z, (x + sin(y)));
}
function code(x, y, z) return fma(1.0, z, Float64(x + sin(y))) end
code[x_, y_, z_] := N[(1.0 * z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1, 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%
Taylor expanded in y around 0
Applied rewrites80.2%
Final simplification80.2%
(FPCore (x y z)
:precision binary64
(if (<= y -17.0)
(+ x z)
(if (<= y 4400000.0)
(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 <= -17.0) {
tmp = x + z;
} else if (y <= 4400000.0) {
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 <= -17.0) tmp = Float64(x + z); elseif (y <= 4400000.0) 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, -17.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 4400000.0], 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 -17:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 4400000:\\
\;\;\;\;\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 < -17 or 4.4e6 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.1
Applied rewrites37.1%
if -17 < y < 4.4e6Initial 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.2
Applied rewrites99.2%
Final simplification69.6%
(FPCore (x y z)
:precision binary64
(if (<= y -3e+48)
(+ x z)
(if (<= y 15500000000000.0)
(fma (fma (* -0.16666666666666666 y) y 1.0) y (+ x z))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+48) {
tmp = x + z;
} else if (y <= 15500000000000.0) {
tmp = fma(fma((-0.16666666666666666 * y), y, 1.0), y, (x + z));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3e+48) tmp = Float64(x + z); elseif (y <= 15500000000000.0) tmp = fma(fma(Float64(-0.16666666666666666 * y), y, 1.0), y, Float64(x + z)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3e+48], N[(x + z), $MachinePrecision], If[LessEqual[y, 15500000000000.0], N[(N[(N[(-0.16666666666666666 * y), $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 -3 \cdot 10^{+48}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 15500000000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right), y, x + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -3e48 or 1.55e13 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6438.4
Applied rewrites38.4%
if -3e48 < y < 1.55e13Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f6474.2
Applied rewrites74.2%
Taylor expanded in x around inf
lower-/.f6491.1
Applied rewrites91.1%
Taylor expanded in y around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
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-+.f6492.2
Applied rewrites92.2%
Taylor expanded in y around inf
Applied rewrites92.7%
Final simplification69.6%
(FPCore (x y z) :precision binary64 (if (<= y -17.0) (+ x z) (if (<= y 4500000.0) (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 <= -17.0) {
tmp = x + z;
} else if (y <= 4500000.0) {
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 <= -17.0) tmp = Float64(x + z); elseif (y <= 4500000.0) 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, -17.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 4500000.0], 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 -17:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 4500000:\\
\;\;\;\;\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 < -17 or 4.5e6 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.1
Applied rewrites37.1%
if -17 < y < 4.5e6Initial 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-+.f6499.0
Applied rewrites99.0%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (<= y -8.6e+17) (+ x z) (if (<= y 2.5e-35) (+ (+ x y) z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.6e+17) {
tmp = x + z;
} else if (y <= 2.5e-35) {
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 <= (-8.6d+17)) then
tmp = x + z
else if (y <= 2.5d-35) 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 <= -8.6e+17) {
tmp = x + z;
} else if (y <= 2.5e-35) {
tmp = (x + y) + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.6e+17: tmp = x + z elif y <= 2.5e-35: tmp = (x + y) + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.6e+17) tmp = Float64(x + z); elseif (y <= 2.5e-35) 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 <= -8.6e+17) tmp = x + z; elseif (y <= 2.5e-35) tmp = (x + y) + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.6e+17], N[(x + z), $MachinePrecision], If[LessEqual[y, 2.5e-35], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+17}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-35}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -8.6e17 or 2.49999999999999982e-35 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6442.5
Applied rewrites42.5%
if -8.6e17 < y < 2.49999999999999982e-35Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
Final simplification69.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-+.f6465.4
Applied rewrites65.4%
Final simplification65.4%
herbie shell --seed 2024294
(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))))