
(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.0)
(* y z)
(if (<= z -9e-140)
y
(if (<= z -1.35e-195)
x
(if (<= z 1.75e-172)
y
(if (<= z 2550.0)
x
(if (or (<= z 1e+226) (not (<= z 1.1e+272))) (* y z) (* x z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= -9e-140) {
tmp = y;
} else if (z <= -1.35e-195) {
tmp = x;
} else if (z <= 1.75e-172) {
tmp = y;
} else if (z <= 2550.0) {
tmp = x;
} else if ((z <= 1e+226) || !(z <= 1.1e+272)) {
tmp = 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 (z <= (-1.0d0)) then
tmp = y * z
else if (z <= (-9d-140)) then
tmp = y
else if (z <= (-1.35d-195)) then
tmp = x
else if (z <= 1.75d-172) then
tmp = y
else if (z <= 2550.0d0) then
tmp = x
else if ((z <= 1d+226) .or. (.not. (z <= 1.1d+272))) then
tmp = 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 (z <= -1.0) {
tmp = y * z;
} else if (z <= -9e-140) {
tmp = y;
} else if (z <= -1.35e-195) {
tmp = x;
} else if (z <= 1.75e-172) {
tmp = y;
} else if (z <= 2550.0) {
tmp = x;
} else if ((z <= 1e+226) || !(z <= 1.1e+272)) {
tmp = y * z;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = y * z elif z <= -9e-140: tmp = y elif z <= -1.35e-195: tmp = x elif z <= 1.75e-172: tmp = y elif z <= 2550.0: tmp = x elif (z <= 1e+226) or not (z <= 1.1e+272): tmp = y * z else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(y * z); elseif (z <= -9e-140) tmp = y; elseif (z <= -1.35e-195) tmp = x; elseif (z <= 1.75e-172) tmp = y; elseif (z <= 2550.0) tmp = x; elseif ((z <= 1e+226) || !(z <= 1.1e+272)) tmp = Float64(y * z); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = y * z; elseif (z <= -9e-140) tmp = y; elseif (z <= -1.35e-195) tmp = x; elseif (z <= 1.75e-172) tmp = y; elseif (z <= 2550.0) tmp = x; elseif ((z <= 1e+226) || ~((z <= 1.1e+272))) tmp = y * z; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, -9e-140], y, If[LessEqual[z, -1.35e-195], x, If[LessEqual[z, 1.75e-172], y, If[LessEqual[z, 2550.0], x, If[Or[LessEqual[z, 1e+226], N[Not[LessEqual[z, 1.1e+272]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -9 \cdot 10^{-140}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{-195}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{-172}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 2550:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 10^{+226} \lor \neg \left(z \leq 1.1 \cdot 10^{+272}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1 or 2550 < z < 9.99999999999999961e225 or 1.10000000000000004e272 < z Initial program 100.0%
Taylor expanded in x around 0 48.9%
+-commutative48.9%
distribute-lft-in48.9%
*-rgt-identity48.9%
Applied egg-rr48.9%
Taylor expanded in z around inf 48.0%
*-commutative48.0%
Simplified48.0%
if -1 < z < -9.00000000000000008e-140 or -1.35e-195 < z < 1.75000000000000014e-172Initial program 100.0%
Taylor expanded in x around 0 54.7%
Taylor expanded in z around 0 53.3%
if -9.00000000000000008e-140 < z < -1.35e-195 or 1.75000000000000014e-172 < z < 2550Initial program 99.9%
Taylor expanded in x around inf 55.5%
Taylor expanded in z around 0 50.2%
if 9.99999999999999961e225 < z < 1.10000000000000004e272Initial program 100.0%
Taylor expanded in x around inf 13.0%
+-commutative13.0%
distribute-lft-in13.0%
*-rgt-identity13.0%
Applied egg-rr13.0%
Taylor expanded in z around inf 13.0%
Final simplification49.3%
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(* x z)
(if (<= z -7.6e-140)
y
(if (<= z -1.06e-196)
x
(if (<= z 4.7e-173) y (if (<= z 1.0) x (* x z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = x * z;
} else if (z <= -7.6e-140) {
tmp = y;
} else if (z <= -1.06e-196) {
tmp = x;
} else if (z <= 4.7e-173) {
tmp = y;
} else if (z <= 1.0) {
tmp = x;
} 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 <= (-7.6d-140)) then
tmp = y
else if (z <= (-1.06d-196)) then
tmp = x
else if (z <= 4.7d-173) then
tmp = y
else if (z <= 1.0d0) then
tmp = x
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 <= -7.6e-140) {
tmp = y;
} else if (z <= -1.06e-196) {
tmp = x;
} else if (z <= 4.7e-173) {
tmp = y;
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = x * z elif z <= -7.6e-140: tmp = y elif z <= -1.06e-196: tmp = x elif z <= 4.7e-173: tmp = y elif z <= 1.0: tmp = x else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(x * z); elseif (z <= -7.6e-140) tmp = y; elseif (z <= -1.06e-196) tmp = x; elseif (z <= 4.7e-173) tmp = y; elseif (z <= 1.0) tmp = x; 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 <= -7.6e-140) tmp = y; elseif (z <= -1.06e-196) tmp = x; elseif (z <= 4.7e-173) tmp = y; elseif (z <= 1.0) tmp = x; 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, -7.6e-140], y, If[LessEqual[z, -1.06e-196], x, If[LessEqual[z, 4.7e-173], y, If[LessEqual[z, 1.0], x, N[(x * z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -7.6 \cdot 10^{-140}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq -1.06 \cdot 10^{-196}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.7 \cdot 10^{-173}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 100.0%
Taylor expanded in x around inf 52.4%
+-commutative52.4%
distribute-lft-in52.4%
*-rgt-identity52.4%
Applied egg-rr52.4%
Taylor expanded in z around inf 51.3%
if -1 < z < -7.59999999999999997e-140 or -1.05999999999999994e-196 < z < 4.7e-173Initial program 100.0%
Taylor expanded in x around 0 54.7%
Taylor expanded in z around 0 53.3%
if -7.59999999999999997e-140 < z < -1.05999999999999994e-196 or 4.7e-173 < z < 1Initial program 99.9%
Taylor expanded in x around inf 54.5%
Taylor expanded in z around 0 51.0%
Final simplification51.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(* y z)
(if (<= z 2550.0)
(+ x y)
(if (or (<= z 5.5e+223) (not (<= z 1.2e+274))) (* y z) (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = y * z;
} else if (z <= 2550.0) {
tmp = x + y;
} else if ((z <= 5.5e+223) || !(z <= 1.2e+274)) {
tmp = 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 (z <= (-1.0d0)) then
tmp = y * z
else if (z <= 2550.0d0) then
tmp = x + y
else if ((z <= 5.5d+223) .or. (.not. (z <= 1.2d+274))) then
tmp = 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 (z <= -1.0) {
tmp = y * z;
} else if (z <= 2550.0) {
tmp = x + y;
} else if ((z <= 5.5e+223) || !(z <= 1.2e+274)) {
tmp = y * z;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = y * z elif z <= 2550.0: tmp = x + y elif (z <= 5.5e+223) or not (z <= 1.2e+274): tmp = y * z else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(y * z); elseif (z <= 2550.0) tmp = Float64(x + y); elseif ((z <= 5.5e+223) || !(z <= 1.2e+274)) tmp = Float64(y * z); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = y * z; elseif (z <= 2550.0) tmp = x + y; elseif ((z <= 5.5e+223) || ~((z <= 1.2e+274))) tmp = y * z; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 2550.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, 5.5e+223], N[Not[LessEqual[z, 1.2e+274]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 2550:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+223} \lor \neg \left(z \leq 1.2 \cdot 10^{+274}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1 or 2550 < z < 5.4999999999999999e223 or 1.2e274 < z Initial program 100.0%
Taylor expanded in x around 0 48.9%
+-commutative48.9%
distribute-lft-in48.9%
*-rgt-identity48.9%
Applied egg-rr48.9%
Taylor expanded in z around inf 48.0%
*-commutative48.0%
Simplified48.0%
if -1 < z < 2550Initial program 100.0%
Taylor expanded in z around 0 96.9%
+-commutative96.9%
Simplified96.9%
if 5.4999999999999999e223 < z < 1.2e274Initial program 100.0%
Taylor expanded in x around inf 13.0%
+-commutative13.0%
distribute-lft-in13.0%
*-rgt-identity13.0%
Applied egg-rr13.0%
Taylor expanded in z around inf 13.0%
Final simplification71.2%
(FPCore (x y z) :precision binary64 (if (<= y 7.5e-204) (* x (+ z 1.0)) (if (or (<= y 7.1e+75) (not (<= y 2.65e+126))) (* y (+ z 1.0)) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e-204) {
tmp = x * (z + 1.0);
} else if ((y <= 7.1e+75) || !(y <= 2.65e+126)) {
tmp = y * (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 (y <= 7.5d-204) then
tmp = x * (z + 1.0d0)
else if ((y <= 7.1d+75) .or. (.not. (y <= 2.65d+126))) then
tmp = y * (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 (y <= 7.5e-204) {
tmp = x * (z + 1.0);
} else if ((y <= 7.1e+75) || !(y <= 2.65e+126)) {
tmp = y * (z + 1.0);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.5e-204: tmp = x * (z + 1.0) elif (y <= 7.1e+75) or not (y <= 2.65e+126): tmp = y * (z + 1.0) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.5e-204) tmp = Float64(x * Float64(z + 1.0)); elseif ((y <= 7.1e+75) || !(y <= 2.65e+126)) tmp = Float64(y * Float64(z + 1.0)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7.5e-204) tmp = x * (z + 1.0); elseif ((y <= 7.1e+75) || ~((y <= 2.65e+126))) tmp = y * (z + 1.0); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.5e-204], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 7.1e+75], N[Not[LessEqual[y, 2.65e+126]], $MachinePrecision]], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{-204}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{elif}\;y \leq 7.1 \cdot 10^{+75} \lor \neg \left(y \leq 2.65 \cdot 10^{+126}\right):\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < 7.5000000000000003e-204Initial program 100.0%
Taylor expanded in x around inf 58.8%
if 7.5000000000000003e-204 < y < 7.09999999999999982e75 or 2.65000000000000014e126 < y Initial program 100.0%
Taylor expanded in x around 0 64.0%
if 7.09999999999999982e75 < y < 2.65000000000000014e126Initial program 100.0%
Taylor expanded in z around 0 83.4%
+-commutative83.4%
Simplified83.4%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.3e+27) (* y z) (if (<= z -4.8e-12) (* x (+ z 1.0)) (if (<= z 2700.0) (+ x y) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.3e+27) {
tmp = y * z;
} else if (z <= -4.8e-12) {
tmp = x * (z + 1.0);
} else if (z <= 2700.0) {
tmp = x + 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.3d+27)) then
tmp = y * z
else if (z <= (-4.8d-12)) then
tmp = x * (z + 1.0d0)
else if (z <= 2700.0d0) then
tmp = x + 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.3e+27) {
tmp = y * z;
} else if (z <= -4.8e-12) {
tmp = x * (z + 1.0);
} else if (z <= 2700.0) {
tmp = x + y;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.3e+27: tmp = y * z elif z <= -4.8e-12: tmp = x * (z + 1.0) elif z <= 2700.0: tmp = x + y else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.3e+27) tmp = Float64(y * z); elseif (z <= -4.8e-12) tmp = Float64(x * Float64(z + 1.0)); elseif (z <= 2700.0) tmp = Float64(x + y); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.3e+27) tmp = y * z; elseif (z <= -4.8e-12) tmp = x * (z + 1.0); elseif (z <= 2700.0) tmp = x + y; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.3e+27], N[(y * z), $MachinePrecision], If[LessEqual[z, -4.8e-12], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2700.0], N[(x + y), $MachinePrecision], N[(y * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+27}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{-12}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{elif}\;z \leq 2700:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -1.30000000000000004e27 or 2700 < z Initial program 100.0%
Taylor expanded in x around 0 49.7%
+-commutative49.7%
distribute-lft-in49.7%
*-rgt-identity49.7%
Applied egg-rr49.7%
Taylor expanded in z around inf 49.2%
*-commutative49.2%
Simplified49.2%
if -1.30000000000000004e27 < z < -4.79999999999999974e-12Initial program 100.0%
Taylor expanded in x around inf 39.8%
if -4.79999999999999974e-12 < z < 2700Initial program 100.0%
Taylor expanded in z around 0 97.9%
+-commutative97.9%
Simplified97.9%
Final simplification72.1%
(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 100.0%
Taylor expanded in z around 0 97.6%
+-commutative97.6%
Simplified97.6%
Final simplification97.8%
(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 (<= x -1.04e-57) x y))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.04e-57) {
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 (x <= (-1.04d-57)) 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 (x <= -1.04e-57) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.04e-57: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.04e-57) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.04e-57) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.04e-57], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{-57}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -1.04000000000000003e-57Initial program 100.0%
Taylor expanded in x around inf 71.9%
Taylor expanded in z around 0 37.9%
if -1.04000000000000003e-57 < x Initial program 100.0%
Taylor expanded in x around 0 57.6%
Taylor expanded in z around 0 29.3%
Final simplification31.8%
(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 51.2%
Taylor expanded in z around 0 25.0%
Final simplification25.0%
herbie shell --seed 2024036
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))