
(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 10 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 (/ (- x y) z)) 2.0))
double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 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 = (4.0d0 * ((x - y) / z)) - 2.0d0
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 2.0;
}
def code(x, y, z): return (4.0 * ((x - y) / z)) - 2.0
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) / z)) - 2.0) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) / z)) - 2.0; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x - y}{z} - 2
\end{array}
Initial program 99.6%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.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.6e-7)
t_1
(if (<= x 1e-215)
-2.0
(if (<= x 1.05e-116)
t_0
(if (<= x 2.5e-44) -2.0 (if (<= x 3.1e+105) 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.6e-7) {
tmp = t_1;
} else if (x <= 1e-215) {
tmp = -2.0;
} else if (x <= 1.05e-116) {
tmp = t_0;
} else if (x <= 2.5e-44) {
tmp = -2.0;
} else if (x <= 3.1e+105) {
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.6d-7)) then
tmp = t_1
else if (x <= 1d-215) then
tmp = -2.0d0
else if (x <= 1.05d-116) then
tmp = t_0
else if (x <= 2.5d-44) then
tmp = -2.0d0
else if (x <= 3.1d+105) 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.6e-7) {
tmp = t_1;
} else if (x <= 1e-215) {
tmp = -2.0;
} else if (x <= 1.05e-116) {
tmp = t_0;
} else if (x <= 2.5e-44) {
tmp = -2.0;
} else if (x <= 3.1e+105) {
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.6e-7: tmp = t_1 elif x <= 1e-215: tmp = -2.0 elif x <= 1.05e-116: tmp = t_0 elif x <= 2.5e-44: tmp = -2.0 elif x <= 3.1e+105: 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.6e-7) tmp = t_1; elseif (x <= 1e-215) tmp = -2.0; elseif (x <= 1.05e-116) tmp = t_0; elseif (x <= 2.5e-44) tmp = -2.0; elseif (x <= 3.1e+105) 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.6e-7) tmp = t_1; elseif (x <= 1e-215) tmp = -2.0; elseif (x <= 1.05e-116) tmp = t_0; elseif (x <= 2.5e-44) tmp = -2.0; elseif (x <= 3.1e+105) 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.6e-7], t$95$1, If[LessEqual[x, 1e-215], -2.0, If[LessEqual[x, 1.05e-116], t$95$0, If[LessEqual[x, 2.5e-44], -2.0, If[LessEqual[x, 3.1e+105], 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.6 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 10^{-215}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-116}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-44}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -7.60000000000000029e-7 or 3.10000000000000004e105 < x Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
associate-+l-99.6%
*-commutative99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
fma-udef99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 76.0%
associate-/r/76.0%
Applied egg-rr76.0%
if -7.60000000000000029e-7 < x < 1.00000000000000004e-215 or 1.05e-116 < x < 2.50000000000000019e-44Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 55.3%
if 1.00000000000000004e-215 < x < 1.05e-116 or 2.50000000000000019e-44 < x < 3.10000000000000004e105Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
associate-+l-99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
fma-udef99.8%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 58.8%
associate-*r/58.8%
*-rgt-identity58.8%
times-frac58.7%
/-rgt-identity58.7%
Simplified58.7%
Final simplification64.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))) (t_1 (* 4.0 (/ x z))))
(if (<= x -4.7e-6)
t_1
(if (<= x 1.5e-215)
-2.0
(if (<= x 4.4e-113)
t_0
(if (<= x 3.5e-47) -2.0 (if (<= x 3.8e+105) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (x <= -4.7e-6) {
tmp = t_1;
} else if (x <= 1.5e-215) {
tmp = -2.0;
} else if (x <= 4.4e-113) {
tmp = t_0;
} else if (x <= 3.5e-47) {
tmp = -2.0;
} else if (x <= 3.8e+105) {
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 = 4.0d0 * (x / z)
if (x <= (-4.7d-6)) then
tmp = t_1
else if (x <= 1.5d-215) then
tmp = -2.0d0
else if (x <= 4.4d-113) then
tmp = t_0
else if (x <= 3.5d-47) then
tmp = -2.0d0
else if (x <= 3.8d+105) 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 = 4.0 * (x / z);
double tmp;
if (x <= -4.7e-6) {
tmp = t_1;
} else if (x <= 1.5e-215) {
tmp = -2.0;
} else if (x <= 4.4e-113) {
tmp = t_0;
} else if (x <= 3.5e-47) {
tmp = -2.0;
} else if (x <= 3.8e+105) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) t_1 = 4.0 * (x / z) tmp = 0 if x <= -4.7e-6: tmp = t_1 elif x <= 1.5e-215: tmp = -2.0 elif x <= 4.4e-113: tmp = t_0 elif x <= 3.5e-47: tmp = -2.0 elif x <= 3.8e+105: 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(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -4.7e-6) tmp = t_1; elseif (x <= 1.5e-215) tmp = -2.0; elseif (x <= 4.4e-113) tmp = t_0; elseif (x <= 3.5e-47) tmp = -2.0; elseif (x <= 3.8e+105) 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 = 4.0 * (x / z); tmp = 0.0; if (x <= -4.7e-6) tmp = t_1; elseif (x <= 1.5e-215) tmp = -2.0; elseif (x <= 4.4e-113) tmp = t_0; elseif (x <= 3.5e-47) tmp = -2.0; elseif (x <= 3.8e+105) 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[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e-6], t$95$1, If[LessEqual[x, 1.5e-215], -2.0, If[LessEqual[x, 4.4e-113], t$95$0, If[LessEqual[x, 3.5e-47], -2.0, If[LessEqual[x, 3.8e+105], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{-6}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-215}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-113}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-47}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -4.69999999999999989e-6 or 3.8e105 < x Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -4.69999999999999989e-6 < x < 1.50000000000000013e-215 or 4.40000000000000008e-113 < x < 3.4999999999999998e-47Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 55.3%
if 1.50000000000000013e-215 < x < 4.40000000000000008e-113 or 3.4999999999999998e-47 < x < 3.8e105Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
associate-+l-99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
fma-udef99.8%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 58.8%
associate-*r/58.8%
*-rgt-identity58.8%
times-frac58.7%
/-rgt-identity58.7%
Simplified58.7%
Final simplification64.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))))
(if (<= x -7.8e-7)
t_0
(if (<= x 5.2e-208)
-2.0
(if (<= x 1e-111)
(* y (/ -4.0 z))
(if (<= x 2.1e-43) -2.0 (if (<= x 3e+106) (/ -4.0 (/ z y)) t_0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double tmp;
if (x <= -7.8e-7) {
tmp = t_0;
} else if (x <= 5.2e-208) {
tmp = -2.0;
} else if (x <= 1e-111) {
tmp = y * (-4.0 / z);
} else if (x <= 2.1e-43) {
tmp = -2.0;
} else if (x <= 3e+106) {
tmp = -4.0 / (z / 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 = 4.0d0 * (x / z)
if (x <= (-7.8d-7)) then
tmp = t_0
else if (x <= 5.2d-208) then
tmp = -2.0d0
else if (x <= 1d-111) then
tmp = y * ((-4.0d0) / z)
else if (x <= 2.1d-43) then
tmp = -2.0d0
else if (x <= 3d+106) then
tmp = (-4.0d0) / (z / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double tmp;
if (x <= -7.8e-7) {
tmp = t_0;
} else if (x <= 5.2e-208) {
tmp = -2.0;
} else if (x <= 1e-111) {
tmp = y * (-4.0 / z);
} else if (x <= 2.1e-43) {
tmp = -2.0;
} else if (x <= 3e+106) {
tmp = -4.0 / (z / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) tmp = 0 if x <= -7.8e-7: tmp = t_0 elif x <= 5.2e-208: tmp = -2.0 elif x <= 1e-111: tmp = y * (-4.0 / z) elif x <= 2.1e-43: tmp = -2.0 elif x <= 3e+106: tmp = -4.0 / (z / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -7.8e-7) tmp = t_0; elseif (x <= 5.2e-208) tmp = -2.0; elseif (x <= 1e-111) tmp = Float64(y * Float64(-4.0 / z)); elseif (x <= 2.1e-43) tmp = -2.0; elseif (x <= 3e+106) tmp = Float64(-4.0 / Float64(z / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); tmp = 0.0; if (x <= -7.8e-7) tmp = t_0; elseif (x <= 5.2e-208) tmp = -2.0; elseif (x <= 1e-111) tmp = y * (-4.0 / z); elseif (x <= 2.1e-43) tmp = -2.0; elseif (x <= 3e+106) tmp = -4.0 / (z / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.8e-7], t$95$0, If[LessEqual[x, 5.2e-208], -2.0, If[LessEqual[x, 1e-111], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1e-43], -2.0, If[LessEqual[x, 3e+106], N[(-4.0 / N[(z / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-208}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 10^{-111}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-43}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+106}:\\
\;\;\;\;\frac{-4}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.80000000000000049e-7 or 3.0000000000000001e106 < x Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -7.80000000000000049e-7 < x < 5.20000000000000034e-208 or 1.00000000000000009e-111 < x < 2.1000000000000001e-43Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 55.3%
if 5.20000000000000034e-208 < x < 1.00000000000000009e-111Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
associate-+l-99.7%
*-commutative99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-commutative99.7%
+-commutative99.7%
fma-udef99.7%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around inf 63.7%
associate-*r/63.7%
*-rgt-identity63.7%
times-frac63.7%
/-rgt-identity63.7%
Simplified63.7%
if 2.1000000000000001e-43 < x < 3.0000000000000001e106Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
associate-+l-99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
fma-udef99.8%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 55.2%
associate-*r/55.2%
*-rgt-identity55.2%
times-frac55.0%
/-rgt-identity55.0%
Simplified55.0%
associate-*l/55.2%
associate-/l*55.2%
Applied egg-rr55.2%
Final simplification64.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* y -4.0) z)) (t_1 (* 4.0 (/ x z))))
(if (<= x -3.4e-8)
t_1
(if (<= x 1.2e-211)
-2.0
(if (<= x 9.8e-114)
t_0
(if (<= x 3.3e-43) -2.0 (if (<= x 3e+106) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (y * -4.0) / z;
double t_1 = 4.0 * (x / z);
double tmp;
if (x <= -3.4e-8) {
tmp = t_1;
} else if (x <= 1.2e-211) {
tmp = -2.0;
} else if (x <= 9.8e-114) {
tmp = t_0;
} else if (x <= 3.3e-43) {
tmp = -2.0;
} else if (x <= 3e+106) {
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 = 4.0d0 * (x / z)
if (x <= (-3.4d-8)) then
tmp = t_1
else if (x <= 1.2d-211) then
tmp = -2.0d0
else if (x <= 9.8d-114) then
tmp = t_0
else if (x <= 3.3d-43) then
tmp = -2.0d0
else if (x <= 3d+106) 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 = 4.0 * (x / z);
double tmp;
if (x <= -3.4e-8) {
tmp = t_1;
} else if (x <= 1.2e-211) {
tmp = -2.0;
} else if (x <= 9.8e-114) {
tmp = t_0;
} else if (x <= 3.3e-43) {
tmp = -2.0;
} else if (x <= 3e+106) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (y * -4.0) / z t_1 = 4.0 * (x / z) tmp = 0 if x <= -3.4e-8: tmp = t_1 elif x <= 1.2e-211: tmp = -2.0 elif x <= 9.8e-114: tmp = t_0 elif x <= 3.3e-43: tmp = -2.0 elif x <= 3e+106: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * -4.0) / z) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -3.4e-8) tmp = t_1; elseif (x <= 1.2e-211) tmp = -2.0; elseif (x <= 9.8e-114) tmp = t_0; elseif (x <= 3.3e-43) tmp = -2.0; elseif (x <= 3e+106) 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 = 4.0 * (x / z); tmp = 0.0; if (x <= -3.4e-8) tmp = t_1; elseif (x <= 1.2e-211) tmp = -2.0; elseif (x <= 9.8e-114) tmp = t_0; elseif (x <= 3.3e-43) tmp = -2.0; elseif (x <= 3e+106) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.4e-8], t$95$1, If[LessEqual[x, 1.2e-211], -2.0, If[LessEqual[x, 9.8e-114], t$95$0, If[LessEqual[x, 3.3e-43], -2.0, If[LessEqual[x, 3e+106], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot -4}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-211}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-114}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-43}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+106}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.4e-8 or 3.0000000000000001e106 < x Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -3.4e-8 < x < 1.2000000000000001e-211 or 9.7999999999999994e-114 < x < 3.30000000000000016e-43Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 55.3%
if 1.2000000000000001e-211 < x < 9.7999999999999994e-114 or 3.30000000000000016e-43 < x < 3.0000000000000001e106Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 58.8%
associate-*r/58.8%
Simplified58.8%
Final simplification64.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.6e-8) (not (<= x 0.029))) (* 4.0 (/ (- x y) z)) (- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.6e-8) || !(x <= 0.029)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = (-4.0 * (y / z)) - 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.6d-8)) .or. (.not. (x <= 0.029d0))) then
tmp = 4.0d0 * ((x - y) / z)
else
tmp = ((-4.0d0) * (y / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.6e-8) || !(x <= 0.029)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.6e-8) or not (x <= 0.029): tmp = 4.0 * ((x - y) / z) else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.6e-8) || !(x <= 0.029)) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.6e-8) || ~((x <= 0.029))) tmp = 4.0 * ((x - y) / z); else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.6e-8], N[Not[LessEqual[x, 0.029]], $MachinePrecision]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{-8} \lor \neg \left(x \leq 0.029\right):\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -8.6000000000000002e-8 or 0.0290000000000000015 < x Initial program 99.1%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 86.3%
if -8.6000000000000002e-8 < x < 0.0290000000000000015Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.0%
Taylor expanded in x around 0 89.5%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+59) (not (<= z 4.5e-52))) (- (* 4.0 (/ x z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+59) || !(z <= 4.5e-52)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = 4.0 * ((x - 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 ((z <= (-2d+59)) .or. (.not. (z <= 4.5d-52))) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else
tmp = 4.0d0 * ((x - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+59) || !(z <= 4.5e-52)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+59) or not (z <= 4.5e-52): tmp = (4.0 * (x / z)) - 2.0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+59) || !(z <= 4.5e-52)) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); else tmp = Float64(4.0 * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+59) || ~((z <= 4.5e-52))) tmp = (4.0 * (x / z)) - 2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+59], N[Not[LessEqual[z, 4.5e-52]], $MachinePrecision]], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+59} \lor \neg \left(z \leq 4.5 \cdot 10^{-52}\right):\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -1.99999999999999994e59 or 4.5e-52 < z Initial program 99.2%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around 0 100.0%
Taylor expanded in x around inf 82.8%
if -1.99999999999999994e59 < z < 4.5e-52Initial program 100.0%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 94.8%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= z -2.7e+181) -2.0 (if (<= z 1.4e+114) (* 4.0 (/ (- x y) z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.7e+181) {
tmp = -2.0;
} else if (z <= 1.4e+114) {
tmp = 4.0 * ((x - y) / 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 <= (-2.7d+181)) then
tmp = -2.0d0
else if (z <= 1.4d+114) then
tmp = 4.0d0 * ((x - y) / 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 <= -2.7e+181) {
tmp = -2.0;
} else if (z <= 1.4e+114) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.7e+181: tmp = -2.0 elif z <= 1.4e+114: tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.7e+181) tmp = -2.0; elseif (z <= 1.4e+114) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.7e+181) tmp = -2.0; elseif (z <= 1.4e+114) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.7e+181], -2.0, If[LessEqual[z, 1.4e+114], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+181}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+114}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.70000000000000007e181 or 1.4e114 < z Initial program 98.6%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 78.0%
if -2.70000000000000007e181 < z < 1.4e114Initial program 100.0%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 85.2%
Final simplification83.2%
(FPCore (x y z) :precision binary64 (if (<= z -2e+55) -2.0 (if (<= z 7.4e-53) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+55) {
tmp = -2.0;
} else if (z <= 7.4e-53) {
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 <= (-2d+55)) then
tmp = -2.0d0
else if (z <= 7.4d-53) 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 <= -2e+55) {
tmp = -2.0;
} else if (z <= 7.4e-53) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e+55: tmp = -2.0 elif z <= 7.4e-53: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e+55) tmp = -2.0; elseif (z <= 7.4e-53) 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 <= -2e+55) tmp = -2.0; elseif (z <= 7.4e-53) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e+55], -2.0, If[LessEqual[z, 7.4e-53], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+55}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-53}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.00000000000000002e55 or 7.39999999999999965e-53 < z Initial program 99.2%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 63.2%
if -2.00000000000000002e55 < z < 7.39999999999999965e-53Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
associate-+l-99.7%
*-commutative99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-commutative99.7%
+-commutative99.7%
fma-udef99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in y around inf 47.9%
associate-*r/47.9%
*-rgt-identity47.9%
times-frac47.8%
/-rgt-identity47.8%
Simplified47.8%
Final simplification55.1%
(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%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 33.0%
Final simplification33.0%
(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 2023293
(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))