
(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 10 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 y))))
double code(double x, double y, double z) {
return z + fma(x, 3.0, (y + y));
}
function code(x, y, z) return Float64(z + fma(x, 3.0, Float64(y + y))) end
code[x_, y_, z_] := N[(z + N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \mathsf{fma}\left(x, 3, y + y\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
associate--l+99.9%
count-299.9%
*-commutative99.9%
fma-def99.9%
count-299.9%
neg-mul-199.9%
distribute-rgt-out--99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
fma-def100.0%
add-log-exp53.6%
*-commutative53.6%
exp-lft-sqr53.5%
log-prod53.9%
add-log-exp54.6%
add-log-exp100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -1.55e+38)
z
(if (<= z -2.85e-30)
(* y 2.0)
(if (<= z -2.9e-38)
z
(if (<= z -8.5e-122)
(* x 3.0)
(if (<= z -3.7e-174)
(* y 2.0)
(if (<= z -4.7e-232)
(* x 3.0)
(if (<= z 2.25e-301)
(* y 2.0)
(if (<= z 1.28e+75) (* x 3.0) z)))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e+38) {
tmp = z;
} else if (z <= -2.85e-30) {
tmp = y * 2.0;
} else if (z <= -2.9e-38) {
tmp = z;
} else if (z <= -8.5e-122) {
tmp = x * 3.0;
} else if (z <= -3.7e-174) {
tmp = y * 2.0;
} else if (z <= -4.7e-232) {
tmp = x * 3.0;
} else if (z <= 2.25e-301) {
tmp = y * 2.0;
} else if (z <= 1.28e+75) {
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 <= (-1.55d+38)) then
tmp = z
else if (z <= (-2.85d-30)) then
tmp = y * 2.0d0
else if (z <= (-2.9d-38)) then
tmp = z
else if (z <= (-8.5d-122)) then
tmp = x * 3.0d0
else if (z <= (-3.7d-174)) then
tmp = y * 2.0d0
else if (z <= (-4.7d-232)) then
tmp = x * 3.0d0
else if (z <= 2.25d-301) then
tmp = y * 2.0d0
else if (z <= 1.28d+75) 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 <= -1.55e+38) {
tmp = z;
} else if (z <= -2.85e-30) {
tmp = y * 2.0;
} else if (z <= -2.9e-38) {
tmp = z;
} else if (z <= -8.5e-122) {
tmp = x * 3.0;
} else if (z <= -3.7e-174) {
tmp = y * 2.0;
} else if (z <= -4.7e-232) {
tmp = x * 3.0;
} else if (z <= 2.25e-301) {
tmp = y * 2.0;
} else if (z <= 1.28e+75) {
tmp = x * 3.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.55e+38: tmp = z elif z <= -2.85e-30: tmp = y * 2.0 elif z <= -2.9e-38: tmp = z elif z <= -8.5e-122: tmp = x * 3.0 elif z <= -3.7e-174: tmp = y * 2.0 elif z <= -4.7e-232: tmp = x * 3.0 elif z <= 2.25e-301: tmp = y * 2.0 elif z <= 1.28e+75: tmp = x * 3.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.55e+38) tmp = z; elseif (z <= -2.85e-30) tmp = Float64(y * 2.0); elseif (z <= -2.9e-38) tmp = z; elseif (z <= -8.5e-122) tmp = Float64(x * 3.0); elseif (z <= -3.7e-174) tmp = Float64(y * 2.0); elseif (z <= -4.7e-232) tmp = Float64(x * 3.0); elseif (z <= 2.25e-301) tmp = Float64(y * 2.0); elseif (z <= 1.28e+75) tmp = Float64(x * 3.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.55e+38) tmp = z; elseif (z <= -2.85e-30) tmp = y * 2.0; elseif (z <= -2.9e-38) tmp = z; elseif (z <= -8.5e-122) tmp = x * 3.0; elseif (z <= -3.7e-174) tmp = y * 2.0; elseif (z <= -4.7e-232) tmp = x * 3.0; elseif (z <= 2.25e-301) tmp = y * 2.0; elseif (z <= 1.28e+75) tmp = x * 3.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.55e+38], z, If[LessEqual[z, -2.85e-30], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, -2.9e-38], z, If[LessEqual[z, -8.5e-122], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, -3.7e-174], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, -4.7e-232], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 2.25e-301], N[(y * 2.0), $MachinePrecision], If[LessEqual[z, 1.28e+75], N[(x * 3.0), $MachinePrecision], z]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+38}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq -2.85 \cdot 10^{-30}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{-38}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{-122}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-174}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq -4.7 \cdot 10^{-232}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{-301}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;z \leq 1.28 \cdot 10^{+75}:\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.55000000000000009e38 or -2.84999999999999989e-30 < z < -2.89999999999999994e-38 or 1.27999999999999998e75 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 72.5%
if -1.55000000000000009e38 < z < -2.84999999999999989e-30 or -8.50000000000000003e-122 < z < -3.7000000000000001e-174 or -4.70000000000000035e-232 < z < 2.2500000000000001e-301Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 72.3%
if -2.89999999999999994e-38 < z < -8.50000000000000003e-122 or -3.7000000000000001e-174 < z < -4.70000000000000035e-232 or 2.2500000000000001e-301 < z < 1.27999999999999998e75Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 58.8%
Final simplification66.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ z (* x 3.0))))
(if (<= x -1.7e+99)
t_0
(if (<= x -2.65e-65)
(+ x (* 2.0 (+ x y)))
(if (<= x 3e-27) (+ z (* y 2.0)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z + (x * 3.0);
double tmp;
if (x <= -1.7e+99) {
tmp = t_0;
} else if (x <= -2.65e-65) {
tmp = x + (2.0 * (x + y));
} else if (x <= 3e-27) {
tmp = z + (y * 2.0);
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = z + (x * 3.0d0)
if (x <= (-1.7d+99)) then
tmp = t_0
else if (x <= (-2.65d-65)) then
tmp = x + (2.0d0 * (x + y))
else if (x <= 3d-27) then
tmp = z + (y * 2.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z + (x * 3.0);
double tmp;
if (x <= -1.7e+99) {
tmp = t_0;
} else if (x <= -2.65e-65) {
tmp = x + (2.0 * (x + y));
} else if (x <= 3e-27) {
tmp = z + (y * 2.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z + (x * 3.0) tmp = 0 if x <= -1.7e+99: tmp = t_0 elif x <= -2.65e-65: tmp = x + (2.0 * (x + y)) elif x <= 3e-27: tmp = z + (y * 2.0) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z + Float64(x * 3.0)) tmp = 0.0 if (x <= -1.7e+99) tmp = t_0; elseif (x <= -2.65e-65) tmp = Float64(x + Float64(2.0 * Float64(x + y))); elseif (x <= 3e-27) tmp = Float64(z + Float64(y * 2.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z + (x * 3.0); tmp = 0.0; if (x <= -1.7e+99) tmp = t_0; elseif (x <= -2.65e-65) tmp = x + (2.0 * (x + y)); elseif (x <= 3e-27) tmp = z + (y * 2.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e+99], t$95$0, If[LessEqual[x, -2.65e-65], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3e-27], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z + x \cdot 3\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{+99}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.65 \cdot 10^{-65}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-27}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.69999999999999992e99 or 3.0000000000000001e-27 < x Initial program 99.7%
+-commutative99.7%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.7%
+-commutative99.7%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 92.7%
if -1.69999999999999992e99 < x < -2.65000000000000019e-65Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around 0 77.5%
if -2.65000000000000019e-65 < x < 3.0000000000000001e-27Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 95.8%
Final simplification92.0%
(FPCore (x y z)
:precision binary64
(if (<= x -5.4e+98)
(+ (+ z x) (* x 2.0))
(if (<= x -2.65e-65)
(+ x (* 2.0 (+ x y)))
(if (<= x 4.2e-27) (+ z (* y 2.0)) (+ z (* x 3.0))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.4e+98) {
tmp = (z + x) + (x * 2.0);
} else if (x <= -2.65e-65) {
tmp = x + (2.0 * (x + y));
} else if (x <= 4.2e-27) {
tmp = z + (y * 2.0);
} 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 (x <= (-5.4d+98)) then
tmp = (z + x) + (x * 2.0d0)
else if (x <= (-2.65d-65)) then
tmp = x + (2.0d0 * (x + y))
else if (x <= 4.2d-27) then
tmp = z + (y * 2.0d0)
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 (x <= -5.4e+98) {
tmp = (z + x) + (x * 2.0);
} else if (x <= -2.65e-65) {
tmp = x + (2.0 * (x + y));
} else if (x <= 4.2e-27) {
tmp = z + (y * 2.0);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.4e+98: tmp = (z + x) + (x * 2.0) elif x <= -2.65e-65: tmp = x + (2.0 * (x + y)) elif x <= 4.2e-27: tmp = z + (y * 2.0) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.4e+98) tmp = Float64(Float64(z + x) + Float64(x * 2.0)); elseif (x <= -2.65e-65) tmp = Float64(x + Float64(2.0 * Float64(x + y))); elseif (x <= 4.2e-27) tmp = Float64(z + Float64(y * 2.0)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.4e+98) tmp = (z + x) + (x * 2.0); elseif (x <= -2.65e-65) tmp = x + (2.0 * (x + y)); elseif (x <= 4.2e-27) tmp = z + (y * 2.0); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.4e+98], N[(N[(z + x), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.65e-65], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2e-27], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+98}:\\
\;\;\;\;\left(z + x\right) + x \cdot 2\\
\mathbf{elif}\;x \leq -2.65 \cdot 10^{-65}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-27}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if x < -5.4e98Initial program 99.7%
+-commutative99.7%
associate-+l+99.7%
+-commutative99.7%
count-299.7%
Simplified99.7%
Taylor expanded in y around 0 96.3%
associate-+r+96.3%
+-commutative96.3%
Simplified96.3%
if -5.4e98 < x < -2.65000000000000019e-65Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around 0 77.5%
if -2.65000000000000019e-65 < x < 4.20000000000000031e-27Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 95.8%
if 4.20000000000000031e-27 < x Initial program 99.7%
+-commutative99.7%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 90.8%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.65e+37) (not (<= x 5.8e-32))) (+ z (* x 3.0)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.65e+37) || !(x <= 5.8e-32)) {
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 <= (-3.65d+37)) .or. (.not. (x <= 5.8d-32))) 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 <= -3.65e+37) || !(x <= 5.8e-32)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.65e+37) or not (x <= 5.8e-32): tmp = z + (x * 3.0) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.65e+37) || !(x <= 5.8e-32)) 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 <= -3.65e+37) || ~((x <= 5.8e-32))) tmp = z + (x * 3.0); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.65e+37], N[Not[LessEqual[x, 5.8e-32]], $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 -3.65 \cdot 10^{+37} \lor \neg \left(x \leq 5.8 \cdot 10^{-32}\right):\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -3.65000000000000019e37 or 5.79999999999999991e-32 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
associate--l+99.8%
count-299.8%
*-commutative99.8%
fma-def99.8%
count-299.8%
neg-mul-199.8%
distribute-rgt-out--99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 88.5%
if -3.65000000000000019e37 < x < 5.79999999999999991e-32Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 92.0%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= x -3.6e+141) (* x 3.0) (if (<= x 1.3e+51) (+ z (* y 2.0)) (* x 3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e+141) {
tmp = x * 3.0;
} else if (x <= 1.3e+51) {
tmp = z + (y * 2.0);
} else {
tmp = 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 (x <= (-3.6d+141)) then
tmp = x * 3.0d0
else if (x <= 1.3d+51) then
tmp = z + (y * 2.0d0)
else
tmp = x * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e+141) {
tmp = x * 3.0;
} else if (x <= 1.3e+51) {
tmp = z + (y * 2.0);
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.6e+141: tmp = x * 3.0 elif x <= 1.3e+51: tmp = z + (y * 2.0) else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.6e+141) tmp = Float64(x * 3.0); elseif (x <= 1.3e+51) tmp = Float64(z + Float64(y * 2.0)); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.6e+141) tmp = x * 3.0; elseif (x <= 1.3e+51) tmp = z + (y * 2.0); else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.6e+141], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, 1.3e+51], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+141}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+51}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -3.6000000000000001e141 or 1.3000000000000001e51 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 73.9%
if -3.6000000000000001e141 < x < 1.3000000000000001e51Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 85.8%
Final simplification81.8%
(FPCore (x y z) :precision binary64 (+ x (+ z (* 2.0 (+ x y)))))
double code(double x, double y, double z) {
return x + (z + (2.0 * (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 + (z + (2.0d0 * (x + y)))
end function
public static double code(double x, double y, double z) {
return x + (z + (2.0 * (x + y)));
}
def code(x, y, z): return x + (z + (2.0 * (x + y)))
function code(x, y, z) return Float64(x + Float64(z + Float64(2.0 * Float64(x + y)))) end
function tmp = code(x, y, z) tmp = x + (z + (2.0 * (x + y))); end
code[x_, y_, z_] := N[(x + N[(z + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z + 2 \cdot \left(x + y\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (+ z (+ (* y 2.0) (* x 3.0))))
double code(double x, double y, double z) {
return z + ((y * 2.0) + (x * 3.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + ((y * 2.0d0) + (x * 3.0d0))
end function
public static double code(double x, double y, double z) {
return z + ((y * 2.0) + (x * 3.0));
}
def code(x, y, z): return z + ((y * 2.0) + (x * 3.0))
function code(x, y, z) return Float64(z + Float64(Float64(y * 2.0) + Float64(x * 3.0))) end
function tmp = code(x, y, z) tmp = z + ((y * 2.0) + (x * 3.0)); end
code[x_, y_, z_] := N[(z + N[(N[(y * 2.0), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \left(y \cdot 2 + x \cdot 3\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
associate--l+99.9%
count-299.9%
*-commutative99.9%
fma-def99.9%
count-299.9%
neg-mul-199.9%
distribute-rgt-out--99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -3.9e+40) z (if (<= z 1.5e-58) (* y 2.0) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.9e+40) {
tmp = z;
} else if (z <= 1.5e-58) {
tmp = y * 2.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.9d+40)) then
tmp = z
else if (z <= 1.5d-58) then
tmp = y * 2.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.9e+40) {
tmp = z;
} else if (z <= 1.5e-58) {
tmp = y * 2.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.9e+40: tmp = z elif z <= 1.5e-58: tmp = y * 2.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.9e+40) tmp = z; elseif (z <= 1.5e-58) tmp = Float64(y * 2.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.9e+40) tmp = z; elseif (z <= 1.5e-58) tmp = y * 2.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.9e+40], z, If[LessEqual[z, 1.5e-58], N[(y * 2.0), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+40}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-58}:\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -3.9000000000000001e40 or 1.50000000000000004e-58 < z Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 61.8%
if -3.9000000000000001e40 < z < 1.50000000000000004e-58Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 49.4%
Final simplification55.6%
(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%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 35.6%
Final simplification35.6%
herbie shell --seed 2023271
(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))