
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (* -4.0 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))) (t_1 (* x (/ 4.0 z))))
(if (<= x -7.5e+43)
t_1
(if (<= x 4e-288)
-2.0
(if (<= x 5.7e-245)
t_0
(if (<= x 4.8e-144) -2.0 (if (<= x 5.8e+62) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = x * (4.0 / z);
double tmp;
if (x <= -7.5e+43) {
tmp = t_1;
} else if (x <= 4e-288) {
tmp = -2.0;
} else if (x <= 5.7e-245) {
tmp = t_0;
} else if (x <= 4.8e-144) {
tmp = -2.0;
} else if (x <= 5.8e+62) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = y * ((-4.0d0) / z)
t_1 = x * (4.0d0 / z)
if (x <= (-7.5d+43)) then
tmp = t_1
else if (x <= 4d-288) then
tmp = -2.0d0
else if (x <= 5.7d-245) then
tmp = t_0
else if (x <= 4.8d-144) then
tmp = -2.0d0
else if (x <= 5.8d+62) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = x * (4.0 / z);
double tmp;
if (x <= -7.5e+43) {
tmp = t_1;
} else if (x <= 4e-288) {
tmp = -2.0;
} else if (x <= 5.7e-245) {
tmp = t_0;
} else if (x <= 4.8e-144) {
tmp = -2.0;
} else if (x <= 5.8e+62) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) t_1 = x * (4.0 / z) tmp = 0 if x <= -7.5e+43: tmp = t_1 elif x <= 4e-288: tmp = -2.0 elif x <= 5.7e-245: tmp = t_0 elif x <= 4.8e-144: tmp = -2.0 elif x <= 5.8e+62: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-4.0 / z)) t_1 = Float64(x * Float64(4.0 / z)) tmp = 0.0 if (x <= -7.5e+43) tmp = t_1; elseif (x <= 4e-288) tmp = -2.0; elseif (x <= 5.7e-245) tmp = t_0; elseif (x <= 4.8e-144) tmp = -2.0; elseif (x <= 5.8e+62) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (-4.0 / z); t_1 = x * (4.0 / z); tmp = 0.0; if (x <= -7.5e+43) tmp = t_1; elseif (x <= 4e-288) tmp = -2.0; elseif (x <= 5.7e-245) tmp = t_0; elseif (x <= 4.8e-144) tmp = -2.0; elseif (x <= 5.8e+62) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.5e+43], t$95$1, If[LessEqual[x, 4e-288], -2.0, If[LessEqual[x, 5.7e-245], t$95$0, If[LessEqual[x, 4.8e-144], -2.0, If[LessEqual[x, 5.8e+62], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
t_1 := x \cdot \frac{4}{z}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-288}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-245}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-144}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.49999999999999967e43 or 5.79999999999999968e62 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 68.7%
associate-*r/68.7%
associate-*l/68.5%
*-commutative68.5%
Simplified68.5%
if -7.49999999999999967e43 < x < 4.00000000000000023e-288 or 5.7000000000000001e-245 < x < 4.79999999999999988e-144Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 60.8%
if 4.00000000000000023e-288 < x < 5.7000000000000001e-245 or 4.79999999999999988e-144 < x < 5.79999999999999968e62Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 66.7%
*-commutative66.7%
Simplified66.7%
Taylor expanded in y around 0 66.7%
associate-*r/66.7%
*-commutative66.7%
associate-*r/66.6%
Simplified66.6%
Final simplification65.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))))
(if (<= x -1.7e+42)
t_0
(if (<= x 2.22e-287)
-2.0
(if (<= x 6e-245)
(* y (/ -4.0 z))
(if (<= x 1.05e-151)
-2.0
(if (<= x 8.8e+63) (* -4.0 (/ y z)) t_0)))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double tmp;
if (x <= -1.7e+42) {
tmp = t_0;
} else if (x <= 2.22e-287) {
tmp = -2.0;
} else if (x <= 6e-245) {
tmp = y * (-4.0 / z);
} else if (x <= 1.05e-151) {
tmp = -2.0;
} else if (x <= 8.8e+63) {
tmp = -4.0 * (y / z);
} 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 = x * (4.0d0 / z)
if (x <= (-1.7d+42)) then
tmp = t_0
else if (x <= 2.22d-287) then
tmp = -2.0d0
else if (x <= 6d-245) then
tmp = y * ((-4.0d0) / z)
else if (x <= 1.05d-151) then
tmp = -2.0d0
else if (x <= 8.8d+63) then
tmp = (-4.0d0) * (y / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double tmp;
if (x <= -1.7e+42) {
tmp = t_0;
} else if (x <= 2.22e-287) {
tmp = -2.0;
} else if (x <= 6e-245) {
tmp = y * (-4.0 / z);
} else if (x <= 1.05e-151) {
tmp = -2.0;
} else if (x <= 8.8e+63) {
tmp = -4.0 * (y / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) tmp = 0 if x <= -1.7e+42: tmp = t_0 elif x <= 2.22e-287: tmp = -2.0 elif x <= 6e-245: tmp = y * (-4.0 / z) elif x <= 1.05e-151: tmp = -2.0 elif x <= 8.8e+63: tmp = -4.0 * (y / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) tmp = 0.0 if (x <= -1.7e+42) tmp = t_0; elseif (x <= 2.22e-287) tmp = -2.0; elseif (x <= 6e-245) tmp = Float64(y * Float64(-4.0 / z)); elseif (x <= 1.05e-151) tmp = -2.0; elseif (x <= 8.8e+63) tmp = Float64(-4.0 * Float64(y / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); tmp = 0.0; if (x <= -1.7e+42) tmp = t_0; elseif (x <= 2.22e-287) tmp = -2.0; elseif (x <= 6e-245) tmp = y * (-4.0 / z); elseif (x <= 1.05e-151) tmp = -2.0; elseif (x <= 8.8e+63) tmp = -4.0 * (y / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e+42], t$95$0, If[LessEqual[x, 2.22e-287], -2.0, If[LessEqual[x, 6e-245], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e-151], -2.0, If[LessEqual[x, 8.8e+63], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.22 \cdot 10^{-287}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-245}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-151}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+63}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.69999999999999988e42 or 8.7999999999999995e63 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 68.7%
associate-*r/68.7%
associate-*l/68.5%
*-commutative68.5%
Simplified68.5%
if -1.69999999999999988e42 < x < 2.21999999999999999e-287 or 6.0000000000000004e-245 < x < 1.04999999999999995e-151Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 60.8%
if 2.21999999999999999e-287 < x < 6.0000000000000004e-245Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in y around inf 89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in y around 0 89.2%
associate-*r/89.2%
*-commutative89.2%
associate-*r/89.2%
Simplified89.2%
if 1.04999999999999995e-151 < x < 8.7999999999999995e63Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 61.2%
*-commutative61.2%
Simplified61.2%
Final simplification65.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)))
(if (<= x -1.4e+44)
t_0
(if (<= x 7.5e-288)
-2.0
(if (<= x 4.6e-245)
(* y (/ -4.0 z))
(if (<= x 2.45e-158)
-2.0
(if (<= x 1.22e+63) (* -4.0 (/ y z)) t_0)))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double tmp;
if (x <= -1.4e+44) {
tmp = t_0;
} else if (x <= 7.5e-288) {
tmp = -2.0;
} else if (x <= 4.6e-245) {
tmp = y * (-4.0 / z);
} else if (x <= 2.45e-158) {
tmp = -2.0;
} else if (x <= 1.22e+63) {
tmp = -4.0 * (y / z);
} 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 = (x * 4.0d0) / z
if (x <= (-1.4d+44)) then
tmp = t_0
else if (x <= 7.5d-288) then
tmp = -2.0d0
else if (x <= 4.6d-245) then
tmp = y * ((-4.0d0) / z)
else if (x <= 2.45d-158) then
tmp = -2.0d0
else if (x <= 1.22d+63) then
tmp = (-4.0d0) * (y / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double tmp;
if (x <= -1.4e+44) {
tmp = t_0;
} else if (x <= 7.5e-288) {
tmp = -2.0;
} else if (x <= 4.6e-245) {
tmp = y * (-4.0 / z);
} else if (x <= 2.45e-158) {
tmp = -2.0;
} else if (x <= 1.22e+63) {
tmp = -4.0 * (y / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z tmp = 0 if x <= -1.4e+44: tmp = t_0 elif x <= 7.5e-288: tmp = -2.0 elif x <= 4.6e-245: tmp = y * (-4.0 / z) elif x <= 2.45e-158: tmp = -2.0 elif x <= 1.22e+63: tmp = -4.0 * (y / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (x <= -1.4e+44) tmp = t_0; elseif (x <= 7.5e-288) tmp = -2.0; elseif (x <= 4.6e-245) tmp = Float64(y * Float64(-4.0 / z)); elseif (x <= 2.45e-158) tmp = -2.0; elseif (x <= 1.22e+63) tmp = Float64(-4.0 * Float64(y / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; tmp = 0.0; if (x <= -1.4e+44) tmp = t_0; elseif (x <= 7.5e-288) tmp = -2.0; elseif (x <= 4.6e-245) tmp = y * (-4.0 / z); elseif (x <= 2.45e-158) tmp = -2.0; elseif (x <= 1.22e+63) tmp = -4.0 * (y / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -1.4e+44], t$95$0, If[LessEqual[x, 7.5e-288], -2.0, If[LessEqual[x, 4.6e-245], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.45e-158], -2.0, If[LessEqual[x, 1.22e+63], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-288}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-245}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{-158}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{+63}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.4e44 or 1.2199999999999999e63 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 68.7%
associate-*r/68.7%
*-commutative68.7%
Simplified68.7%
if -1.4e44 < x < 7.4999999999999998e-288 or 4.6000000000000003e-245 < x < 2.44999999999999997e-158Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 60.8%
if 7.4999999999999998e-288 < x < 4.6000000000000003e-245Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in y around inf 89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in y around 0 89.2%
associate-*r/89.2%
*-commutative89.2%
associate-*r/89.2%
Simplified89.2%
if 2.44999999999999997e-158 < x < 1.2199999999999999e63Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 61.2%
*-commutative61.2%
Simplified61.2%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.2e+21) (not (<= y 2.05e-37))) (* 4.0 (- -0.5 (/ y z))) (* -4.0 (- (/ x (- z)) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.2e+21) || !(y <= 2.05e-37)) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = -4.0 * ((x / -z) - -0.5);
}
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 <= (-7.2d+21)) .or. (.not. (y <= 2.05d-37))) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = (-4.0d0) * ((x / -z) - (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.2e+21) || !(y <= 2.05e-37)) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = -4.0 * ((x / -z) - -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.2e+21) or not (y <= 2.05e-37): tmp = 4.0 * (-0.5 - (y / z)) else: tmp = -4.0 * ((x / -z) - -0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.2e+21) || !(y <= 2.05e-37)) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(-4.0 * Float64(Float64(x / Float64(-z)) - -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.2e+21) || ~((y <= 2.05e-37))) tmp = 4.0 * (-0.5 - (y / z)); else tmp = -4.0 * ((x / -z) - -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.2e+21], N[Not[LessEqual[y, 2.05e-37]], $MachinePrecision]], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(x / (-z)), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+21} \lor \neg \left(y \leq 2.05 \cdot 10^{-37}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\frac{x}{-z} - -0.5\right)\\
\end{array}
\end{array}
if y < -7.2e21 or 2.0499999999999999e-37 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 84.1%
associate-*r/84.1%
metadata-eval84.1%
+-commutative84.1%
*-commutative84.1%
fma-undefine84.1%
associate-*r*84.1%
neg-mul-184.1%
associate-/l*84.1%
fma-undefine84.1%
*-commutative84.1%
distribute-neg-in84.1%
sub-neg84.1%
div-sub84.1%
distribute-neg-frac84.1%
associate-/l*84.1%
*-inverses84.1%
metadata-eval84.1%
metadata-eval84.1%
Simplified84.1%
if -7.2e21 < y < 2.0499999999999999e-37Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.4%
neg-mul-197.4%
distribute-neg-frac97.4%
Simplified97.4%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.22e+173) (not (<= x 8.6e+161))) (/ (* x 4.0) z) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e+173) || !(x <= 8.6e+161)) {
tmp = (x * 4.0) / z;
} else {
tmp = 4.0 * (-0.5 - (y / 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 ((x <= (-1.22d+173)) .or. (.not. (x <= 8.6d+161))) then
tmp = (x * 4.0d0) / z
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e+173) || !(x <= 8.6e+161)) {
tmp = (x * 4.0) / z;
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.22e+173) or not (x <= 8.6e+161): tmp = (x * 4.0) / z else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.22e+173) || !(x <= 8.6e+161)) tmp = Float64(Float64(x * 4.0) / z); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.22e+173) || ~((x <= 8.6e+161))) tmp = (x * 4.0) / z; else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.22e+173], N[Not[LessEqual[x, 8.6e+161]], $MachinePrecision]], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{+173} \lor \neg \left(x \leq 8.6 \cdot 10^{+161}\right):\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -1.22e173 or 8.6e161 < x Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 88.6%
associate-*r/88.6%
*-commutative88.6%
Simplified88.6%
if -1.22e173 < x < 8.6e161Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 83.4%
associate-*r/83.4%
metadata-eval83.4%
+-commutative83.4%
*-commutative83.4%
fma-undefine83.4%
associate-*r*83.4%
neg-mul-183.4%
associate-/l*83.4%
fma-undefine83.4%
*-commutative83.4%
distribute-neg-in83.4%
sub-neg83.4%
div-sub83.4%
distribute-neg-frac83.4%
associate-/l*83.4%
*-inverses83.4%
metadata-eval83.4%
metadata-eval83.4%
Simplified83.4%
Final simplification84.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -4e+41) (not (<= x 5.3e-67))) (* 4.0 (/ (- x y) z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+41) || !(x <= 5.3e-67)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = 4.0 * (-0.5 - (y / 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 ((x <= (-4d+41)) .or. (.not. (x <= 5.3d-67))) then
tmp = 4.0d0 * ((x - y) / z)
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+41) || !(x <= 5.3e-67)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+41) or not (x <= 5.3e-67): tmp = 4.0 * ((x - y) / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+41) || !(x <= 5.3e-67)) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4e+41) || ~((x <= 5.3e-67))) tmp = 4.0 * ((x - y) / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+41], N[Not[LessEqual[x, 5.3e-67]], $MachinePrecision]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+41} \lor \neg \left(x \leq 5.3 \cdot 10^{-67}\right):\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -4.00000000000000002e41 or 5.29999999999999971e-67 < x Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around 0 85.1%
if -4.00000000000000002e41 < x < 5.29999999999999971e-67Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 92.7%
associate-*r/92.7%
metadata-eval92.7%
+-commutative92.7%
*-commutative92.7%
fma-undefine92.7%
associate-*r*92.7%
neg-mul-192.7%
associate-/l*92.7%
fma-undefine92.7%
*-commutative92.7%
distribute-neg-in92.7%
sub-neg92.7%
div-sub92.7%
distribute-neg-frac92.7%
associate-/l*92.7%
*-inverses92.7%
metadata-eval92.7%
metadata-eval92.7%
Simplified92.7%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e+40) (not (<= x 5.3e-67))) (* x (/ 4.0 z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+40) || !(x <= 5.3e-67)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-5.5d+40)) .or. (.not. (x <= 5.3d-67))) then
tmp = x * (4.0d0 / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+40) || !(x <= 5.3e-67)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+40) or not (x <= 5.3e-67): tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+40) || !(x <= 5.3e-67)) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e+40) || ~((x <= 5.3e-67))) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+40], N[Not[LessEqual[x, 5.3e-67]], $MachinePrecision]], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+40} \lor \neg \left(x \leq 5.3 \cdot 10^{-67}\right):\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -5.49999999999999974e40 or 5.29999999999999971e-67 < x Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 61.3%
associate-*r/61.3%
associate-*l/61.2%
*-commutative61.2%
Simplified61.2%
if -5.49999999999999974e40 < x < 5.29999999999999971e-67Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 54.7%
Final simplification57.9%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 35.1%
Final simplification35.1%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * (x / z)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2024039
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:herbie-target
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))