
(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 (* 2.0 y))))
double code(double x, double y, double z) {
return z + fma(x, 3.0, (2.0 * y));
}
function code(x, y, z) return Float64(z + fma(x, 3.0, Float64(2.0 * y))) end
code[x_, y_, z_] := N[(z + N[(x * 3.0 + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \mathsf{fma}\left(x, 3, 2 \cdot 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%
add-log-exp20.8%
*-un-lft-identity20.8%
log-prod20.8%
metadata-eval20.8%
add-log-exp99.9%
fma-udef99.9%
+-commutative99.9%
fma-def99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= x -7e+121)
(* x 3.0)
(if (<= x -2.4e-66)
(* 2.0 y)
(if (<= x -2.45e-157)
z
(if (<= x 5.5e-289)
(* 2.0 y)
(if (<= x 3.4e-104) z (if (<= x 1.7e+17) (* 2.0 y) (* x 3.0))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e+121) {
tmp = x * 3.0;
} else if (x <= -2.4e-66) {
tmp = 2.0 * y;
} else if (x <= -2.45e-157) {
tmp = z;
} else if (x <= 5.5e-289) {
tmp = 2.0 * y;
} else if (x <= 3.4e-104) {
tmp = z;
} else if (x <= 1.7e+17) {
tmp = 2.0 * y;
} 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 <= (-7d+121)) then
tmp = x * 3.0d0
else if (x <= (-2.4d-66)) then
tmp = 2.0d0 * y
else if (x <= (-2.45d-157)) then
tmp = z
else if (x <= 5.5d-289) then
tmp = 2.0d0 * y
else if (x <= 3.4d-104) then
tmp = z
else if (x <= 1.7d+17) then
tmp = 2.0d0 * y
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 <= -7e+121) {
tmp = x * 3.0;
} else if (x <= -2.4e-66) {
tmp = 2.0 * y;
} else if (x <= -2.45e-157) {
tmp = z;
} else if (x <= 5.5e-289) {
tmp = 2.0 * y;
} else if (x <= 3.4e-104) {
tmp = z;
} else if (x <= 1.7e+17) {
tmp = 2.0 * y;
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7e+121: tmp = x * 3.0 elif x <= -2.4e-66: tmp = 2.0 * y elif x <= -2.45e-157: tmp = z elif x <= 5.5e-289: tmp = 2.0 * y elif x <= 3.4e-104: tmp = z elif x <= 1.7e+17: tmp = 2.0 * y else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7e+121) tmp = Float64(x * 3.0); elseif (x <= -2.4e-66) tmp = Float64(2.0 * y); elseif (x <= -2.45e-157) tmp = z; elseif (x <= 5.5e-289) tmp = Float64(2.0 * y); elseif (x <= 3.4e-104) tmp = z; elseif (x <= 1.7e+17) tmp = Float64(2.0 * y); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7e+121) tmp = x * 3.0; elseif (x <= -2.4e-66) tmp = 2.0 * y; elseif (x <= -2.45e-157) tmp = z; elseif (x <= 5.5e-289) tmp = 2.0 * y; elseif (x <= 3.4e-104) tmp = z; elseif (x <= 1.7e+17) tmp = 2.0 * y; else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7e+121], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -2.4e-66], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, -2.45e-157], z, If[LessEqual[x, 5.5e-289], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, 3.4e-104], z, If[LessEqual[x, 1.7e+17], N[(2.0 * y), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+121}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{-66}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq -2.45 \cdot 10^{-157}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-289}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-104}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+17}:\\
\;\;\;\;2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -6.9999999999999999e121 or 1.7e17 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 71.2%
if -6.9999999999999999e121 < x < -2.40000000000000026e-66 or -2.4499999999999999e-157 < x < 5.5000000000000004e-289 or 3.40000000000000015e-104 < x < 1.7e17Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in y around inf 55.3%
if -2.40000000000000026e-66 < x < -2.4499999999999999e-157 or 5.5000000000000004e-289 < x < 3.40000000000000015e-104Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in z around inf 66.5%
Final simplification64.0%
(FPCore (x y z)
:precision binary64
(if (<= x -1.7e+123)
(* x 3.0)
(if (or (<= x 1.8e+103) (and (not (<= x 2.8e+159)) (<= x 7.2e+190)))
(+ z (* 2.0 y))
(* x 3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.7e+123) {
tmp = x * 3.0;
} else if ((x <= 1.8e+103) || (!(x <= 2.8e+159) && (x <= 7.2e+190))) {
tmp = z + (2.0 * y);
} 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 <= (-1.7d+123)) then
tmp = x * 3.0d0
else if ((x <= 1.8d+103) .or. (.not. (x <= 2.8d+159)) .and. (x <= 7.2d+190)) then
tmp = z + (2.0d0 * y)
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 <= -1.7e+123) {
tmp = x * 3.0;
} else if ((x <= 1.8e+103) || (!(x <= 2.8e+159) && (x <= 7.2e+190))) {
tmp = z + (2.0 * y);
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.7e+123: tmp = x * 3.0 elif (x <= 1.8e+103) or (not (x <= 2.8e+159) and (x <= 7.2e+190)): tmp = z + (2.0 * y) else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.7e+123) tmp = Float64(x * 3.0); elseif ((x <= 1.8e+103) || (!(x <= 2.8e+159) && (x <= 7.2e+190))) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.7e+123) tmp = x * 3.0; elseif ((x <= 1.8e+103) || (~((x <= 2.8e+159)) && (x <= 7.2e+190))) tmp = z + (2.0 * y); else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.7e+123], N[(x * 3.0), $MachinePrecision], If[Or[LessEqual[x, 1.8e+103], And[N[Not[LessEqual[x, 2.8e+159]], $MachinePrecision], LessEqual[x, 7.2e+190]]], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+123}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+103} \lor \neg \left(x \leq 2.8 \cdot 10^{+159}\right) \land x \leq 7.2 \cdot 10^{+190}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -1.70000000000000001e123 or 1.80000000000000008e103 < x < 2.8000000000000001e159 or 7.19999999999999957e190 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 80.4%
if -1.70000000000000001e123 < x < 1.80000000000000008e103 or 2.8000000000000001e159 < x < 7.19999999999999957e190Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 84.4%
Final simplification83.1%
(FPCore (x y z) :precision binary64 (if (<= y -1.25e+130) (+ z (* 2.0 y)) (if (<= y 3.6e-26) (+ z (* x 3.0)) (+ x (* 2.0 (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e+130) {
tmp = z + (2.0 * y);
} else if (y <= 3.6e-26) {
tmp = z + (x * 3.0);
} else {
tmp = x + (2.0 * (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 <= (-1.25d+130)) then
tmp = z + (2.0d0 * y)
else if (y <= 3.6d-26) then
tmp = z + (x * 3.0d0)
else
tmp = x + (2.0d0 * (x + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e+130) {
tmp = z + (2.0 * y);
} else if (y <= 3.6e-26) {
tmp = z + (x * 3.0);
} else {
tmp = x + (2.0 * (x + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.25e+130: tmp = z + (2.0 * y) elif y <= 3.6e-26: tmp = z + (x * 3.0) else: tmp = x + (2.0 * (x + y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.25e+130) tmp = Float64(z + Float64(2.0 * y)); elseif (y <= 3.6e-26) tmp = Float64(z + Float64(x * 3.0)); else tmp = Float64(x + Float64(2.0 * Float64(x + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.25e+130) tmp = z + (2.0 * y); elseif (y <= 3.6e-26) tmp = z + (x * 3.0); else tmp = x + (2.0 * (x + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.25e+130], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-26], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+130}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-26}:\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -1.2499999999999999e130Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 91.5%
if -1.2499999999999999e130 < y < 3.6000000000000001e-26Initial 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%
Taylor expanded in y around 0 91.3%
if 3.6000000000000001e-26 < y Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around 0 89.0%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (<= y -2e+132) (+ z (* 2.0 y)) (if (<= y 2.35e-26) (+ z (* x 3.0)) (+ (* 2.0 y) (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+132) {
tmp = z + (2.0 * y);
} else if (y <= 2.35e-26) {
tmp = z + (x * 3.0);
} else {
tmp = (2.0 * y) + (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 (y <= (-2d+132)) then
tmp = z + (2.0d0 * y)
else if (y <= 2.35d-26) then
tmp = z + (x * 3.0d0)
else
tmp = (2.0d0 * y) + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e+132) {
tmp = z + (2.0 * y);
} else if (y <= 2.35e-26) {
tmp = z + (x * 3.0);
} else {
tmp = (2.0 * y) + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+132: tmp = z + (2.0 * y) elif y <= 2.35e-26: tmp = z + (x * 3.0) else: tmp = (2.0 * y) + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+132) tmp = Float64(z + Float64(2.0 * y)); elseif (y <= 2.35e-26) tmp = Float64(z + Float64(x * 3.0)); else tmp = Float64(Float64(2.0 * y) + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+132) tmp = z + (2.0 * y); elseif (y <= 2.35e-26) tmp = z + (x * 3.0); else tmp = (2.0 * y) + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+132], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.35e-26], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+132}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-26}:\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y + x \cdot 3\\
\end{array}
\end{array}
if y < -1.99999999999999998e132Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 91.5%
if -1.99999999999999998e132 < y < 2.34999999999999995e-26Initial 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%
Taylor expanded in y around 0 91.3%
if 2.34999999999999995e-26 < y 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%
add-log-exp9.6%
*-un-lft-identity9.6%
log-prod9.6%
metadata-eval9.6%
add-log-exp99.9%
fma-udef99.9%
+-commutative99.9%
fma-def100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 89.1%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.56e+131) (not (<= y 4.9e+30))) (+ z (* 2.0 y)) (+ z (* x 3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.56e+131) || !(y <= 4.9e+30)) {
tmp = z + (2.0 * 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 ((y <= (-1.56d+131)) .or. (.not. (y <= 4.9d+30))) then
tmp = z + (2.0d0 * 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 ((y <= -1.56e+131) || !(y <= 4.9e+30)) {
tmp = z + (2.0 * y);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.56e+131) or not (y <= 4.9e+30): tmp = z + (2.0 * y) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.56e+131) || !(y <= 4.9e+30)) tmp = Float64(z + Float64(2.0 * y)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.56e+131) || ~((y <= 4.9e+30))) tmp = z + (2.0 * y); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.56e+131], N[Not[LessEqual[y, 4.9e+30]], $MachinePrecision]], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.56 \cdot 10^{+131} \lor \neg \left(y \leq 4.9 \cdot 10^{+30}\right):\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if y < -1.5600000000000001e131 or 4.89999999999999984e30 < y Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around 0 86.4%
if -1.5600000000000001e131 < y < 4.89999999999999984e30Initial 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%
Taylor expanded in y around 0 89.2%
Final simplification88.2%
(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 (+ (* 2.0 y) (* x 3.0))))
double code(double x, double y, double z) {
return z + ((2.0 * y) + (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 + ((2.0d0 * y) + (x * 3.0d0))
end function
public static double code(double x, double y, double z) {
return z + ((2.0 * y) + (x * 3.0));
}
def code(x, y, z): return z + ((2.0 * y) + (x * 3.0))
function code(x, y, z) return Float64(z + Float64(Float64(2.0 * y) + Float64(x * 3.0))) end
function tmp = code(x, y, z) tmp = z + ((2.0 * y) + (x * 3.0)); end
code[x_, y_, z_] := N[(z + N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + \left(2 \cdot y + 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 (<= y -5.9e+23) (* 2.0 y) (if (<= y 1.05e-24) z (* 2.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.9e+23) {
tmp = 2.0 * y;
} else if (y <= 1.05e-24) {
tmp = z;
} else {
tmp = 2.0 * 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 <= (-5.9d+23)) then
tmp = 2.0d0 * y
else if (y <= 1.05d-24) then
tmp = z
else
tmp = 2.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.9e+23) {
tmp = 2.0 * y;
} else if (y <= 1.05e-24) {
tmp = z;
} else {
tmp = 2.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.9e+23: tmp = 2.0 * y elif y <= 1.05e-24: tmp = z else: tmp = 2.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.9e+23) tmp = Float64(2.0 * y); elseif (y <= 1.05e-24) tmp = z; else tmp = Float64(2.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.9e+23) tmp = 2.0 * y; elseif (y <= 1.05e-24) tmp = z; else tmp = 2.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.9e+23], N[(2.0 * y), $MachinePrecision], If[LessEqual[y, 1.05e-24], z, N[(2.0 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.9 \cdot 10^{+23}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-24}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y\\
\end{array}
\end{array}
if y < -5.89999999999999987e23 or 1.05e-24 < y Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 62.1%
if -5.89999999999999987e23 < y < 1.05e-24Initial program 99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in z around inf 46.3%
Final simplification53.5%
(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 31.9%
Final simplification31.9%
herbie shell --seed 2023293
(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))