
(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.65e+244)
(* x z)
(if (<= z -2.05e+164)
(* y z)
(if (<= z -8.5e+91)
(* x z)
(if (<= z -1.0)
(* y z)
(if (<= z -5.2e-211)
x
(if (<= z -6.8e-307)
y
(if (<= z 950000.0) x (if (<= z 1.1e+200) (* x z) (* y z))))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.65e+244) {
tmp = x * z;
} else if (z <= -2.05e+164) {
tmp = y * z;
} else if (z <= -8.5e+91) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= -5.2e-211) {
tmp = x;
} else if (z <= -6.8e-307) {
tmp = y;
} else if (z <= 950000.0) {
tmp = x;
} else if (z <= 1.1e+200) {
tmp = x * z;
} 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.65d+244)) then
tmp = x * z
else if (z <= (-2.05d+164)) then
tmp = y * z
else if (z <= (-8.5d+91)) then
tmp = x * z
else if (z <= (-1.0d0)) then
tmp = y * z
else if (z <= (-5.2d-211)) then
tmp = x
else if (z <= (-6.8d-307)) then
tmp = y
else if (z <= 950000.0d0) then
tmp = x
else if (z <= 1.1d+200) then
tmp = x * z
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.65e+244) {
tmp = x * z;
} else if (z <= -2.05e+164) {
tmp = y * z;
} else if (z <= -8.5e+91) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= -5.2e-211) {
tmp = x;
} else if (z <= -6.8e-307) {
tmp = y;
} else if (z <= 950000.0) {
tmp = x;
} else if (z <= 1.1e+200) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.65e+244: tmp = x * z elif z <= -2.05e+164: tmp = y * z elif z <= -8.5e+91: tmp = x * z elif z <= -1.0: tmp = y * z elif z <= -5.2e-211: tmp = x elif z <= -6.8e-307: tmp = y elif z <= 950000.0: tmp = x elif z <= 1.1e+200: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.65e+244) tmp = Float64(x * z); elseif (z <= -2.05e+164) tmp = Float64(y * z); elseif (z <= -8.5e+91) tmp = Float64(x * z); elseif (z <= -1.0) tmp = Float64(y * z); elseif (z <= -5.2e-211) tmp = x; elseif (z <= -6.8e-307) tmp = y; elseif (z <= 950000.0) tmp = x; elseif (z <= 1.1e+200) tmp = Float64(x * z); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.65e+244) tmp = x * z; elseif (z <= -2.05e+164) tmp = y * z; elseif (z <= -8.5e+91) tmp = x * z; elseif (z <= -1.0) tmp = y * z; elseif (z <= -5.2e-211) tmp = x; elseif (z <= -6.8e-307) tmp = y; elseif (z <= 950000.0) tmp = x; elseif (z <= 1.1e+200) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.65e+244], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.05e+164], N[(y * z), $MachinePrecision], If[LessEqual[z, -8.5e+91], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, -5.2e-211], x, If[LessEqual[z, -6.8e-307], y, If[LessEqual[z, 950000.0], x, If[LessEqual[z, 1.1e+200], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+244}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -2.05 \cdot 10^{+164}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{+91}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{-211}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -6.8 \cdot 10^{-307}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 950000:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+200}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -1.6499999999999999e244 or -2.05000000000000008e164 < z < -8.4999999999999995e91 or 9.5e5 < z < 1.1e200Initial program 100.0%
Taylor expanded in x around inf 54.4%
+-commutative54.4%
distribute-lft-in54.4%
*-rgt-identity54.4%
Applied egg-rr54.4%
Taylor expanded in z around inf 53.8%
if -1.6499999999999999e244 < z < -2.05000000000000008e164 or -8.4999999999999995e91 < z < -1 or 1.1e200 < z Initial program 100.0%
Taylor expanded in x around 0 53.5%
+-commutative53.5%
distribute-lft-in53.5%
*-rgt-identity53.5%
Applied egg-rr53.5%
Taylor expanded in z around inf 53.5%
*-commutative53.5%
Simplified53.5%
if -1 < z < -5.2e-211 or -6.79999999999999978e-307 < z < 9.5e5Initial program 100.0%
Taylor expanded in x around inf 50.4%
Taylor expanded in z around 0 48.0%
if -5.2e-211 < z < -6.79999999999999978e-307Initial program 100.0%
Taylor expanded in x around 0 54.4%
Taylor expanded in z around 0 54.4%
Final simplification51.6%
(FPCore (x y z)
:precision binary64
(if (<= z -7.8e+245)
(* x z)
(if (<= z -8e+166)
(* y z)
(if (<= z -8.6e+95)
(* x z)
(if (<= z -1.0)
(* y z)
(if (<= z 3e-8)
(+ x y)
(if (<= z 2.3e+201) (* x (+ z 1.0)) (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e+245) {
tmp = x * z;
} else if (z <= -8e+166) {
tmp = y * z;
} else if (z <= -8.6e+95) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 3e-8) {
tmp = x + y;
} else if (z <= 2.3e+201) {
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 <= (-7.8d+245)) then
tmp = x * z
else if (z <= (-8d+166)) then
tmp = y * z
else if (z <= (-8.6d+95)) then
tmp = x * z
else if (z <= (-1.0d0)) then
tmp = y * z
else if (z <= 3d-8) then
tmp = x + y
else if (z <= 2.3d+201) 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 <= -7.8e+245) {
tmp = x * z;
} else if (z <= -8e+166) {
tmp = y * z;
} else if (z <= -8.6e+95) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 3e-8) {
tmp = x + y;
} else if (z <= 2.3e+201) {
tmp = x * (z + 1.0);
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e+245: tmp = x * z elif z <= -8e+166: tmp = y * z elif z <= -8.6e+95: tmp = x * z elif z <= -1.0: tmp = y * z elif z <= 3e-8: tmp = x + y elif z <= 2.3e+201: tmp = x * (z + 1.0) else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e+245) tmp = Float64(x * z); elseif (z <= -8e+166) tmp = Float64(y * z); elseif (z <= -8.6e+95) tmp = Float64(x * z); elseif (z <= -1.0) tmp = Float64(y * z); elseif (z <= 3e-8) tmp = Float64(x + y); elseif (z <= 2.3e+201) 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 <= -7.8e+245) tmp = x * z; elseif (z <= -8e+166) tmp = y * z; elseif (z <= -8.6e+95) tmp = x * z; elseif (z <= -1.0) tmp = y * z; elseif (z <= 3e-8) tmp = x + y; elseif (z <= 2.3e+201) tmp = x * (z + 1.0); else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e+245], N[(x * z), $MachinePrecision], If[LessEqual[z, -8e+166], N[(y * z), $MachinePrecision], If[LessEqual[z, -8.6e+95], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 3e-8], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.3e+201], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+245}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -8 \cdot 10^{+166}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -8.6 \cdot 10^{+95}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-8}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+201}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -7.7999999999999996e245 or -7.99999999999999952e166 < z < -8.6e95Initial program 100.0%
Taylor expanded in x around inf 44.9%
+-commutative44.9%
distribute-lft-in44.9%
*-rgt-identity44.9%
Applied egg-rr44.9%
Taylor expanded in z around inf 44.9%
if -7.7999999999999996e245 < z < -7.99999999999999952e166 or -8.6e95 < z < -1 or 2.3000000000000001e201 < z Initial program 100.0%
Taylor expanded in x around 0 53.5%
+-commutative53.5%
distribute-lft-in53.5%
*-rgt-identity53.5%
Applied egg-rr53.5%
Taylor expanded in z around inf 53.5%
*-commutative53.5%
Simplified53.5%
if -1 < z < 2.99999999999999973e-8Initial program 100.0%
Taylor expanded in z around 0 99.5%
+-commutative99.5%
Simplified99.5%
if 2.99999999999999973e-8 < z < 2.3000000000000001e201Initial program 100.0%
Taylor expanded in x around inf 60.7%
Final simplification73.3%
(FPCore (x y z)
:precision binary64
(if (<= z -7.5e+246)
(* x z)
(if (<= z -2.6e+164)
(* y z)
(if (<= z -6.2e+95)
(* x z)
(if (<= z -1.0)
(* y z)
(if (<= z 78000000.0)
(+ x y)
(if (<= z 7.2e+202) (* x z) (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.5e+246) {
tmp = x * z;
} else if (z <= -2.6e+164) {
tmp = y * z;
} else if (z <= -6.2e+95) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 78000000.0) {
tmp = x + y;
} else if (z <= 7.2e+202) {
tmp = x * z;
} 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 <= (-7.5d+246)) then
tmp = x * z
else if (z <= (-2.6d+164)) then
tmp = y * z
else if (z <= (-6.2d+95)) then
tmp = x * z
else if (z <= (-1.0d0)) then
tmp = y * z
else if (z <= 78000000.0d0) then
tmp = x + y
else if (z <= 7.2d+202) then
tmp = x * z
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.5e+246) {
tmp = x * z;
} else if (z <= -2.6e+164) {
tmp = y * z;
} else if (z <= -6.2e+95) {
tmp = x * z;
} else if (z <= -1.0) {
tmp = y * z;
} else if (z <= 78000000.0) {
tmp = x + y;
} else if (z <= 7.2e+202) {
tmp = x * z;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.5e+246: tmp = x * z elif z <= -2.6e+164: tmp = y * z elif z <= -6.2e+95: tmp = x * z elif z <= -1.0: tmp = y * z elif z <= 78000000.0: tmp = x + y elif z <= 7.2e+202: tmp = x * z else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.5e+246) tmp = Float64(x * z); elseif (z <= -2.6e+164) tmp = Float64(y * z); elseif (z <= -6.2e+95) tmp = Float64(x * z); elseif (z <= -1.0) tmp = Float64(y * z); elseif (z <= 78000000.0) tmp = Float64(x + y); elseif (z <= 7.2e+202) tmp = Float64(x * z); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.5e+246) tmp = x * z; elseif (z <= -2.6e+164) tmp = y * z; elseif (z <= -6.2e+95) tmp = x * z; elseif (z <= -1.0) tmp = y * z; elseif (z <= 78000000.0) tmp = x + y; elseif (z <= 7.2e+202) tmp = x * z; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.5e+246], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.6e+164], N[(y * z), $MachinePrecision], If[LessEqual[z, -6.2e+95], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 78000000.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 7.2e+202], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+246}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -2.6 \cdot 10^{+164}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{+95}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 78000000:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+202}:\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -7.5e246 or -2.5999999999999999e164 < z < -6.2000000000000006e95 or 7.8e7 < z < 7.20000000000000016e202Initial program 100.0%
Taylor expanded in x around inf 53.8%
+-commutative53.8%
distribute-lft-in53.8%
*-rgt-identity53.8%
Applied egg-rr53.8%
Taylor expanded in z around inf 53.2%
if -7.5e246 < z < -2.5999999999999999e164 or -6.2000000000000006e95 < z < -1 or 7.20000000000000016e202 < z Initial program 100.0%
Taylor expanded in x around 0 53.5%
+-commutative53.5%
distribute-lft-in53.5%
*-rgt-identity53.5%
Applied egg-rr53.5%
Taylor expanded in z around inf 53.5%
*-commutative53.5%
Simplified53.5%
if -1 < z < 7.8e7Initial program 100.0%
Taylor expanded in z around 0 96.2%
+-commutative96.2%
Simplified96.2%
Final simplification72.1%
(FPCore (x y z)
:precision binary64
(if (<= z -1.5e+29)
(* x z)
(if (<= z -4.5e-211)
x
(if (<= z -5e-308) y (if (<= z 950000.0) x (* x z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+29) {
tmp = x * z;
} else if (z <= -4.5e-211) {
tmp = x;
} else if (z <= -5e-308) {
tmp = y;
} else if (z <= 950000.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.5d+29)) then
tmp = x * z
else if (z <= (-4.5d-211)) then
tmp = x
else if (z <= (-5d-308)) then
tmp = y
else if (z <= 950000.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.5e+29) {
tmp = x * z;
} else if (z <= -4.5e-211) {
tmp = x;
} else if (z <= -5e-308) {
tmp = y;
} else if (z <= 950000.0) {
tmp = x;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.5e+29: tmp = x * z elif z <= -4.5e-211: tmp = x elif z <= -5e-308: tmp = y elif z <= 950000.0: tmp = x else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.5e+29) tmp = Float64(x * z); elseif (z <= -4.5e-211) tmp = x; elseif (z <= -5e-308) tmp = y; elseif (z <= 950000.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.5e+29) tmp = x * z; elseif (z <= -4.5e-211) tmp = x; elseif (z <= -5e-308) tmp = y; elseif (z <= 950000.0) tmp = x; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.5e+29], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.5e-211], x, If[LessEqual[z, -5e-308], y, If[LessEqual[z, 950000.0], x, N[(x * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+29}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-211}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-308}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 950000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -1.5e29 or 9.5e5 < z Initial program 100.0%
Taylor expanded in x around inf 54.0%
+-commutative54.0%
distribute-lft-in54.0%
*-rgt-identity54.0%
Applied egg-rr54.0%
Taylor expanded in z around inf 53.7%
if -1.5e29 < z < -4.4999999999999999e-211 or -4.99999999999999955e-308 < z < 9.5e5Initial program 100.0%
Taylor expanded in x around inf 51.9%
Taylor expanded in z around 0 45.8%
if -4.4999999999999999e-211 < z < -4.99999999999999955e-308Initial program 100.0%
Taylor expanded in x around 0 54.4%
Taylor expanded in z around 0 54.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.3%
+-commutative98.3%
Simplified98.3%
if -1 < z < 1Initial program 100.0%
Taylor expanded in z around 0 98.5%
+-commutative98.5%
Simplified98.5%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= y 2.8e-51) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e-51) {
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 <= 2.8d-51) 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 <= 2.8e-51) {
tmp = x * (z + 1.0);
} else {
tmp = y * (z + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.8e-51: tmp = x * (z + 1.0) else: tmp = y * (z + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.8e-51) 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 <= 2.8e-51) tmp = x * (z + 1.0); else tmp = y * (z + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.8e-51], 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.8 \cdot 10^{-51}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\
\end{array}
\end{array}
if y < 2.8e-51Initial program 100.0%
Taylor expanded in x around inf 59.2%
if 2.8e-51 < y Initial program 100.0%
Taylor expanded in x around 0 78.5%
Final simplification64.0%
(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.5e-51) x y))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.5e-51) {
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.5d-51) 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.5e-51) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.5e-51: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.5e-51) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.5e-51) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.5e-51], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-51}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 4.49999999999999974e-51Initial program 100.0%
Taylor expanded in x around inf 59.2%
Taylor expanded in z around 0 25.6%
if 4.49999999999999974e-51 < y Initial program 100.0%
Taylor expanded in x around 0 78.5%
Taylor expanded in z around 0 30.9%
(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.7%
Taylor expanded in z around 0 22.6%
herbie shell --seed 2024085
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))