
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (+ z (fma x 3.0 (* y 2.0))))
double code(double x, double y, double z) {
return z + fma(x, 3.0, (y * 2.0));
}
function code(x, y, z) return Float64(z + fma(x, 3.0, Float64(y * 2.0))) end
code[x_, y_, z_] := N[(z + N[(x * 3.0 + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \mathsf{fma}\left(x, 3, y \cdot 2\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -2.3e+145)
(+ z x)
(if (<= z 1.22e-129)
(+ x (* y 2.0))
(if (<= z 9.2e+108) (* x 3.0) (+ z x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+145) {
tmp = z + x;
} else if (z <= 1.22e-129) {
tmp = x + (y * 2.0);
} else if (z <= 9.2e+108) {
tmp = x * 3.0;
} else {
tmp = z + x;
}
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 <= (-2.3d+145)) then
tmp = z + x
else if (z <= 1.22d-129) then
tmp = x + (y * 2.0d0)
else if (z <= 9.2d+108) then
tmp = x * 3.0d0
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+145) {
tmp = z + x;
} else if (z <= 1.22e-129) {
tmp = x + (y * 2.0);
} else if (z <= 9.2e+108) {
tmp = x * 3.0;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.3e+145: tmp = z + x elif z <= 1.22e-129: tmp = x + (y * 2.0) elif z <= 9.2e+108: tmp = x * 3.0 else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.3e+145) tmp = Float64(z + x); elseif (z <= 1.22e-129) tmp = Float64(x + Float64(y * 2.0)); elseif (z <= 9.2e+108) tmp = Float64(x * 3.0); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.3e+145) tmp = z + x; elseif (z <= 1.22e-129) tmp = x + (y * 2.0); elseif (z <= 9.2e+108) tmp = x * 3.0; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.3e+145], N[(z + x), $MachinePrecision], If[LessEqual[z, 1.22e-129], N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.2e+108], N[(x * 3.0), $MachinePrecision], N[(z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+145}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 1.22 \cdot 10^{-129}:\\
\;\;\;\;x + y \cdot 2\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+108}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -2.3e145 or 9.1999999999999996e108 < z Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 89.8%
Taylor expanded in y around 0 77.3%
if -2.3e145 < z < 1.21999999999999999e-129Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 68.6%
Taylor expanded in z around 0 60.8%
if 1.21999999999999999e-129 < z < 9.1999999999999996e108Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 85.7%
Taylor expanded in x around inf 60.4%
Final simplification65.9%
(FPCore (x y z) :precision binary64 (if (<= z -7.8e+108) (+ z x) (if (<= z 3.1e-126) (* y 2.0) (if (<= z 1.3e+109) (* x 3.0) (+ z x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e+108) {
tmp = z + x;
} else if (z <= 3.1e-126) {
tmp = y * 2.0;
} else if (z <= 1.3e+109) {
tmp = x * 3.0;
} else {
tmp = z + x;
}
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+108)) then
tmp = z + x
else if (z <= 3.1d-126) then
tmp = y * 2.0d0
else if (z <= 1.3d+109) then
tmp = x * 3.0d0
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e+108) {
tmp = z + x;
} else if (z <= 3.1e-126) {
tmp = y * 2.0;
} else if (z <= 1.3e+109) {
tmp = x * 3.0;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e+108: tmp = z + x elif z <= 3.1e-126: tmp = y * 2.0 elif z <= 1.3e+109: tmp = x * 3.0 else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e+108) tmp = Float64(z + x); elseif (z <= 3.1e-126) tmp = Float64(y * 2.0); elseif (z <= 1.3e+109) tmp = Float64(x * 3.0); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.8e+108) tmp = z + x; elseif (z <= 3.1e-126) tmp = y * 2.0; elseif (z <= 1.3e+109) tmp = x * 3.0; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e+108], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.1e-126], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 1.3e+109], N[(x * 3.0), $MachinePrecision], N[(z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+108}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{-126}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+109}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -7.79999999999999969e108 or 1.2999999999999999e109 < z Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 88.6%
Taylor expanded in y around 0 74.7%
if -7.79999999999999969e108 < z < 3.1000000000000001e-126Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 68.4%
Taylor expanded in z around 0 61.8%
Taylor expanded in x around 0 56.1%
*-commutative56.1%
Simplified56.1%
if 3.1000000000000001e-126 < z < 1.2999999999999999e109Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 85.7%
Taylor expanded in x around inf 60.4%
Final simplification63.2%
(FPCore (x y z) :precision binary64 (if (<= z -3.4e+115) z (if (<= z 2e-126) (* y 2.0) (if (<= z 8.8e+108) (* x 3.0) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e+115) {
tmp = z;
} else if (z <= 2e-126) {
tmp = y * 2.0;
} else if (z <= 8.8e+108) {
tmp = x * 3.0;
} else {
tmp = 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.4d+115)) then
tmp = z
else if (z <= 2d-126) then
tmp = y * 2.0d0
else if (z <= 8.8d+108) then
tmp = x * 3.0d0
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e+115) {
tmp = z;
} else if (z <= 2e-126) {
tmp = y * 2.0;
} else if (z <= 8.8e+108) {
tmp = x * 3.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.4e+115: tmp = z elif z <= 2e-126: tmp = y * 2.0 elif z <= 8.8e+108: tmp = x * 3.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.4e+115) tmp = z; elseif (z <= 2e-126) tmp = Float64(y * 2.0); elseif (z <= 8.8e+108) tmp = Float64(x * 3.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.4e+115) tmp = z; elseif (z <= 2e-126) tmp = y * 2.0; elseif (z <= 8.8e+108) tmp = x * 3.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.4e+115], z, If[LessEqual[z, 2e-126], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 8.8e+108], N[(x * 3.0), $MachinePrecision], z]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+115}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-126}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+108}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -3.4000000000000001e115 or 8.8000000000000005e108 < z Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 73.8%
if -3.4000000000000001e115 < z < 1.9999999999999999e-126Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 67.9%
Taylor expanded in z around 0 61.5%
Taylor expanded in x around 0 55.7%
*-commutative55.7%
Simplified55.7%
if 1.9999999999999999e-126 < z < 8.8000000000000005e108Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 85.7%
Taylor expanded in x around inf 60.4%
Final simplification62.6%
(FPCore (x y z) :precision binary64 (if (<= z -5.2e+122) (+ (+ z x) (* y 2.0)) (if (<= z 2e+110) (+ x (* 2.0 (+ x y))) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.2e+122) {
tmp = (z + x) + (y * 2.0);
} else if (z <= 2e+110) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.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 (z <= (-5.2d+122)) then
tmp = (z + x) + (y * 2.0d0)
else if (z <= 2d+110) then
tmp = x + (2.0d0 * (x + y))
else
tmp = z + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.2e+122) {
tmp = (z + x) + (y * 2.0);
} else if (z <= 2e+110) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.2e+122: tmp = (z + x) + (y * 2.0) elif z <= 2e+110: tmp = x + (2.0 * (x + y)) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.2e+122) tmp = Float64(Float64(z + x) + Float64(y * 2.0)); elseif (z <= 2e+110) tmp = Float64(x + Float64(2.0 * Float64(x + y))); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.2e+122) tmp = (z + x) + (y * 2.0); elseif (z <= 2e+110) tmp = x + (2.0 * (x + y)); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.2e+122], N[(N[(z + x), $MachinePrecision] + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e+110], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+122}:\\
\;\;\;\;\left(z + x\right) + y \cdot 2\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+110}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -5.20000000000000015e122Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
if -5.20000000000000015e122 < z < 2e110Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 91.0%
if 2e110 < z Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 91.5%
Final simplification91.6%
(FPCore (x y z) :precision binary64 (if (<= z -7.2e+121) (+ z (* y 2.0)) (if (<= z 1.25e+110) (+ x (* 2.0 (+ x y))) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+121) {
tmp = z + (y * 2.0);
} else if (z <= 1.25e+110) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.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 (z <= (-7.2d+121)) then
tmp = z + (y * 2.0d0)
else if (z <= 1.25d+110) then
tmp = x + (2.0d0 * (x + y))
else
tmp = z + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+121) {
tmp = z + (y * 2.0);
} else if (z <= 1.25e+110) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.2e+121: tmp = z + (y * 2.0) elif z <= 1.25e+110: tmp = x + (2.0 * (x + y)) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.2e+121) tmp = Float64(z + Float64(y * 2.0)); elseif (z <= 1.25e+110) tmp = Float64(x + Float64(2.0 * Float64(x + y))); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.2e+121) tmp = z + (y * 2.0); elseif (z <= 1.25e+110) tmp = x + (2.0 * (x + y)); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.2e+121], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.25e+110], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+121}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+110}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -7.19999999999999963e121Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 93.4%
if -7.19999999999999963e121 < z < 1.24999999999999995e110Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 91.0%
if 1.24999999999999995e110 < z Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 91.5%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.2e+74) (not (<= x 6.2e+20))) (+ z (* x 3.0)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.2e+74) || !(x <= 6.2e+20)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (y * 2.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 ((x <= (-6.2d+74)) .or. (.not. (x <= 6.2d+20))) then
tmp = z + (x * 3.0d0)
else
tmp = z + (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -6.2e+74) || !(x <= 6.2e+20)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.2e+74) or not (x <= 6.2e+20): tmp = z + (x * 3.0) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.2e+74) || !(x <= 6.2e+20)) tmp = Float64(z + Float64(x * 3.0)); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6.2e+74) || ~((x <= 6.2e+20))) tmp = z + (x * 3.0); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.2e+74], N[Not[LessEqual[x, 6.2e+20]], $MachinePrecision]], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{+74} \lor \neg \left(x \leq 6.2 \cdot 10^{+20}\right):\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -6.20000000000000043e74 or 6.2e20 < x Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.8%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 83.4%
if -6.20000000000000043e74 < x < 6.2e20Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 93.3%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e+198) (not (<= x 1e+132))) (* x 3.0) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+198) || !(x <= 1e+132)) {
tmp = x * 3.0;
} else {
tmp = z + (y * 2.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 ((x <= (-5.5d+198)) .or. (.not. (x <= 1d+132))) then
tmp = x * 3.0d0
else
tmp = z + (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+198) || !(x <= 1e+132)) {
tmp = x * 3.0;
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+198) or not (x <= 1e+132): tmp = x * 3.0 else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+198) || !(x <= 1e+132)) tmp = Float64(x * 3.0); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e+198) || ~((x <= 1e+132))) tmp = x * 3.0; else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+198], N[Not[LessEqual[x, 1e+132]], $MachinePrecision]], N[(x * 3.0), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+198} \lor \neg \left(x \leq 10^{+132}\right):\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -5.5000000000000004e198 or 9.99999999999999991e131 < x Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 91.7%
Taylor expanded in x around inf 84.1%
if -5.5000000000000004e198 < x < 9.99999999999999991e131Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 81.5%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (<= z -6.5e+121) z (if (<= z 1.25e+109) (* x 3.0) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+121) {
tmp = z;
} else if (z <= 1.25e+109) {
tmp = x * 3.0;
} else {
tmp = 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 <= (-6.5d+121)) then
tmp = z
else if (z <= 1.25d+109) then
tmp = x * 3.0d0
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+121) {
tmp = z;
} else if (z <= 1.25e+109) {
tmp = x * 3.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.5e+121: tmp = z elif z <= 1.25e+109: tmp = x * 3.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.5e+121) tmp = z; elseif (z <= 1.25e+109) tmp = Float64(x * 3.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.5e+121) tmp = z; elseif (z <= 1.25e+109) tmp = x * 3.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.5e+121], z, If[LessEqual[z, 1.25e+109], N[(x * 3.0), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+121}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+109}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -6.50000000000000019e121 or 1.25e109 < z Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+r+100.0%
associate-+r+100.0%
*-lft-identity100.0%
metadata-eval100.0%
count-2100.0%
distribute-rgt-out100.0%
fma-define99.9%
metadata-eval99.9%
metadata-eval99.9%
count-299.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 74.6%
if -6.50000000000000019e121 < z < 1.25e109Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 90.9%
Taylor expanded in x around inf 46.4%
Final simplification55.6%
(FPCore (x y z) :precision binary64 (+ (* 2.0 (+ x y)) (+ z x)))
double code(double x, double y, double z) {
return (2.0 * (x + y)) + (z + x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (2.0d0 * (x + y)) + (z + x)
end function
public static double code(double x, double y, double z) {
return (2.0 * (x + y)) + (z + x);
}
def code(x, y, z): return (2.0 * (x + y)) + (z + x)
function code(x, y, z) return Float64(Float64(2.0 * Float64(x + y)) + Float64(z + x)) end
function tmp = code(x, y, z) tmp = (2.0 * (x + y)) + (z + x); end
code[x_, y_, z_] := N[(N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(z + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x + y\right) + \left(z + x\right)
\end{array}
Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+r+99.9%
associate-+r+99.9%
*-lft-identity99.9%
metadata-eval99.9%
count-299.9%
distribute-rgt-out99.9%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
count-2100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 31.7%
(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 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 71.4%
Taylor expanded in x around inf 8.1%
herbie shell --seed 2024181
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))