
(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 9 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%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.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 99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= x -4.4e+44)
(* x 3.0)
(if (<= x -6e-50)
(* 2.0 y)
(if (<= x -3.6e-289)
z
(if (<= x 1.1e-196)
(* 2.0 y)
(if (<= x 8.6e-129) z (if (<= x 1.12e+43) (* 2.0 y) (* x 3.0))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+44) {
tmp = x * 3.0;
} else if (x <= -6e-50) {
tmp = 2.0 * y;
} else if (x <= -3.6e-289) {
tmp = z;
} else if (x <= 1.1e-196) {
tmp = 2.0 * y;
} else if (x <= 8.6e-129) {
tmp = z;
} else if (x <= 1.12e+43) {
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 <= (-4.4d+44)) then
tmp = x * 3.0d0
else if (x <= (-6d-50)) then
tmp = 2.0d0 * y
else if (x <= (-3.6d-289)) then
tmp = z
else if (x <= 1.1d-196) then
tmp = 2.0d0 * y
else if (x <= 8.6d-129) then
tmp = z
else if (x <= 1.12d+43) 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 <= -4.4e+44) {
tmp = x * 3.0;
} else if (x <= -6e-50) {
tmp = 2.0 * y;
} else if (x <= -3.6e-289) {
tmp = z;
} else if (x <= 1.1e-196) {
tmp = 2.0 * y;
} else if (x <= 8.6e-129) {
tmp = z;
} else if (x <= 1.12e+43) {
tmp = 2.0 * y;
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.4e+44: tmp = x * 3.0 elif x <= -6e-50: tmp = 2.0 * y elif x <= -3.6e-289: tmp = z elif x <= 1.1e-196: tmp = 2.0 * y elif x <= 8.6e-129: tmp = z elif x <= 1.12e+43: tmp = 2.0 * y else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.4e+44) tmp = Float64(x * 3.0); elseif (x <= -6e-50) tmp = Float64(2.0 * y); elseif (x <= -3.6e-289) tmp = z; elseif (x <= 1.1e-196) tmp = Float64(2.0 * y); elseif (x <= 8.6e-129) tmp = z; elseif (x <= 1.12e+43) 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 <= -4.4e+44) tmp = x * 3.0; elseif (x <= -6e-50) tmp = 2.0 * y; elseif (x <= -3.6e-289) tmp = z; elseif (x <= 1.1e-196) tmp = 2.0 * y; elseif (x <= 8.6e-129) tmp = z; elseif (x <= 1.12e+43) tmp = 2.0 * y; else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.4e+44], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -6e-50], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, -3.6e-289], z, If[LessEqual[x, 1.1e-196], N[(2.0 * y), $MachinePrecision], If[LessEqual[x, 8.6e-129], z, If[LessEqual[x, 1.12e+43], N[(2.0 * y), $MachinePrecision], N[(x * 3.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+44}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-50}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-289}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-196}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{-129}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+43}:\\
\;\;\;\;2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
if x < -4.39999999999999991e44 or 1.12e43 < 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%
+-commutative99.8%
+-commutative99.8%
associate-+r+99.8%
associate-+r+99.9%
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 99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 64.3%
if -4.39999999999999991e44 < x < -5.99999999999999981e-50 or -3.6e-289 < x < 1.10000000000000007e-196 or 8.59999999999999962e-129 < x < 1.12e43Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+99.9%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
*-commutative100.0%
*-commutative100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 68.7%
if -5.99999999999999981e-50 < x < -3.6e-289 or 1.10000000000000007e-196 < x < 8.59999999999999962e-129Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 61.7%
Final simplification65.1%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.55e+88)
(not (or (<= x 6.8e+44) (and (not (<= x 1.6e+88)) (<= x 1.1e+173)))))
(* x 3.0)
(+ z (* 2.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55e+88) || !((x <= 6.8e+44) || (!(x <= 1.6e+88) && (x <= 1.1e+173)))) {
tmp = x * 3.0;
} else {
tmp = z + (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 ((x <= (-1.55d+88)) .or. (.not. (x <= 6.8d+44) .or. (.not. (x <= 1.6d+88)) .and. (x <= 1.1d+173))) then
tmp = x * 3.0d0
else
tmp = z + (2.0d0 * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55e+88) || !((x <= 6.8e+44) || (!(x <= 1.6e+88) && (x <= 1.1e+173)))) {
tmp = x * 3.0;
} else {
tmp = z + (2.0 * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.55e+88) or not ((x <= 6.8e+44) or (not (x <= 1.6e+88) and (x <= 1.1e+173))): tmp = x * 3.0 else: tmp = z + (2.0 * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.55e+88) || !((x <= 6.8e+44) || (!(x <= 1.6e+88) && (x <= 1.1e+173)))) tmp = Float64(x * 3.0); else tmp = Float64(z + Float64(2.0 * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.55e+88) || ~(((x <= 6.8e+44) || (~((x <= 1.6e+88)) && (x <= 1.1e+173))))) tmp = x * 3.0; else tmp = z + (2.0 * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.55e+88], N[Not[Or[LessEqual[x, 6.8e+44], And[N[Not[LessEqual[x, 1.6e+88]], $MachinePrecision], LessEqual[x, 1.1e+173]]]], $MachinePrecision]], N[(x * 3.0), $MachinePrecision], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+88} \lor \neg \left(x \leq 6.8 \cdot 10^{+44} \lor \neg \left(x \leq 1.6 \cdot 10^{+88}\right) \land x \leq 1.1 \cdot 10^{+173}\right):\\
\;\;\;\;x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + 2 \cdot y\\
\end{array}
\end{array}
if x < -1.5500000000000001e88 or 6.8e44 < x < 1.5999999999999999e88 or 1.1e173 < 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%
+-commutative99.8%
+-commutative99.8%
associate-+r+99.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 99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 74.9%
if -1.5500000000000001e88 < x < 6.8e44 or 1.5999999999999999e88 < x < 1.1e173Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+99.9%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 88.5%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.6e-11) (+ z (* 2.0 y)) (if (<= z 3.8e+135) (+ x (* 2.0 (+ x y))) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.6e-11) {
tmp = z + (2.0 * y);
} else if (z <= 3.8e+135) {
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 <= (-1.6d-11)) then
tmp = z + (2.0d0 * y)
else if (z <= 3.8d+135) 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 <= -1.6e-11) {
tmp = z + (2.0 * y);
} else if (z <= 3.8e+135) {
tmp = x + (2.0 * (x + y));
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.6e-11: tmp = z + (2.0 * y) elif z <= 3.8e+135: tmp = x + (2.0 * (x + y)) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.6e-11) tmp = Float64(z + Float64(2.0 * y)); elseif (z <= 3.8e+135) 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 <= -1.6e-11) tmp = z + (2.0 * y); elseif (z <= 3.8e+135) tmp = x + (2.0 * (x + y)); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.6e-11], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.8e+135], 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 -1.6 \cdot 10^{-11}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+135}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -1.59999999999999997e-11Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 85.8%
if -1.59999999999999997e-11 < z < 3.8000000000000001e135Initial program 99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
count-299.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 92.7%
if 3.8000000000000001e135 < z Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 96.9%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.4e-11) (+ z (* 2.0 y)) (if (<= z 6.6e+137) (+ (* 2.0 y) (* x 3.0)) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e-11) {
tmp = z + (2.0 * y);
} else if (z <= 6.6e+137) {
tmp = (2.0 * y) + (x * 3.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 (z <= (-1.4d-11)) then
tmp = z + (2.0d0 * y)
else if (z <= 6.6d+137) then
tmp = (2.0d0 * y) + (x * 3.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 (z <= -1.4e-11) {
tmp = z + (2.0 * y);
} else if (z <= 6.6e+137) {
tmp = (2.0 * y) + (x * 3.0);
} else {
tmp = z + (x * 3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.4e-11: tmp = z + (2.0 * y) elif z <= 6.6e+137: tmp = (2.0 * y) + (x * 3.0) else: tmp = z + (x * 3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.4e-11) tmp = Float64(z + Float64(2.0 * y)); elseif (z <= 6.6e+137) tmp = Float64(Float64(2.0 * y) + Float64(x * 3.0)); else tmp = Float64(z + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.4e-11) tmp = z + (2.0 * y); elseif (z <= 6.6e+137) tmp = (2.0 * y) + (x * 3.0); else tmp = z + (x * 3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.4e-11], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.6e+137], N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-11}:\\
\;\;\;\;z + 2 \cdot y\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{+137}:\\
\;\;\;\;2 \cdot y + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot 3\\
\end{array}
\end{array}
if z < -1.4e-11Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 85.8%
if -1.4e-11 < z < 6.60000000000000005e137Initial 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%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.8%
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 99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in z around 0 92.7%
if 6.60000000000000005e137 < z Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 96.9%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.4e+46) (not (<= x 5.2e+44))) (+ z (* x 3.0)) (+ z (* 2.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.4e+46) || !(x <= 5.2e+44)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (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 ((x <= (-8.4d+46)) .or. (.not. (x <= 5.2d+44))) then
tmp = z + (x * 3.0d0)
else
tmp = z + (2.0d0 * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.4e+46) || !(x <= 5.2e+44)) {
tmp = z + (x * 3.0);
} else {
tmp = z + (2.0 * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.4e+46) or not (x <= 5.2e+44): tmp = z + (x * 3.0) else: tmp = z + (2.0 * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.4e+46) || !(x <= 5.2e+44)) tmp = Float64(z + Float64(x * 3.0)); else tmp = Float64(z + Float64(2.0 * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.4e+46) || ~((x <= 5.2e+44))) tmp = z + (x * 3.0); else tmp = z + (2.0 * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.4e+46], N[Not[LessEqual[x, 5.2e+44]], $MachinePrecision]], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{+46} \lor \neg \left(x \leq 5.2 \cdot 10^{+44}\right):\\
\;\;\;\;z + x \cdot 3\\
\mathbf{else}:\\
\;\;\;\;z + 2 \cdot y\\
\end{array}
\end{array}
if x < -8.4e46 or 5.1999999999999998e44 < 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%
+-commutative99.8%
+-commutative99.8%
associate-+r+99.8%
associate-+r+99.9%
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 83.2%
if -8.4e46 < x < 5.1999999999999998e44Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 93.1%
Final simplification88.5%
(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%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.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%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -4.2e+95) z (if (<= z 3.2e+135) (* 2.0 y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+95) {
tmp = z;
} else if (z <= 3.2e+135) {
tmp = 2.0 * y;
} 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 <= (-4.2d+95)) then
tmp = z
else if (z <= 3.2d+135) then
tmp = 2.0d0 * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+95) {
tmp = z;
} else if (z <= 3.2e+135) {
tmp = 2.0 * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e+95: tmp = z elif z <= 3.2e+135: tmp = 2.0 * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e+95) tmp = z; elseif (z <= 3.2e+135) tmp = Float64(2.0 * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.2e+95) tmp = z; elseif (z <= 3.2e+135) tmp = 2.0 * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e+95], z, If[LessEqual[z, 3.2e+135], N[(2.0 * y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+95}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+135}:\\
\;\;\;\;2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -4.2e95 or 3.19999999999999975e135 < z Initial program 99.9%
+-commutative99.9%
associate-+l+100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
associate-+r+100.0%
associate--l+100.0%
count-2100.0%
*-commutative100.0%
fma-def100.0%
count-2100.0%
neg-mul-1100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 77.1%
if -4.2e95 < z < 3.19999999999999975e135Initial 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%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.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 99.9%
+-commutative99.9%
*-commutative99.9%
*-commutative99.9%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around inf 48.6%
Final simplification57.0%
(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%
remove-double-neg99.9%
distribute-neg-in99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.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 z around inf 31.3%
Final simplification31.3%
herbie shell --seed 2023310
(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))