
(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
(if (<= z -9e+125)
(* z (cos y))
(if (<= z 1020000000.0)
(fma 1.0 z (fma (/ (sin y) x) x x))
(fma (cos y) z (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+125) {
tmp = z * cos(y);
} else if (z <= 1020000000.0) {
tmp = fma(1.0, z, fma((sin(y) / x), x, x));
} else {
tmp = fma(cos(y), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -9e+125) tmp = Float64(z * cos(y)); elseif (z <= 1020000000.0) tmp = fma(1.0, z, fma(Float64(sin(y) / x), x, x)); else tmp = fma(cos(y), z, Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -9e+125], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1020000000.0], N[(1.0 * z + N[(N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+125}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{elif}\;z \leq 1020000000:\\
\;\;\;\;\mathsf{fma}\left(1, z, \mathsf{fma}\left(\frac{\sin y}{x}, x, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\end{array}
\end{array}
if z < -9.0000000000000001e125Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6492.1
Applied rewrites92.1%
if -9.0000000000000001e125 < z < 1.02e9Initial 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 rewrites97.0%
if 1.02e9 < z Initial 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-+.f6487.1
Applied rewrites87.1%
Final simplification93.6%
(FPCore (x y z)
:precision binary64
(if (<= z -9e+125)
(* z (cos y))
(if (<= z -1.12e-72)
(+ x z)
(if (<= z 8e-59) (+ x (sin y)) (fma (cos y) z (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+125) {
tmp = z * cos(y);
} else if (z <= -1.12e-72) {
tmp = x + z;
} else if (z <= 8e-59) {
tmp = x + sin(y);
} else {
tmp = fma(cos(y), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -9e+125) tmp = Float64(z * cos(y)); elseif (z <= -1.12e-72) tmp = Float64(x + z); elseif (z <= 8e-59) 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, -9e+125], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.12e-72], N[(x + z), $MachinePrecision], If[LessEqual[z, 8e-59], 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 -9 \cdot 10^{+125}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-72}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-59}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\end{array}
\end{array}
if z < -9.0000000000000001e125Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6492.1
Applied rewrites92.1%
if -9.0000000000000001e125 < z < -1.12000000000000005e-72Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6483.8
Applied rewrites83.8%
if -1.12000000000000005e-72 < z < 8.0000000000000002e-59Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6497.6
Applied rewrites97.6%
if 8.0000000000000002e-59 < z Initial 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-+.f6486.5
Applied rewrites86.5%
Final simplification91.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -9e+125)
t_0
(if (<= z -1.12e-72)
(+ x z)
(if (<= z 11200000000.0) (+ x (sin y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -9e+125) {
tmp = t_0;
} else if (z <= -1.12e-72) {
tmp = x + z;
} else if (z <= 11200000000.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 = z * cos(y)
if (z <= (-9d+125)) then
tmp = t_0
else if (z <= (-1.12d-72)) then
tmp = x + z
else if (z <= 11200000000.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 = z * Math.cos(y);
double tmp;
if (z <= -9e+125) {
tmp = t_0;
} else if (z <= -1.12e-72) {
tmp = x + z;
} else if (z <= 11200000000.0) {
tmp = x + Math.sin(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -9e+125: tmp = t_0 elif z <= -1.12e-72: tmp = x + z elif z <= 11200000000.0: tmp = x + math.sin(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -9e+125) tmp = t_0; elseif (z <= -1.12e-72) tmp = Float64(x + z); elseif (z <= 11200000000.0) tmp = Float64(x + sin(y)); 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 <= -9e+125) tmp = t_0; elseif (z <= -1.12e-72) tmp = x + z; elseif (z <= 11200000000.0) tmp = x + sin(y); 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, -9e+125], t$95$0, If[LessEqual[z, -1.12e-72], N[(x + z), $MachinePrecision], If[LessEqual[z, 11200000000.0], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -9 \cdot 10^{+125}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-72}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 11200000000:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.0000000000000001e125 or 1.12e10 < z Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.9
Applied rewrites85.9%
if -9.0000000000000001e125 < z < -1.12000000000000005e-72Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6483.8
Applied rewrites83.8%
if -1.12000000000000005e-72 < z < 1.12e10Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6495.2
Applied rewrites95.2%
Final simplification89.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (sin y))))
(if (<= y -0.0037)
t_0
(if (<= y 5e-14)
(+
(* (fma (fma 0.041666666666666664 (* y y) -0.5) (* y y) 1.0) z)
(+ x y))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.0037) {
tmp = t_0;
} else if (y <= 5e-14) {
tmp = (fma(fma(0.041666666666666664, (y * y), -0.5), (y * y), 1.0) * z) + (x + y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.0037) tmp = t_0; elseif (y <= 5e-14) tmp = Float64(Float64(fma(fma(0.041666666666666664, Float64(y * y), -0.5), Float64(y * y), 1.0) * z) + Float64(x + y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.0037], t$95$0, If[LessEqual[y, 5e-14], N[(N[(N[(N[(0.041666666666666664 * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.0037:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y \cdot y, -0.5\right), y \cdot y, 1\right) \cdot z + \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0037000000000000002 or 5.0000000000000002e-14 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6463.3
Applied rewrites63.3%
if -0.0037000000000000002 < y < 5.0000000000000002e-14Initial 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
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification81.7%
(FPCore (x y z)
:precision binary64
(if (<= y -1050.0)
(+ x z)
(if (<= y 1.7e+35)
(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 <= -1050.0) {
tmp = x + z;
} else if (y <= 1.7e+35) {
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 <= -1050.0) tmp = Float64(x + z); elseif (y <= 1.7e+35) 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, -1050.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.7e+35], 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 -1050:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+35}:\\
\;\;\;\;\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 < -1050 or 1.7000000000000001e35 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.1
Applied rewrites40.1%
if -1050 < y < 1.7000000000000001e35Initial 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.0
Applied rewrites95.0%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (<= y -1050.0) (+ x z) (if (<= y 1.32e+20) (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 <= -1050.0) {
tmp = x + z;
} else if (y <= 1.32e+20) {
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 <= -1050.0) tmp = Float64(x + z); elseif (y <= 1.32e+20) 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, -1050.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.32e+20], 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 -1050:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.32 \cdot 10^{+20}:\\
\;\;\;\;\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 < -1050 or 1.32e20 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6439.9
Applied rewrites39.9%
if -1050 < y < 1.32e20Initial 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-+.f6496.0
Applied rewrites96.0%
Final simplification70.4%
(FPCore (x y z)
:precision binary64
(if (<= y -15600000.0)
(+ x z)
(if (<= y 1.7e+35)
(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 <= -15600000.0) {
tmp = x + z;
} else if (y <= 1.7e+35) {
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 <= -15600000.0) tmp = Float64(x + z); elseif (y <= 1.7e+35) 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, -15600000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.7e+35], 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 -15600000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+35}:\\
\;\;\;\;\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 < -1.56e7 or 1.7000000000000001e35 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6440.3
Applied rewrites40.3%
if -1.56e7 < y < 1.7000000000000001e35Initial 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-+.f6494.3
Applied rewrites94.3%
Taylor expanded in z around 0
Applied rewrites93.9%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (<= y -4600000000.0) (+ x z) (if (<= y 2.95e+119) (+ (+ x y) z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4600000000.0) {
tmp = x + z;
} else if (y <= 2.95e+119) {
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 <= (-4600000000.0d0)) then
tmp = x + z
else if (y <= 2.95d+119) 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 <= -4600000000.0) {
tmp = x + z;
} else if (y <= 2.95e+119) {
tmp = (x + y) + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4600000000.0: tmp = x + z elif y <= 2.95e+119: tmp = (x + y) + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4600000000.0) tmp = Float64(x + z); elseif (y <= 2.95e+119) 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 <= -4600000000.0) tmp = x + z; elseif (y <= 2.95e+119) tmp = (x + y) + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4600000000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 2.95e+119], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4600000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{+119}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -4.6e9 or 2.95e119 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6443.2
Applied rewrites43.2%
if -4.6e9 < y < 2.95e119Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6487.6
Applied rewrites87.6%
Final simplification70.1%
(FPCore (x y z) :precision binary64 (if (<= z -7e+47) (+ z y) (if (<= z 1.05e+60) (+ x y) (+ z y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7e+47) {
tmp = z + y;
} else if (z <= 1.05e+60) {
tmp = x + y;
} else {
tmp = z + 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 (z <= (-7d+47)) then
tmp = z + y
else if (z <= 1.05d+60) then
tmp = x + y
else
tmp = z + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7e+47) {
tmp = z + y;
} else if (z <= 1.05e+60) {
tmp = x + y;
} else {
tmp = z + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7e+47: tmp = z + y elif z <= 1.05e+60: tmp = x + y else: tmp = z + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7e+47) tmp = Float64(z + y); elseif (z <= 1.05e+60) tmp = Float64(x + y); else tmp = Float64(z + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7e+47) tmp = z + y; elseif (z <= 1.05e+60) tmp = x + y; else tmp = z + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7e+47], N[(z + y), $MachinePrecision], If[LessEqual[z, 1.05e+60], N[(x + y), $MachinePrecision], N[(z + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+47}:\\
\;\;\;\;z + y\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+60}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z + y\\
\end{array}
\end{array}
if z < -7.00000000000000031e47 or 1.0500000000000001e60 < z Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6464.3
Applied rewrites64.3%
Taylor expanded in x around 0
Applied rewrites50.8%
if -7.00000000000000031e47 < z < 1.0500000000000001e60Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6461.9
Applied rewrites61.9%
Taylor expanded in z around 0
Applied rewrites53.9%
Final simplification52.6%
(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.1
Applied rewrites66.1%
Final simplification66.1%
(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
lower-+.f64N/A
+-commutativeN/A
lower-+.f6462.9
Applied rewrites62.9%
Taylor expanded in z around 0
Applied rewrites37.4%
Final simplification37.4%
herbie shell --seed 2024254
(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))))