
(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 (+ y (+ z (fma 3.0 x y))))
double code(double x, double y, double z) {
return y + (z + fma(3.0, x, y));
}
function code(x, y, z) return Float64(y + Float64(z + fma(3.0, x, y))) end
code[x_, y_, z_] := N[(y + N[(z + N[(3.0 * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \left(z + \mathsf{fma}\left(3, x, y\right)\right)
\end{array}
Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
count-299.9%
distribute-rgt1-in99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (* 3.0 x))))
(if (<= x -3.8e+38)
t_0
(if (<= x -1.05e-193)
(+ y z)
(if (<= x -8.5e-236)
(+ y y)
(if (<= x 5.4e-176) (+ y z) (if (<= x 1.1e+42) (+ y y) t_0)))))))
double code(double x, double y, double z) {
double t_0 = y + (3.0 * x);
double tmp;
if (x <= -3.8e+38) {
tmp = t_0;
} else if (x <= -1.05e-193) {
tmp = y + z;
} else if (x <= -8.5e-236) {
tmp = y + y;
} else if (x <= 5.4e-176) {
tmp = y + z;
} else if (x <= 1.1e+42) {
tmp = y + y;
} 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 = y + (3.0d0 * x)
if (x <= (-3.8d+38)) then
tmp = t_0
else if (x <= (-1.05d-193)) then
tmp = y + z
else if (x <= (-8.5d-236)) then
tmp = y + y
else if (x <= 5.4d-176) then
tmp = y + z
else if (x <= 1.1d+42) then
tmp = y + y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (3.0 * x);
double tmp;
if (x <= -3.8e+38) {
tmp = t_0;
} else if (x <= -1.05e-193) {
tmp = y + z;
} else if (x <= -8.5e-236) {
tmp = y + y;
} else if (x <= 5.4e-176) {
tmp = y + z;
} else if (x <= 1.1e+42) {
tmp = y + y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y + (3.0 * x) tmp = 0 if x <= -3.8e+38: tmp = t_0 elif x <= -1.05e-193: tmp = y + z elif x <= -8.5e-236: tmp = y + y elif x <= 5.4e-176: tmp = y + z elif x <= 1.1e+42: tmp = y + y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y + Float64(3.0 * x)) tmp = 0.0 if (x <= -3.8e+38) tmp = t_0; elseif (x <= -1.05e-193) tmp = Float64(y + z); elseif (x <= -8.5e-236) tmp = Float64(y + y); elseif (x <= 5.4e-176) tmp = Float64(y + z); elseif (x <= 1.1e+42) tmp = Float64(y + y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (3.0 * x); tmp = 0.0; if (x <= -3.8e+38) tmp = t_0; elseif (x <= -1.05e-193) tmp = y + z; elseif (x <= -8.5e-236) tmp = y + y; elseif (x <= 5.4e-176) tmp = y + z; elseif (x <= 1.1e+42) tmp = y + y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(3.0 * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.8e+38], t$95$0, If[LessEqual[x, -1.05e-193], N[(y + z), $MachinePrecision], If[LessEqual[x, -8.5e-236], N[(y + y), $MachinePrecision], If[LessEqual[x, 5.4e-176], N[(y + z), $MachinePrecision], If[LessEqual[x, 1.1e+42], N[(y + y), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + 3 \cdot x\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{-193}:\\
\;\;\;\;y + z\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-236}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-176}:\\
\;\;\;\;y + z\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+42}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.7999999999999998e38 or 1.1000000000000001e42 < x Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
count-299.8%
distribute-rgt1-in99.8%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 81.7%
+-commutative81.7%
fma-def81.8%
Simplified81.8%
Taylor expanded in z around 0 65.8%
if -3.7999999999999998e38 < x < -1.05e-193 or -8.49999999999999929e-236 < x < 5.3999999999999997e-176Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
count-2100.0%
distribute-rgt1-in100.0%
fma-def100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 68.8%
+-commutative68.8%
fma-def68.7%
Simplified68.7%
Taylor expanded in x around 0 64.3%
+-commutative64.3%
Simplified64.3%
if -1.05e-193 < x < -8.49999999999999929e-236 or 5.3999999999999997e-176 < x < 1.1000000000000001e42Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+99.9%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
count-2100.0%
distribute-rgt1-in100.0%
fma-def100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 63.6%
Final simplification64.9%
(FPCore (x y z)
:precision binary64
(if (<= x -1.25e+38)
(* 3.0 x)
(if (<= x -1.6e-190)
(+ y z)
(if (<= x -9.5e-238)
(+ y y)
(if (<= x 1.8e-177) (+ y z) (if (<= x 1.75e+109) (+ y y) (* 3.0 x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.25e+38) {
tmp = 3.0 * x;
} else if (x <= -1.6e-190) {
tmp = y + z;
} else if (x <= -9.5e-238) {
tmp = y + y;
} else if (x <= 1.8e-177) {
tmp = y + z;
} else if (x <= 1.75e+109) {
tmp = y + y;
} else {
tmp = 3.0 * 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 (x <= (-1.25d+38)) then
tmp = 3.0d0 * x
else if (x <= (-1.6d-190)) then
tmp = y + z
else if (x <= (-9.5d-238)) then
tmp = y + y
else if (x <= 1.8d-177) then
tmp = y + z
else if (x <= 1.75d+109) then
tmp = y + y
else
tmp = 3.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.25e+38) {
tmp = 3.0 * x;
} else if (x <= -1.6e-190) {
tmp = y + z;
} else if (x <= -9.5e-238) {
tmp = y + y;
} else if (x <= 1.8e-177) {
tmp = y + z;
} else if (x <= 1.75e+109) {
tmp = y + y;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.25e+38: tmp = 3.0 * x elif x <= -1.6e-190: tmp = y + z elif x <= -9.5e-238: tmp = y + y elif x <= 1.8e-177: tmp = y + z elif x <= 1.75e+109: tmp = y + y else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.25e+38) tmp = Float64(3.0 * x); elseif (x <= -1.6e-190) tmp = Float64(y + z); elseif (x <= -9.5e-238) tmp = Float64(y + y); elseif (x <= 1.8e-177) tmp = Float64(y + z); elseif (x <= 1.75e+109) tmp = Float64(y + y); else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.25e+38) tmp = 3.0 * x; elseif (x <= -1.6e-190) tmp = y + z; elseif (x <= -9.5e-238) tmp = y + y; elseif (x <= 1.8e-177) tmp = y + z; elseif (x <= 1.75e+109) tmp = y + y; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.25e+38], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, -1.6e-190], N[(y + z), $MachinePrecision], If[LessEqual[x, -9.5e-238], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.8e-177], N[(y + z), $MachinePrecision], If[LessEqual[x, 1.75e+109], N[(y + y), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+38}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-190}:\\
\;\;\;\;y + z\\
\mathbf{elif}\;x \leq -9.5 \cdot 10^{-238}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-177}:\\
\;\;\;\;y + z\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+109}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -1.24999999999999992e38 or 1.74999999999999992e109 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 67.1%
if -1.24999999999999992e38 < x < -1.6e-190 or -9.50000000000000059e-238 < x < 1.79999999999999991e-177Initial program 100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+r+100.0%
count-2100.0%
distribute-rgt1-in100.0%
fma-def100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 68.8%
+-commutative68.8%
fma-def68.7%
Simplified68.7%
Taylor expanded in x around 0 64.3%
+-commutative64.3%
Simplified64.3%
if -1.6e-190 < x < -9.50000000000000059e-238 or 1.79999999999999991e-177 < x < 1.74999999999999992e109Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
count-299.9%
distribute-rgt1-in99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 56.1%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (if (<= x -2e+71) (+ z (* 3.0 x)) (if (<= x 5e+39) (+ z (* y 2.0)) (+ x (* 2.0 (+ y x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2e+71) {
tmp = z + (3.0 * x);
} else if (x <= 5e+39) {
tmp = z + (y * 2.0);
} else {
tmp = x + (2.0 * (y + 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 (x <= (-2d+71)) then
tmp = z + (3.0d0 * x)
else if (x <= 5d+39) then
tmp = z + (y * 2.0d0)
else
tmp = x + (2.0d0 * (y + x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2e+71) {
tmp = z + (3.0 * x);
} else if (x <= 5e+39) {
tmp = z + (y * 2.0);
} else {
tmp = x + (2.0 * (y + x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2e+71: tmp = z + (3.0 * x) elif x <= 5e+39: tmp = z + (y * 2.0) else: tmp = x + (2.0 * (y + x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2e+71) tmp = Float64(z + Float64(3.0 * x)); elseif (x <= 5e+39) tmp = Float64(z + Float64(y * 2.0)); else tmp = Float64(x + Float64(2.0 * Float64(y + x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2e+71) tmp = z + (3.0 * x); elseif (x <= 5e+39) tmp = z + (y * 2.0); else tmp = x + (2.0 * (y + x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2e+71], N[(z + N[(3.0 * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e+39], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(2.0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+71}:\\
\;\;\;\;z + 3 \cdot x\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+39}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;x + 2 \cdot \left(y + x\right)\\
\end{array}
\end{array}
if x < -2.0000000000000001e71Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
count-299.8%
distribute-rgt1-in99.8%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 89.6%
+-commutative89.6%
fma-def89.7%
Simplified89.7%
Taylor expanded in y around 0 87.9%
if -2.0000000000000001e71 < x < 5.00000000000000015e39Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 94.5%
if 5.00000000000000015e39 < x Initial program 99.7%
+-commutative99.7%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in z around 0 85.3%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.1e+71) (+ y (+ z (* 3.0 x))) (if (<= x 3.8e+39) (+ z (* y 2.0)) (+ x (* 2.0 (+ y x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.1e+71) {
tmp = y + (z + (3.0 * x));
} else if (x <= 3.8e+39) {
tmp = z + (y * 2.0);
} else {
tmp = x + (2.0 * (y + 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 (x <= (-1.1d+71)) then
tmp = y + (z + (3.0d0 * x))
else if (x <= 3.8d+39) then
tmp = z + (y * 2.0d0)
else
tmp = x + (2.0d0 * (y + x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.1e+71) {
tmp = y + (z + (3.0 * x));
} else if (x <= 3.8e+39) {
tmp = z + (y * 2.0);
} else {
tmp = x + (2.0 * (y + x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.1e+71: tmp = y + (z + (3.0 * x)) elif x <= 3.8e+39: tmp = z + (y * 2.0) else: tmp = x + (2.0 * (y + x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.1e+71) tmp = Float64(y + Float64(z + Float64(3.0 * x))); elseif (x <= 3.8e+39) tmp = Float64(z + Float64(y * 2.0)); else tmp = Float64(x + Float64(2.0 * Float64(y + x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.1e+71) tmp = y + (z + (3.0 * x)); elseif (x <= 3.8e+39) tmp = z + (y * 2.0); else tmp = x + (2.0 * (y + x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.1e+71], N[(y + N[(z + N[(3.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e+39], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(2.0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+71}:\\
\;\;\;\;y + \left(z + 3 \cdot x\right)\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+39}:\\
\;\;\;\;z + y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;x + 2 \cdot \left(y + x\right)\\
\end{array}
\end{array}
if x < -1.09999999999999997e71Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
count-299.8%
distribute-rgt1-in99.8%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 89.6%
if -1.09999999999999997e71 < x < 3.7999999999999998e39Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 94.5%
if 3.7999999999999998e39 < x Initial program 99.7%
+-commutative99.7%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in z around 0 85.3%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (if (<= x -3.7e+36) (* 3.0 x) (if (<= x -5.2e-191) z (if (<= x 2.2e+109) (+ y y) (* 3.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.7e+36) {
tmp = 3.0 * x;
} else if (x <= -5.2e-191) {
tmp = z;
} else if (x <= 2.2e+109) {
tmp = y + y;
} else {
tmp = 3.0 * 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 (x <= (-3.7d+36)) then
tmp = 3.0d0 * x
else if (x <= (-5.2d-191)) then
tmp = z
else if (x <= 2.2d+109) then
tmp = y + y
else
tmp = 3.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.7e+36) {
tmp = 3.0 * x;
} else if (x <= -5.2e-191) {
tmp = z;
} else if (x <= 2.2e+109) {
tmp = y + y;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.7e+36: tmp = 3.0 * x elif x <= -5.2e-191: tmp = z elif x <= 2.2e+109: tmp = y + y else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.7e+36) tmp = Float64(3.0 * x); elseif (x <= -5.2e-191) tmp = z; elseif (x <= 2.2e+109) tmp = Float64(y + y); else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.7e+36) tmp = 3.0 * x; elseif (x <= -5.2e-191) tmp = z; elseif (x <= 2.2e+109) tmp = y + y; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.7e+36], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, -5.2e-191], z, If[LessEqual[x, 2.2e+109], N[(y + y), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{+36}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-191}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+109}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -3.70000000000000029e36 or 2.1999999999999999e109 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 66.5%
if -3.70000000000000029e36 < x < -5.19999999999999972e-191Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in z around inf 61.9%
if -5.19999999999999972e-191 < x < 2.1999999999999999e109Initial program 100.0%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+l+100.0%
+-commutative100.0%
associate-+r+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
count-299.9%
distribute-rgt1-in99.9%
fma-def100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 53.4%
Final simplification60.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.2e+72) (not (<= x 7.3e+146))) (+ y (* 3.0 x)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.2e+72) || !(x <= 7.3e+146)) {
tmp = y + (3.0 * x);
} 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 <= (-8.2d+72)) .or. (.not. (x <= 7.3d+146))) then
tmp = y + (3.0d0 * x)
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 <= -8.2e+72) || !(x <= 7.3e+146)) {
tmp = y + (3.0 * x);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.2e+72) or not (x <= 7.3e+146): tmp = y + (3.0 * x) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.2e+72) || !(x <= 7.3e+146)) tmp = Float64(y + Float64(3.0 * x)); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.2e+72) || ~((x <= 7.3e+146))) tmp = y + (3.0 * x); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.2e+72], N[Not[LessEqual[x, 7.3e+146]], $MachinePrecision]], N[(y + N[(3.0 * x), $MachinePrecision]), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+72} \lor \neg \left(x \leq 7.3 \cdot 10^{+146}\right):\\
\;\;\;\;y + 3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -8.19999999999999926e72 or 7.30000000000000034e146 < x Initial program 99.7%
associate-+l+99.7%
associate-+l+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.7%
associate-+l+99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
+-commutative99.7%
associate-+l+99.7%
+-commutative99.7%
associate-+r+99.7%
count-299.7%
distribute-rgt1-in99.7%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 87.3%
+-commutative87.3%
fma-def87.5%
Simplified87.5%
Taylor expanded in z around 0 74.1%
if -8.19999999999999926e72 < x < 7.30000000000000034e146Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 88.6%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.3e+71) (not (<= x 4.8e+109))) (+ z (* 3.0 x)) (+ z (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e+71) || !(x <= 4.8e+109)) {
tmp = z + (3.0 * x);
} 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 <= (-2.3d+71)) .or. (.not. (x <= 4.8d+109))) then
tmp = z + (3.0d0 * x)
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 <= -2.3e+71) || !(x <= 4.8e+109)) {
tmp = z + (3.0 * x);
} else {
tmp = z + (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.3e+71) or not (x <= 4.8e+109): tmp = z + (3.0 * x) else: tmp = z + (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.3e+71) || !(x <= 4.8e+109)) tmp = Float64(z + Float64(3.0 * x)); else tmp = Float64(z + Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.3e+71) || ~((x <= 4.8e+109))) tmp = z + (3.0 * x); else tmp = z + (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e+71], N[Not[LessEqual[x, 4.8e+109]], $MachinePrecision]], N[(z + N[(3.0 * x), $MachinePrecision]), $MachinePrecision], N[(z + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+71} \lor \neg \left(x \leq 4.8 \cdot 10^{+109}\right):\\
\;\;\;\;z + 3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot 2\\
\end{array}
\end{array}
if x < -2.3000000000000002e71 or 4.79999999999999975e109 < x Initial program 99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
associate-+r+99.8%
count-299.8%
distribute-rgt1-in99.8%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 86.9%
+-commutative86.9%
fma-def87.0%
Simplified87.0%
Taylor expanded in y around 0 84.6%
if -2.3000000000000002e71 < x < 4.79999999999999975e109Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around 0 90.4%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (+ x (+ z (* 2.0 (+ y x)))))
double code(double x, double y, double z) {
return x + (z + (2.0 * (y + 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 + (z + (2.0d0 * (y + x)))
end function
public static double code(double x, double y, double z) {
return x + (z + (2.0 * (y + x)));
}
def code(x, y, z): return x + (z + (2.0 * (y + x)))
function code(x, y, z) return Float64(x + Float64(z + Float64(2.0 * Float64(y + x)))) end
function tmp = code(x, y, z) tmp = x + (z + (2.0 * (y + x))); end
code[x_, y_, z_] := N[(x + N[(z + N[(2.0 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z + 2 \cdot \left(y + x\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 (if (<= x -3.6e+36) (* 3.0 x) (if (<= x 4.6e+38) z (* 3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e+36) {
tmp = 3.0 * x;
} else if (x <= 4.6e+38) {
tmp = z;
} else {
tmp = 3.0 * 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 (x <= (-3.6d+36)) then
tmp = 3.0d0 * x
else if (x <= 4.6d+38) then
tmp = z
else
tmp = 3.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e+36) {
tmp = 3.0 * x;
} else if (x <= 4.6e+38) {
tmp = z;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.6e+36: tmp = 3.0 * x elif x <= 4.6e+38: tmp = z else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.6e+36) tmp = Float64(3.0 * x); elseif (x <= 4.6e+38) tmp = z; else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.6e+36) tmp = 3.0 * x; elseif (x <= 4.6e+38) tmp = z; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.6e+36], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 4.6e+38], z, N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+36}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+38}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -3.5999999999999997e36 or 4.6000000000000002e38 < x Initial program 99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
count-299.8%
Simplified99.8%
Taylor expanded in x around inf 61.5%
if -3.5999999999999997e36 < x < 4.6000000000000002e38Initial program 100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in z around inf 50.6%
Final simplification56.1%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
associate-+r+99.9%
count-299.9%
distribute-rgt1-in99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 71.8%
+-commutative71.8%
fma-def71.9%
Simplified71.9%
Taylor expanded in y around inf 8.4%
Final simplification8.4%
(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 34.0%
Final simplification34.0%
herbie shell --seed 2023297
(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))