
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
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) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
def code(x, y, z): return (x + y) * (z + 1.0)
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function tmp = code(x, y, z) tmp = (x + y) * (z + 1.0); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
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) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
def code(x, y, z): return (x + y) * (z + 1.0)
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function tmp = code(x, y, z) tmp = (x + y) * (z + 1.0); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}
(FPCore (x y z) :precision binary64 (+ x (+ y (* z (+ x y)))))
double code(double x, double y, double z) {
return x + (y + (z * (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 + (z * (x + y)))
end function
public static double code(double x, double y, double z) {
return x + (y + (z * (x + y)));
}
def code(x, y, z): return x + (y + (z * (x + y)))
function code(x, y, z) return Float64(x + Float64(y + Float64(z * Float64(x + y)))) end
function tmp = code(x, y, z) tmp = x + (y + (z * (x + y))); end
code[x_, y_, z_] := N[(x + N[(y + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y + z \cdot \left(x + y\right)\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
+-commutative100.0%
associate-+r+100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -3.6)
(* x z)
(if (<= z -1.95e-118)
x
(if (<= z -1.2e-137)
y
(if (<= z -2.5e-275)
x
(if (<= z 2.9e-285)
y
(if (<= z 2.3e-223)
x
(if (<= z 7.4e-116)
y
(if (<= z 7e-81) x (if (<= z 0.245) y (* x z)))))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.6) {
tmp = x * z;
} else if (z <= -1.95e-118) {
tmp = x;
} else if (z <= -1.2e-137) {
tmp = y;
} else if (z <= -2.5e-275) {
tmp = x;
} else if (z <= 2.9e-285) {
tmp = y;
} else if (z <= 2.3e-223) {
tmp = x;
} else if (z <= 7.4e-116) {
tmp = y;
} else if (z <= 7e-81) {
tmp = x;
} else if (z <= 0.245) {
tmp = 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) :: tmp
if (z <= (-3.6d0)) then
tmp = x * z
else if (z <= (-1.95d-118)) then
tmp = x
else if (z <= (-1.2d-137)) then
tmp = y
else if (z <= (-2.5d-275)) then
tmp = x
else if (z <= 2.9d-285) then
tmp = y
else if (z <= 2.3d-223) then
tmp = x
else if (z <= 7.4d-116) then
tmp = y
else if (z <= 7d-81) then
tmp = x
else if (z <= 0.245d0) then
tmp = y
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.6) {
tmp = x * z;
} else if (z <= -1.95e-118) {
tmp = x;
} else if (z <= -1.2e-137) {
tmp = y;
} else if (z <= -2.5e-275) {
tmp = x;
} else if (z <= 2.9e-285) {
tmp = y;
} else if (z <= 2.3e-223) {
tmp = x;
} else if (z <= 7.4e-116) {
tmp = y;
} else if (z <= 7e-81) {
tmp = x;
} else if (z <= 0.245) {
tmp = y;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.6: tmp = x * z elif z <= -1.95e-118: tmp = x elif z <= -1.2e-137: tmp = y elif z <= -2.5e-275: tmp = x elif z <= 2.9e-285: tmp = y elif z <= 2.3e-223: tmp = x elif z <= 7.4e-116: tmp = y elif z <= 7e-81: tmp = x elif z <= 0.245: tmp = y else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.6) tmp = Float64(x * z); elseif (z <= -1.95e-118) tmp = x; elseif (z <= -1.2e-137) tmp = y; elseif (z <= -2.5e-275) tmp = x; elseif (z <= 2.9e-285) tmp = y; elseif (z <= 2.3e-223) tmp = x; elseif (z <= 7.4e-116) tmp = y; elseif (z <= 7e-81) tmp = x; elseif (z <= 0.245) tmp = y; else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.6) tmp = x * z; elseif (z <= -1.95e-118) tmp = x; elseif (z <= -1.2e-137) tmp = y; elseif (z <= -2.5e-275) tmp = x; elseif (z <= 2.9e-285) tmp = y; elseif (z <= 2.3e-223) tmp = x; elseif (z <= 7.4e-116) tmp = y; elseif (z <= 7e-81) tmp = x; elseif (z <= 0.245) tmp = y; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.6], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.95e-118], x, If[LessEqual[z, -1.2e-137], y, If[LessEqual[z, -2.5e-275], x, If[LessEqual[z, 2.9e-285], y, If[LessEqual[z, 2.3e-223], x, If[LessEqual[z, 7.4e-116], y, If[LessEqual[z, 7e-81], x, If[LessEqual[z, 0.245], y, N[(x * z), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1.95 \cdot 10^{-118}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -1.2 \cdot 10^{-137}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -2.5 \cdot 10^{-275}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-285}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-223}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-116}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-81}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 0.245:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -3.60000000000000009 or 0.245 < z Initial program 100.0%
Taylor expanded in x around inf 48.3%
+-commutative48.3%
distribute-lft-in48.3%
*-rgt-identity48.3%
Applied egg-rr48.3%
Taylor expanded in z around inf 48.2%
if -3.60000000000000009 < z < -1.95e-118 or -1.2e-137 < z < -2.49999999999999992e-275 or 2.9e-285 < z < 2.3e-223 or 7.4000000000000005e-116 < z < 6.99999999999999973e-81Initial program 100.0%
Taylor expanded in x around inf 53.8%
Taylor expanded in z around 0 52.1%
if -1.95e-118 < z < -1.2e-137 or -2.49999999999999992e-275 < z < 2.9e-285 or 2.3e-223 < z < 7.4000000000000005e-116 or 6.99999999999999973e-81 < z < 0.245Initial program 99.9%
Taylor expanded in x around 0 46.8%
+-commutative46.8%
distribute-lft-in46.8%
*-rgt-identity46.8%
Applied egg-rr46.8%
Taylor expanded in z around 0 46.8%
Final simplification49.1%
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(* y z)
(if (<= z -1.85e-118)
x
(if (<= z -1.65e-138)
y
(if (<= z -1.35e-275)
x
(if (<= z 6e-287)
y
(if (<= z 1.65e-223)
x
(if (<= z 4.65e-116)
y
(if (<= z 1.15e-78) x (if (<= z 1.0) y (* y z)))))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= -1.85e-118) {
tmp = x;
} else if (z <= -1.65e-138) {
tmp = y;
} else if (z <= -1.35e-275) {
tmp = x;
} else if (z <= 6e-287) {
tmp = y;
} else if (z <= 1.65e-223) {
tmp = x;
} else if (z <= 4.65e-116) {
tmp = y;
} else if (z <= 1.15e-78) {
tmp = x;
} else if (z <= 1.0) {
tmp = y;
} else {
tmp = y * 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 (z <= (-1.0d0)) then
tmp = y * z
else if (z <= (-1.85d-118)) then
tmp = x
else if (z <= (-1.65d-138)) then
tmp = y
else if (z <= (-1.35d-275)) then
tmp = x
else if (z <= 6d-287) then
tmp = y
else if (z <= 1.65d-223) then
tmp = x
else if (z <= 4.65d-116) then
tmp = y
else if (z <= 1.15d-78) then
tmp = x
else if (z <= 1.0d0) then
tmp = y
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= -1.85e-118) {
tmp = x;
} else if (z <= -1.65e-138) {
tmp = y;
} else if (z <= -1.35e-275) {
tmp = x;
} else if (z <= 6e-287) {
tmp = y;
} else if (z <= 1.65e-223) {
tmp = x;
} else if (z <= 4.65e-116) {
tmp = y;
} else if (z <= 1.15e-78) {
tmp = x;
} else if (z <= 1.0) {
tmp = y;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = y * z elif z <= -1.85e-118: tmp = x elif z <= -1.65e-138: tmp = y elif z <= -1.35e-275: tmp = x elif z <= 6e-287: tmp = y elif z <= 1.65e-223: tmp = x elif z <= 4.65e-116: tmp = y elif z <= 1.15e-78: tmp = x elif z <= 1.0: tmp = y else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(y * z); elseif (z <= -1.85e-118) tmp = x; elseif (z <= -1.65e-138) tmp = y; elseif (z <= -1.35e-275) tmp = x; elseif (z <= 6e-287) tmp = y; elseif (z <= 1.65e-223) tmp = x; elseif (z <= 4.65e-116) tmp = y; elseif (z <= 1.15e-78) tmp = x; elseif (z <= 1.0) tmp = y; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = y * z; elseif (z <= -1.85e-118) tmp = x; elseif (z <= -1.65e-138) tmp = y; elseif (z <= -1.35e-275) tmp = x; elseif (z <= 6e-287) tmp = y; elseif (z <= 1.65e-223) tmp = x; elseif (z <= 4.65e-116) tmp = y; elseif (z <= 1.15e-78) tmp = x; elseif (z <= 1.0) tmp = y; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.85e-118], x, If[LessEqual[z, -1.65e-138], y, If[LessEqual[z, -1.35e-275], x, If[LessEqual[z, 6e-287], y, If[LessEqual[z, 1.65e-223], x, If[LessEqual[z, 4.65e-116], y, If[LessEqual[z, 1.15e-78], x, If[LessEqual[z, 1.0], y, N[(y * z), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.85 \cdot 10^{-118}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{-138}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{-275}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-287}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{-223}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.65 \cdot 10^{-116}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-78}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 100.0%
Taylor expanded in x around 0 58.5%
+-commutative58.5%
distribute-lft-in58.4%
*-rgt-identity58.4%
Applied egg-rr58.4%
Taylor expanded in z around inf 57.3%
*-commutative57.3%
Simplified57.3%
if -1 < z < -1.85000000000000007e-118 or -1.64999999999999991e-138 < z < -1.34999999999999997e-275 or 5.99999999999999984e-287 < z < 1.64999999999999997e-223 or 4.64999999999999999e-116 < z < 1.1500000000000001e-78Initial program 100.0%
Taylor expanded in x around inf 53.2%
Taylor expanded in z around 0 52.7%
if -1.85000000000000007e-118 < z < -1.64999999999999991e-138 or -1.34999999999999997e-275 < z < 5.99999999999999984e-287 or 1.64999999999999997e-223 < z < 4.64999999999999999e-116 or 1.1500000000000001e-78 < z < 1Initial program 99.9%
Taylor expanded in x around 0 46.8%
+-commutative46.8%
distribute-lft-in46.8%
*-rgt-identity46.8%
Applied egg-rr46.8%
Taylor expanded in z around 0 46.8%
Final simplification53.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (* y z) (if (<= z 4.8e-6) (+ x y) (if (<= z 1.1e+24) (* x (+ z 1.0)) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= 4.8e-6) {
tmp = x + y;
} else if (z <= 1.1e+24) {
tmp = x * (z + 1.0);
} else {
tmp = y * 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 (z <= (-1.0d0)) then
tmp = y * z
else if (z <= 4.8d-6) then
tmp = x + y
else if (z <= 1.1d+24) then
tmp = x * (z + 1.0d0)
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= 4.8e-6) {
tmp = x + y;
} else if (z <= 1.1e+24) {
tmp = x * (z + 1.0);
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = y * z elif z <= 4.8e-6: tmp = x + y elif z <= 1.1e+24: tmp = x * (z + 1.0) else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(y * z); elseif (z <= 4.8e-6) tmp = Float64(x + y); elseif (z <= 1.1e+24) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = y * z; elseif (z <= 4.8e-6) tmp = x + y; elseif (z <= 1.1e+24) tmp = x * (z + 1.0); else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 4.8e-6], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.1e+24], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+24}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -1 or 1.10000000000000001e24 < z Initial program 100.0%
Taylor expanded in x around 0 58.4%
+-commutative58.4%
distribute-lft-in58.4%
*-rgt-identity58.4%
Applied egg-rr58.4%
Taylor expanded in z around inf 58.4%
*-commutative58.4%
Simplified58.4%
if -1 < z < 4.7999999999999998e-6Initial program 99.9%
Taylor expanded in z around 0 98.4%
+-commutative98.4%
Simplified98.4%
if 4.7999999999999998e-6 < z < 1.10000000000000001e24Initial program 100.0%
Taylor expanded in x around inf 45.4%
Final simplification80.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (+ x y)) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x + 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x + y)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x + y);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * (x + y) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(x + y)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = z * (x + y); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 100.0%
Taylor expanded in z around inf 98.0%
+-commutative98.0%
Simplified98.0%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 98.4%
+-commutative98.4%
Simplified98.4%
Final simplification98.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 395000000.0))) (* y z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 395000000.0)) {
tmp = y * z;
} 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 ((z <= (-1.0d0)) .or. (.not. (z <= 395000000.0d0))) then
tmp = y * z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 395000000.0)) {
tmp = y * z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 395000000.0): tmp = y * z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 395000000.0)) tmp = Float64(y * z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 395000000.0))) tmp = y * z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 395000000.0]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 395000000\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1 or 3.95e8 < z Initial program 100.0%
Taylor expanded in x around 0 58.2%
+-commutative58.2%
distribute-lft-in58.2%
*-rgt-identity58.2%
Applied egg-rr58.2%
Taylor expanded in z around inf 58.2%
*-commutative58.2%
Simplified58.2%
if -1 < z < 3.95e8Initial program 99.9%
Taylor expanded in z around 0 96.7%
+-commutative96.7%
Simplified96.7%
Final simplification80.1%
(FPCore (x y z) :precision binary64 (if (<= y 2e-63) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-63) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.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) :: tmp
if (y <= 2d-63) then
tmp = x * (z + 1.0d0)
else
tmp = y * (z + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e-63) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e-63: tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e-63) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(y * Float64(z + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e-63) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e-63], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-63}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < 2.00000000000000013e-63Initial program 100.0%
Taylor expanded in x around inf 61.5%
if 2.00000000000000013e-63 < y Initial program 100.0%
Taylor expanded in x around 0 73.6%
Final simplification65.5%
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
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) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
def code(x, y, z): return (x + y) * (z + 1.0)
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function tmp = code(x, y, z) tmp = (x + y) * (z + 1.0); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= y 2e-50) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-50) {
tmp = x;
} else {
tmp = 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 (y <= 2d-50) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e-50) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e-50: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e-50) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e-50) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e-50], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 2.00000000000000002e-50Initial program 100.0%
Taylor expanded in x around inf 61.5%
Taylor expanded in z around 0 36.6%
if 2.00000000000000002e-50 < y Initial program 100.0%
Taylor expanded in x around 0 76.2%
+-commutative76.2%
distribute-lft-in76.2%
*-rgt-identity76.2%
Applied egg-rr76.2%
Taylor expanded in z around 0 33.3%
Final simplification35.6%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 52.0%
Taylor expanded in z around 0 31.3%
Final simplification31.3%
herbie shell --seed 2024034
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))