
(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(Float64(x + 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[(N[(x + y), $MachinePrecision] + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) + z \cdot \left(x + y\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -1.75e+215)
(* y z)
(if (<= z -2.9e+194)
(* x z)
(if (<= z -1.35e+82)
(* y z)
(if (<= z -1.0)
(* x z)
(if (<= z -4.4e-158)
y
(if (<= z -8.2e-304) x (if (<= z 2.9) y (* x z)))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.75e+215) {
tmp = y * z;
} else if (z <= -2.9e+194) {
tmp = x * z;
} else if (z <= -1.35e+82) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= -4.4e-158) {
tmp = y;
} else if (z <= -8.2e-304) {
tmp = x;
} else if (z <= 2.9) {
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 <= (-1.75d+215)) then
tmp = y * z
else if (z <= (-2.9d+194)) then
tmp = x * z
else if (z <= (-1.35d+82)) then
tmp = y * z
else if (z <= (-1.0d0)) then
tmp = x * z
else if (z <= (-4.4d-158)) then
tmp = y
else if (z <= (-8.2d-304)) then
tmp = x
else if (z <= 2.9d0) 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 <= -1.75e+215) {
tmp = y * z;
} else if (z <= -2.9e+194) {
tmp = x * z;
} else if (z <= -1.35e+82) {
tmp = y * z;
} else if (z <= -1.0) {
tmp = x * z;
} else if (z <= -4.4e-158) {
tmp = y;
} else if (z <= -8.2e-304) {
tmp = x;
} else if (z <= 2.9) {
tmp = y;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.75e+215: tmp = y * z elif z <= -2.9e+194: tmp = x * z elif z <= -1.35e+82: tmp = y * z elif z <= -1.0: tmp = x * z elif z <= -4.4e-158: tmp = y elif z <= -8.2e-304: tmp = x elif z <= 2.9: tmp = y else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.75e+215) tmp = Float64(y * z); elseif (z <= -2.9e+194) tmp = Float64(x * z); elseif (z <= -1.35e+82) tmp = Float64(y * z); elseif (z <= -1.0) tmp = Float64(x * z); elseif (z <= -4.4e-158) tmp = y; elseif (z <= -8.2e-304) tmp = x; elseif (z <= 2.9) tmp = y; else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.75e+215) tmp = y * z; elseif (z <= -2.9e+194) tmp = x * z; elseif (z <= -1.35e+82) tmp = y * z; elseif (z <= -1.0) tmp = x * z; elseif (z <= -4.4e-158) tmp = y; elseif (z <= -8.2e-304) tmp = x; elseif (z <= 2.9) tmp = y; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.75e+215], N[(y * z), $MachinePrecision], If[LessEqual[z, -2.9e+194], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.35e+82], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.4e-158], y, If[LessEqual[z, -8.2e-304], x, If[LessEqual[z, 2.9], y, N[(x * z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+215}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{+194}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{+82}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -4.4 \cdot 10^{-158}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -8.2 \cdot 10^{-304}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.9:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1.74999999999999988e215 or -2.9000000000000001e194 < z < -1.35e82Initial program 99.9%
Taylor expanded in z around inf 99.9%
+-commutative99.9%
Simplified99.9%
distribute-lft-in94.8%
*-commutative94.8%
Applied egg-rr94.8%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if -1.74999999999999988e215 < z < -2.9000000000000001e194 or -1.35e82 < z < -1 or 2.89999999999999991 < z Initial program 99.9%
Taylor expanded in z around inf 97.1%
+-commutative97.1%
Simplified97.1%
distribute-lft-in90.8%
*-commutative90.8%
Applied egg-rr90.8%
Taylor expanded in y around 0 47.3%
*-commutative47.3%
Simplified47.3%
if -1 < z < -4.4000000000000002e-158 or -8.20000000000000005e-304 < z < 2.89999999999999991Initial program 100.0%
Taylor expanded in x around 0 46.1%
Taylor expanded in z around 0 44.9%
if -4.4000000000000002e-158 < z < -8.20000000000000005e-304Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 45.4%
Taylor expanded in z around 0 45.4%
Final simplification49.8%
(FPCore (x y z)
:precision binary64
(if (<= z -3.1e+215)
(* y z)
(if (<= z -7.8e+194)
(* x z)
(if (<= z -1.55e+82)
(* y z)
(if (or (<= z -2.2e-5) (not (<= z 0.001))) (* x (+ z 1.0)) (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e+215) {
tmp = y * z;
} else if (z <= -7.8e+194) {
tmp = x * z;
} else if (z <= -1.55e+82) {
tmp = y * z;
} else if ((z <= -2.2e-5) || !(z <= 0.001)) {
tmp = x * (z + 1.0);
} 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 <= (-3.1d+215)) then
tmp = y * z
else if (z <= (-7.8d+194)) then
tmp = x * z
else if (z <= (-1.55d+82)) then
tmp = y * z
else if ((z <= (-2.2d-5)) .or. (.not. (z <= 0.001d0))) then
tmp = x * (z + 1.0d0)
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e+215) {
tmp = y * z;
} else if (z <= -7.8e+194) {
tmp = x * z;
} else if (z <= -1.55e+82) {
tmp = y * z;
} else if ((z <= -2.2e-5) || !(z <= 0.001)) {
tmp = x * (z + 1.0);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.1e+215: tmp = y * z elif z <= -7.8e+194: tmp = x * z elif z <= -1.55e+82: tmp = y * z elif (z <= -2.2e-5) or not (z <= 0.001): tmp = x * (z + 1.0) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.1e+215) tmp = Float64(y * z); elseif (z <= -7.8e+194) tmp = Float64(x * z); elseif (z <= -1.55e+82) tmp = Float64(y * z); elseif ((z <= -2.2e-5) || !(z <= 0.001)) tmp = Float64(x * Float64(z + 1.0)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.1e+215) tmp = y * z; elseif (z <= -7.8e+194) tmp = x * z; elseif (z <= -1.55e+82) tmp = y * z; elseif ((z <= -2.2e-5) || ~((z <= 0.001))) tmp = x * (z + 1.0); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.1e+215], N[(y * z), $MachinePrecision], If[LessEqual[z, -7.8e+194], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.55e+82], N[(y * z), $MachinePrecision], If[Or[LessEqual[z, -2.2e-5], N[Not[LessEqual[z, 0.001]], $MachinePrecision]], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+215}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -7.8 \cdot 10^{+194}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{+82}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -2.2 \cdot 10^{-5} \lor \neg \left(z \leq 0.001\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -3.0999999999999999e215 or -7.80000000000000031e194 < z < -1.55000000000000016e82Initial program 99.9%
Taylor expanded in z around inf 99.9%
+-commutative99.9%
Simplified99.9%
distribute-lft-in94.8%
*-commutative94.8%
Applied egg-rr94.8%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if -3.0999999999999999e215 < z < -7.80000000000000031e194Initial program 100.0%
Taylor expanded in z around inf 100.0%
+-commutative100.0%
Simplified100.0%
distribute-lft-in100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 63.6%
*-commutative63.6%
Simplified63.6%
if -1.55000000000000016e82 < z < -2.1999999999999999e-5 or 1e-3 < z Initial program 99.9%
Taylor expanded in x around inf 46.8%
if -2.1999999999999999e-5 < z < 1e-3Initial program 100.0%
Taylor expanded in z around 0 98.9%
+-commutative98.9%
Simplified98.9%
Final simplification74.6%
(FPCore (x y z)
:precision binary64
(if (<= z -4e+216)
(* y z)
(if (<= z -1.36e+193)
(* x z)
(if (<= z -1.5e+83)
(* y z)
(if (or (<= z -1.0) (not (<= z 5.0))) (* x z) (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4e+216) {
tmp = y * z;
} else if (z <= -1.36e+193) {
tmp = x * z;
} else if (z <= -1.5e+83) {
tmp = y * z;
} else if ((z <= -1.0) || !(z <= 5.0)) {
tmp = x * 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 <= (-4d+216)) then
tmp = y * z
else if (z <= (-1.36d+193)) then
tmp = x * z
else if (z <= (-1.5d+83)) then
tmp = y * z
else if ((z <= (-1.0d0)) .or. (.not. (z <= 5.0d0))) then
tmp = x * 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 <= -4e+216) {
tmp = y * z;
} else if (z <= -1.36e+193) {
tmp = x * z;
} else if (z <= -1.5e+83) {
tmp = y * z;
} else if ((z <= -1.0) || !(z <= 5.0)) {
tmp = x * z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4e+216: tmp = y * z elif z <= -1.36e+193: tmp = x * z elif z <= -1.5e+83: tmp = y * z elif (z <= -1.0) or not (z <= 5.0): tmp = x * z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4e+216) tmp = Float64(y * z); elseif (z <= -1.36e+193) tmp = Float64(x * z); elseif (z <= -1.5e+83) tmp = Float64(y * z); elseif ((z <= -1.0) || !(z <= 5.0)) tmp = Float64(x * z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4e+216) tmp = y * z; elseif (z <= -1.36e+193) tmp = x * z; elseif (z <= -1.5e+83) tmp = y * z; elseif ((z <= -1.0) || ~((z <= 5.0))) tmp = x * z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4e+216], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.36e+193], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.5e+83], N[(y * z), $MachinePrecision], If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 5.0]], $MachinePrecision]], N[(x * z), $MachinePrecision], N[(x + y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+216}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1.36 \cdot 10^{+193}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1.5 \cdot 10^{+83}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -1 \lor \neg \left(z \leq 5\right):\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -4.0000000000000001e216 or -1.35999999999999998e193 < z < -1.5e83Initial program 99.9%
Taylor expanded in z around inf 99.9%
+-commutative99.9%
Simplified99.9%
distribute-lft-in94.8%
*-commutative94.8%
Applied egg-rr94.8%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if -4.0000000000000001e216 < z < -1.35999999999999998e193 or -1.5e83 < z < -1 or 5 < z Initial program 99.9%
Taylor expanded in z around inf 97.1%
+-commutative97.1%
Simplified97.1%
distribute-lft-in90.8%
*-commutative90.8%
Applied egg-rr90.8%
Taylor expanded in y around 0 47.3%
*-commutative47.3%
Simplified47.3%
if -1 < z < 5Initial program 100.0%
Taylor expanded in z around 0 97.6%
+-commutative97.6%
Simplified97.6%
Final simplification74.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (* x z) (if (<= z -4e-158) y (if (<= z -1.4e-302) x (if (<= z 4.0) y (* x z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = x * z;
} else if (z <= -4e-158) {
tmp = y;
} else if (z <= -1.4e-302) {
tmp = x;
} else if (z <= 4.0) {
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 <= (-1.0d0)) then
tmp = x * z
else if (z <= (-4d-158)) then
tmp = y
else if (z <= (-1.4d-302)) then
tmp = x
else if (z <= 4.0d0) 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 <= -1.0) {
tmp = x * z;
} else if (z <= -4e-158) {
tmp = y;
} else if (z <= -1.4e-302) {
tmp = x;
} else if (z <= 4.0) {
tmp = y;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = x * z elif z <= -4e-158: tmp = y elif z <= -1.4e-302: tmp = x elif z <= 4.0: tmp = y else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(x * z); elseif (z <= -4e-158) tmp = y; elseif (z <= -1.4e-302) tmp = x; elseif (z <= 4.0) tmp = y; else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = x * z; elseif (z <= -4e-158) tmp = y; elseif (z <= -1.4e-302) tmp = x; elseif (z <= 4.0) tmp = y; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -4e-158], y, If[LessEqual[z, -1.4e-302], x, If[LessEqual[z, 4.0], y, N[(x * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-158}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-302}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1 or 4 < z Initial program 99.9%
Taylor expanded in z around inf 98.3%
+-commutative98.3%
Simplified98.3%
distribute-lft-in92.5%
*-commutative92.5%
Applied egg-rr92.5%
Taylor expanded in y around 0 43.8%
*-commutative43.8%
Simplified43.8%
if -1 < z < -4.00000000000000026e-158 or -1.4e-302 < z < 4Initial program 100.0%
Taylor expanded in x around 0 46.1%
Taylor expanded in z around 0 44.9%
if -4.00000000000000026e-158 < z < -1.4e-302Initial program 100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 45.4%
Taylor expanded in z around 0 45.4%
Final simplification44.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 99.9%
Taylor expanded in z around inf 98.3%
+-commutative98.3%
Simplified98.3%
if -1 < z < 1Initial program 100.0%
Taylor expanded in z around 0 97.6%
+-commutative97.6%
Simplified97.6%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.25e-126) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.25e-126) {
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 <= 1.25d-126) 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 <= 1.25e-126) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.25e-126: tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.25e-126) 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 <= 1.25e-126) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.25e-126], 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 1.25 \cdot 10^{-126}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < 1.25000000000000001e-126Initial program 100.0%
Taylor expanded in x around inf 56.8%
if 1.25000000000000001e-126 < y Initial program 100.0%
Taylor expanded in x around 0 67.7%
Final simplification60.7%
(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%
(FPCore (x y z) :precision binary64 (if (<= y 4.2e-124) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.2e-124) {
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 <= 4.2d-124) 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 <= 4.2e-124) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.2e-124: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.2e-124) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.2e-124) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.2e-124], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 4.2000000000000002e-124Initial program 100.0%
+-commutative100.0%
distribute-lft-in99.9%
*-rgt-identity99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 56.4%
Taylor expanded in z around 0 30.4%
if 4.2000000000000002e-124 < y Initial program 100.0%
Taylor expanded in x around 0 67.4%
Taylor expanded in z around 0 32.2%
(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%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 48.3%
Taylor expanded in z around 0 25.1%
herbie shell --seed 2024087
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))