
(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 99.6%
remove-double-neg99.6%
neg-mul-199.6%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
(if (<= x -1.25e+89)
t_0
(if (<= x 6.4e-225)
t_1
(if (<= x 1.85e-137) -2.0 (if (<= x 7.6e+118) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -1.25e+89) {
tmp = t_0;
} else if (x <= 6.4e-225) {
tmp = t_1;
} else if (x <= 1.85e-137) {
tmp = -2.0;
} else if (x <= 7.6e+118) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (x * 4.0d0) / z
t_1 = (-4.0d0) * (y / z)
if (x <= (-1.25d+89)) then
tmp = t_0
else if (x <= 6.4d-225) then
tmp = t_1
else if (x <= 1.85d-137) then
tmp = -2.0d0
else if (x <= 7.6d+118) then
tmp = t_1
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 t_1 = -4.0 * (y / z);
double tmp;
if (x <= -1.25e+89) {
tmp = t_0;
} else if (x <= 6.4e-225) {
tmp = t_1;
} else if (x <= 1.85e-137) {
tmp = -2.0;
} else if (x <= 7.6e+118) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z t_1 = -4.0 * (y / z) tmp = 0 if x <= -1.25e+89: tmp = t_0 elif x <= 6.4e-225: tmp = t_1 elif x <= 1.85e-137: tmp = -2.0 elif x <= 7.6e+118: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -1.25e+89) tmp = t_0; elseif (x <= 6.4e-225) tmp = t_1; elseif (x <= 1.85e-137) tmp = -2.0; elseif (x <= 7.6e+118) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -1.25e+89) tmp = t_0; elseif (x <= 6.4e-225) tmp = t_1; elseif (x <= 1.85e-137) tmp = -2.0; elseif (x <= 7.6e+118) tmp = t_1; 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]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.25e+89], t$95$0, If[LessEqual[x, 6.4e-225], t$95$1, If[LessEqual[x, 1.85e-137], -2.0, If[LessEqual[x, 7.6e+118], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-225}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-137}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.24999999999999996e89 or 7.60000000000000033e118 < x Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.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%
Taylor expanded in x around inf 72.9%
*-commutative72.9%
associate-*l/72.9%
Simplified72.9%
if -1.24999999999999996e89 < x < 6.3999999999999995e-225 or 1.85e-137 < x < 7.60000000000000033e118Initial 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%
Taylor expanded in y around inf 56.2%
*-commutative56.2%
Simplified56.2%
if 6.3999999999999995e-225 < x < 1.85e-137Initial 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%
Taylor expanded in z around inf 73.0%
Final simplification63.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))) (t_1 (* -4.0 (/ y z))))
(if (<= x -5e+89)
t_0
(if (<= x 4.8e-230)
t_1
(if (<= x 1.8e-137) -2.0 (if (<= x 4.5e+117) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -5e+89) {
tmp = t_0;
} else if (x <= 4.8e-230) {
tmp = t_1;
} else if (x <= 1.8e-137) {
tmp = -2.0;
} else if (x <= 4.5e+117) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x * (4.0d0 / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-5d+89)) then
tmp = t_0
else if (x <= 4.8d-230) then
tmp = t_1
else if (x <= 1.8d-137) then
tmp = -2.0d0
else if (x <= 4.5d+117) then
tmp = t_1
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 t_1 = -4.0 * (y / z);
double tmp;
if (x <= -5e+89) {
tmp = t_0;
} else if (x <= 4.8e-230) {
tmp = t_1;
} else if (x <= 1.8e-137) {
tmp = -2.0;
} else if (x <= 4.5e+117) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -5e+89: tmp = t_0 elif x <= 4.8e-230: tmp = t_1 elif x <= 1.8e-137: tmp = -2.0 elif x <= 4.5e+117: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -5e+89) tmp = t_0; elseif (x <= 4.8e-230) tmp = t_1; elseif (x <= 1.8e-137) tmp = -2.0; elseif (x <= 4.5e+117) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -5e+89) tmp = t_0; elseif (x <= 4.8e-230) tmp = t_1; elseif (x <= 1.8e-137) tmp = -2.0; elseif (x <= 4.5e+117) tmp = t_1; 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]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+89], t$95$0, If[LessEqual[x, 4.8e-230], t$95$1, If[LessEqual[x, 1.8e-137], -2.0, If[LessEqual[x, 4.5e+117], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -5 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-230}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-137}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.99999999999999983e89 or 4.5e117 < x Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.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%
Taylor expanded in x around inf 72.9%
*-commutative72.9%
associate-*l/72.9%
Simplified72.9%
associate-/l*72.7%
*-commutative72.7%
Applied egg-rr72.7%
if -4.99999999999999983e89 < x < 4.8000000000000004e-230 or 1.80000000000000003e-137 < x < 4.5e117Initial 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%
Taylor expanded in y around inf 56.2%
*-commutative56.2%
Simplified56.2%
if 4.8000000000000004e-230 < x < 1.80000000000000003e-137Initial 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%
Taylor expanded in z around inf 73.0%
Final simplification63.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))) (t_1 (* y (/ -4.0 z))))
(if (<= x -7.6e+88)
t_0
(if (<= x 5.1e-229)
t_1
(if (<= x 3.4e-137) -2.0 (if (<= x 3e+117) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double t_1 = y * (-4.0 / z);
double tmp;
if (x <= -7.6e+88) {
tmp = t_0;
} else if (x <= 5.1e-229) {
tmp = t_1;
} else if (x <= 3.4e-137) {
tmp = -2.0;
} else if (x <= 3e+117) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x * (4.0d0 / z)
t_1 = y * ((-4.0d0) / z)
if (x <= (-7.6d+88)) then
tmp = t_0
else if (x <= 5.1d-229) then
tmp = t_1
else if (x <= 3.4d-137) then
tmp = -2.0d0
else if (x <= 3d+117) then
tmp = t_1
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 t_1 = y * (-4.0 / z);
double tmp;
if (x <= -7.6e+88) {
tmp = t_0;
} else if (x <= 5.1e-229) {
tmp = t_1;
} else if (x <= 3.4e-137) {
tmp = -2.0;
} else if (x <= 3e+117) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) t_1 = y * (-4.0 / z) tmp = 0 if x <= -7.6e+88: tmp = t_0 elif x <= 5.1e-229: tmp = t_1 elif x <= 3.4e-137: tmp = -2.0 elif x <= 3e+117: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) t_1 = Float64(y * Float64(-4.0 / z)) tmp = 0.0 if (x <= -7.6e+88) tmp = t_0; elseif (x <= 5.1e-229) tmp = t_1; elseif (x <= 3.4e-137) tmp = -2.0; elseif (x <= 3e+117) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); t_1 = y * (-4.0 / z); tmp = 0.0; if (x <= -7.6e+88) tmp = t_0; elseif (x <= 5.1e-229) tmp = t_1; elseif (x <= 3.4e-137) tmp = -2.0; elseif (x <= 3e+117) tmp = t_1; 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]}, Block[{t$95$1 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.6e+88], t$95$0, If[LessEqual[x, 5.1e-229], t$95$1, If[LessEqual[x, 3.4e-137], -2.0, If[LessEqual[x, 3e+117], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := y \cdot \frac{-4}{z}\\
\mathbf{if}\;x \leq -7.6 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-229}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-137}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.5999999999999993e88 or 3e117 < x Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.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%
Taylor expanded in x around inf 72.9%
*-commutative72.9%
associate-*l/72.9%
Simplified72.9%
associate-/l*72.7%
*-commutative72.7%
Applied egg-rr72.7%
if -7.5999999999999993e88 < x < 5.0999999999999999e-229 or 3.40000000000000014e-137 < x < 3e117Initial 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%
Taylor expanded in z around 0 66.6%
*-commutative66.6%
Simplified66.6%
Taylor expanded in y around inf 56.2%
*-commutative56.2%
associate-*l/56.2%
associate-*r/56.0%
Simplified56.0%
if 5.0999999999999999e-229 < x < 3.40000000000000014e-137Initial 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%
Taylor expanded in z around inf 73.0%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.2e+123) (not (<= z 7.8e+185))) (* 4.0 (+ -0.5 (/ x z))) (* -4.0 (/ (- y x) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e+123) || !(z <= 7.8e+185)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - x) / 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 <= (-5.2d+123)) .or. (.not. (z <= 7.8d+185))) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else
tmp = (-4.0d0) * ((y - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e+123) || !(z <= 7.8e+185)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.2e+123) or not (z <= 7.8e+185): tmp = 4.0 * (-0.5 + (x / z)) else: tmp = -4.0 * ((y - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.2e+123) || !(z <= 7.8e+185)) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.2e+123) || ~((z <= 7.8e+185))) tmp = 4.0 * (-0.5 + (x / z)); else tmp = -4.0 * ((y - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.2e+123], N[Not[LessEqual[z, 7.8e+185]], $MachinePrecision]], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+123} \lor \neg \left(z \leq 7.8 \cdot 10^{+185}\right):\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\end{array}
\end{array}
if z < -5.19999999999999971e123 or 7.7999999999999997e185 < z Initial program 98.5%
remove-double-neg98.5%
neg-mul-198.5%
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%
Taylor expanded in y around 0 89.6%
sub-neg89.6%
+-commutative89.6%
neg-sub089.6%
associate-+l-89.6%
neg-sub089.6%
neg-mul-189.6%
associate-*r*89.6%
metadata-eval89.6%
sub-neg89.6%
metadata-eval89.6%
Simplified89.6%
if -5.19999999999999971e123 < z < 7.7999999999999997e185Initial 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%
Taylor expanded in z around 0 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e+114) (not (<= y 7.2e+144))) (* -4.0 (/ y z)) (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+114) || !(y <= 7.2e+144)) {
tmp = -4.0 * (y / z);
} else {
tmp = 4.0 * (-0.5 + (x / 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 ((y <= (-4d+114)) .or. (.not. (y <= 7.2d+144))) then
tmp = (-4.0d0) * (y / z)
else
tmp = 4.0d0 * ((-0.5d0) + (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+114) || !(y <= 7.2e+144)) {
tmp = -4.0 * (y / z);
} else {
tmp = 4.0 * (-0.5 + (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e+114) or not (y <= 7.2e+144): tmp = -4.0 * (y / z) else: tmp = 4.0 * (-0.5 + (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e+114) || !(y <= 7.2e+144)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4e+114) || ~((y <= 7.2e+144))) tmp = -4.0 * (y / z); else tmp = 4.0 * (-0.5 + (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e+114], N[Not[LessEqual[y, 7.2e+144]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+114} \lor \neg \left(y \leq 7.2 \cdot 10^{+144}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -4e114 or 7.1999999999999995e144 < y Initial program 98.8%
remove-double-neg98.8%
neg-mul-198.8%
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 inf 80.1%
*-commutative80.1%
Simplified80.1%
if -4e114 < y < 7.1999999999999995e144Initial 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%
Taylor expanded in y around 0 83.0%
sub-neg83.0%
+-commutative83.0%
neg-sub083.0%
associate-+l-83.0%
neg-sub083.0%
neg-mul-183.0%
associate-*r*83.0%
metadata-eval83.0%
sub-neg83.0%
metadata-eval83.0%
Simplified83.0%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (if (<= x -9.2e+88) (* 4.0 (+ -0.5 (/ x z))) (if (<= x 5.5e+18) (+ (* -4.0 (/ y z)) -2.0) (* -4.0 (/ (- y x) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.2e+88) {
tmp = 4.0 * (-0.5 + (x / z));
} else if (x <= 5.5e+18) {
tmp = (-4.0 * (y / z)) + -2.0;
} else {
tmp = -4.0 * ((y - x) / 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 <= (-9.2d+88)) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else if (x <= 5.5d+18) then
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
else
tmp = (-4.0d0) * ((y - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.2e+88) {
tmp = 4.0 * (-0.5 + (x / z));
} else if (x <= 5.5e+18) {
tmp = (-4.0 * (y / z)) + -2.0;
} else {
tmp = -4.0 * ((y - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.2e+88: tmp = 4.0 * (-0.5 + (x / z)) elif x <= 5.5e+18: tmp = (-4.0 * (y / z)) + -2.0 else: tmp = -4.0 * ((y - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.2e+88) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); elseif (x <= 5.5e+18) tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); else tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9.2e+88) tmp = 4.0 * (-0.5 + (x / z)); elseif (x <= 5.5e+18) tmp = (-4.0 * (y / z)) + -2.0; else tmp = -4.0 * ((y - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.2e+88], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+18], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+88}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+18}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\end{array}
\end{array}
if x < -9.2000000000000007e88Initial program 98.1%
remove-double-neg98.1%
neg-mul-198.1%
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%
Taylor expanded in y around 0 87.0%
sub-neg87.0%
+-commutative87.0%
neg-sub087.0%
associate-+l-87.0%
neg-sub087.0%
neg-mul-187.0%
associate-*r*87.0%
metadata-eval87.0%
sub-neg87.0%
metadata-eval87.0%
Simplified87.0%
if -9.2000000000000007e88 < x < 5.5e18Initial 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%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
distribute-rgt-in92.1%
metadata-eval92.1%
Simplified92.1%
if 5.5e18 < x 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%
Taylor expanded in z around 0 87.7%
*-commutative87.7%
Simplified87.7%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.5e+117) -2.0 (if (<= z 7.8e+185) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+117) {
tmp = -2.0;
} else if (z <= 7.8e+185) {
tmp = y * (-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 (z <= (-1.5d+117)) then
tmp = -2.0d0
else if (z <= 7.8d+185) then
tmp = y * ((-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 (z <= -1.5e+117) {
tmp = -2.0;
} else if (z <= 7.8e+185) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.5e+117: tmp = -2.0 elif z <= 7.8e+185: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.5e+117) tmp = -2.0; elseif (z <= 7.8e+185) tmp = Float64(y * Float64(-4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.5e+117) tmp = -2.0; elseif (z <= 7.8e+185) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.5e+117], -2.0, If[LessEqual[z, 7.8e+185], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+117}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{+185}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.5e117 or 7.7999999999999997e185 < z Initial program 98.6%
remove-double-neg98.6%
neg-mul-198.6%
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%
Taylor expanded in z around inf 72.2%
if -1.5e117 < z < 7.7999999999999997e185Initial 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%
Taylor expanded in z around 0 85.8%
*-commutative85.8%
Simplified85.8%
Taylor expanded in y around inf 49.6%
*-commutative49.6%
associate-*l/49.6%
associate-*r/49.5%
Simplified49.5%
(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 99.6%
remove-double-neg99.6%
neg-mul-199.6%
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%
Taylor expanded in z around inf 30.6%
(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 2024144
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z)))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))