
(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 8 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 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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (/ -4.0 (/ z y))))
(if (<= x -1.18e+119)
t_0
(if (<= x -3.95e-41)
t_1
(if (<= x -3e-150)
-2.0
(if (<= x 7.2e-118)
t_1
(if (<= x 1200000.0) -2.0 (if (<= x 2.5e+71) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = -4.0 / (z / y);
double tmp;
if (x <= -1.18e+119) {
tmp = t_0;
} else if (x <= -3.95e-41) {
tmp = t_1;
} else if (x <= -3e-150) {
tmp = -2.0;
} else if (x <= 7.2e-118) {
tmp = t_1;
} else if (x <= 1200000.0) {
tmp = -2.0;
} else if (x <= 2.5e+71) {
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 = 4.0d0 * (x / z)
t_1 = (-4.0d0) / (z / y)
if (x <= (-1.18d+119)) then
tmp = t_0
else if (x <= (-3.95d-41)) then
tmp = t_1
else if (x <= (-3d-150)) then
tmp = -2.0d0
else if (x <= 7.2d-118) then
tmp = t_1
else if (x <= 1200000.0d0) then
tmp = -2.0d0
else if (x <= 2.5d+71) 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 = 4.0 * (x / z);
double t_1 = -4.0 / (z / y);
double tmp;
if (x <= -1.18e+119) {
tmp = t_0;
} else if (x <= -3.95e-41) {
tmp = t_1;
} else if (x <= -3e-150) {
tmp = -2.0;
} else if (x <= 7.2e-118) {
tmp = t_1;
} else if (x <= 1200000.0) {
tmp = -2.0;
} else if (x <= 2.5e+71) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 / (z / y) tmp = 0 if x <= -1.18e+119: tmp = t_0 elif x <= -3.95e-41: tmp = t_1 elif x <= -3e-150: tmp = -2.0 elif x <= 7.2e-118: tmp = t_1 elif x <= 1200000.0: tmp = -2.0 elif x <= 2.5e+71: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(-4.0 / Float64(z / y)) tmp = 0.0 if (x <= -1.18e+119) tmp = t_0; elseif (x <= -3.95e-41) tmp = t_1; elseif (x <= -3e-150) tmp = -2.0; elseif (x <= 7.2e-118) tmp = t_1; elseif (x <= 1200000.0) tmp = -2.0; elseif (x <= 2.5e+71) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = -4.0 / (z / y); tmp = 0.0; if (x <= -1.18e+119) tmp = t_0; elseif (x <= -3.95e-41) tmp = t_1; elseif (x <= -3e-150) tmp = -2.0; elseif (x <= 7.2e-118) tmp = t_1; elseif (x <= 1200000.0) tmp = -2.0; elseif (x <= 2.5e+71) tmp = t_1; 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]}, Block[{t$95$1 = N[(-4.0 / N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.18e+119], t$95$0, If[LessEqual[x, -3.95e-41], t$95$1, If[LessEqual[x, -3e-150], -2.0, If[LessEqual[x, 7.2e-118], t$95$1, If[LessEqual[x, 1200000.0], -2.0, If[LessEqual[x, 2.5e+71], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := \frac{-4}{\frac{z}{y}}\\
\mathbf{if}\;x \leq -1.18 \cdot 10^{+119}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.95 \cdot 10^{-41}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-150}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-118}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1200000:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.1799999999999999e119 or 2.49999999999999986e71 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 76.0%
if -1.1799999999999999e119 < x < -3.95e-41 or -3.0000000000000002e-150 < x < 7.2000000000000004e-118 or 1.2e6 < x < 2.49999999999999986e71Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 58.2%
associate-*r/58.2%
neg-mul-158.2%
Simplified58.2%
clear-num58.2%
associate-/r/58.2%
clear-num58.3%
add-sqr-sqrt25.5%
sqrt-unprod22.0%
sqr-neg22.0%
sqrt-unprod1.1%
add-sqr-sqrt2.0%
Applied egg-rr2.0%
add-sqr-sqrt0.8%
sqrt-unprod21.6%
swap-sqr21.6%
metadata-eval21.6%
metadata-eval21.6%
swap-sqr21.6%
*-commutative21.6%
*-commutative21.6%
sqrt-unprod26.5%
add-sqr-sqrt58.3%
clear-num58.2%
un-div-inv58.2%
Applied egg-rr58.2%
if -3.95e-41 < x < -3.0000000000000002e-150 or 7.2000000000000004e-118 < x < 1.2e6Initial 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 60.4%
Final simplification65.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (/ (* y -4.0) z)))
(if (<= x -4.1e+116)
t_0
(if (<= x -2.7e-39)
t_1
(if (<= x -3.7e-150)
-2.0
(if (<= x 7.7e-118)
t_1
(if (<= x 260000000000.0)
-2.0
(if (<= x 1.42e+71) (/ -4.0 (/ z y)) t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = (y * -4.0) / z;
double tmp;
if (x <= -4.1e+116) {
tmp = t_0;
} else if (x <= -2.7e-39) {
tmp = t_1;
} else if (x <= -3.7e-150) {
tmp = -2.0;
} else if (x <= 7.7e-118) {
tmp = t_1;
} else if (x <= 260000000000.0) {
tmp = -2.0;
} else if (x <= 1.42e+71) {
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) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = (y * (-4.0d0)) / z
if (x <= (-4.1d+116)) then
tmp = t_0
else if (x <= (-2.7d-39)) then
tmp = t_1
else if (x <= (-3.7d-150)) then
tmp = -2.0d0
else if (x <= 7.7d-118) then
tmp = t_1
else if (x <= 260000000000.0d0) then
tmp = -2.0d0
else if (x <= 1.42d+71) 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 t_1 = (y * -4.0) / z;
double tmp;
if (x <= -4.1e+116) {
tmp = t_0;
} else if (x <= -2.7e-39) {
tmp = t_1;
} else if (x <= -3.7e-150) {
tmp = -2.0;
} else if (x <= 7.7e-118) {
tmp = t_1;
} else if (x <= 260000000000.0) {
tmp = -2.0;
} else if (x <= 1.42e+71) {
tmp = -4.0 / (z / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = (y * -4.0) / z tmp = 0 if x <= -4.1e+116: tmp = t_0 elif x <= -2.7e-39: tmp = t_1 elif x <= -3.7e-150: tmp = -2.0 elif x <= 7.7e-118: tmp = t_1 elif x <= 260000000000.0: tmp = -2.0 elif x <= 1.42e+71: tmp = -4.0 / (z / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(Float64(y * -4.0) / z) tmp = 0.0 if (x <= -4.1e+116) tmp = t_0; elseif (x <= -2.7e-39) tmp = t_1; elseif (x <= -3.7e-150) tmp = -2.0; elseif (x <= 7.7e-118) tmp = t_1; elseif (x <= 260000000000.0) tmp = -2.0; elseif (x <= 1.42e+71) 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); t_1 = (y * -4.0) / z; tmp = 0.0; if (x <= -4.1e+116) tmp = t_0; elseif (x <= -2.7e-39) tmp = t_1; elseif (x <= -3.7e-150) tmp = -2.0; elseif (x <= 7.7e-118) tmp = t_1; elseif (x <= 260000000000.0) tmp = -2.0; elseif (x <= 1.42e+71) 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]}, Block[{t$95$1 = N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -4.1e+116], t$95$0, If[LessEqual[x, -2.7e-39], t$95$1, If[LessEqual[x, -3.7e-150], -2.0, If[LessEqual[x, 7.7e-118], t$95$1, If[LessEqual[x, 260000000000.0], -2.0, If[LessEqual[x, 1.42e+71], N[(-4.0 / N[(z / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := \frac{y \cdot -4}{z}\\
\mathbf{if}\;x \leq -4.1 \cdot 10^{+116}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-39}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.7 \cdot 10^{-150}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 7.7 \cdot 10^{-118}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 260000000000:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{+71}:\\
\;\;\;\;\frac{-4}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -4.0999999999999998e116 or 1.42000000000000012e71 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 76.0%
if -4.0999999999999998e116 < x < -2.7000000000000001e-39 or -3.70000000000000001e-150 < x < 7.6999999999999996e-118Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 59.6%
*-commutative59.6%
associate-*l/59.6%
Simplified59.6%
if -2.7000000000000001e-39 < x < -3.70000000000000001e-150 or 7.6999999999999996e-118 < x < 2.6e11Initial 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 60.4%
if 2.6e11 < x < 1.42000000000000012e71Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around inf 51.7%
associate-*r/51.7%
neg-mul-151.7%
Simplified51.7%
clear-num51.7%
associate-/r/51.7%
clear-num51.7%
add-sqr-sqrt22.5%
sqrt-unprod24.0%
sqr-neg24.0%
sqrt-unprod1.2%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
add-sqr-sqrt0.8%
sqrt-unprod29.8%
swap-sqr29.8%
metadata-eval29.8%
metadata-eval29.8%
swap-sqr29.8%
*-commutative29.8%
*-commutative29.8%
sqrt-unprod34.5%
add-sqr-sqrt51.7%
clear-num51.7%
un-div-inv51.7%
Applied egg-rr51.7%
Final simplification65.5%
(FPCore (x y z)
:precision binary64
(if (or (<= x -9.5e+123)
(not
(or (<= x 6.2e+72) (and (not (<= x 1.5e+138)) (<= x 1.55e+164)))))
(* 4.0 (/ x z))
(* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+123) || !((x <= 6.2e+72) || (!(x <= 1.5e+138) && (x <= 1.55e+164)))) {
tmp = 4.0 * (x / 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 <= (-9.5d+123)) .or. (.not. (x <= 6.2d+72) .or. (.not. (x <= 1.5d+138)) .and. (x <= 1.55d+164))) then
tmp = 4.0d0 * (x / 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 <= -9.5e+123) || !((x <= 6.2e+72) || (!(x <= 1.5e+138) && (x <= 1.55e+164)))) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+123) or not ((x <= 6.2e+72) or (not (x <= 1.5e+138) and (x <= 1.55e+164))): tmp = 4.0 * (x / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+123) || !((x <= 6.2e+72) || (!(x <= 1.5e+138) && (x <= 1.55e+164)))) tmp = Float64(4.0 * Float64(x / 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 <= -9.5e+123) || ~(((x <= 6.2e+72) || (~((x <= 1.5e+138)) && (x <= 1.55e+164))))) tmp = 4.0 * (x / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+123], N[Not[Or[LessEqual[x, 6.2e+72], And[N[Not[LessEqual[x, 1.5e+138]], $MachinePrecision], LessEqual[x, 1.55e+164]]]], $MachinePrecision]], N[(4.0 * N[(x / 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 -9.5 \cdot 10^{+123} \lor \neg \left(x \leq 6.2 \cdot 10^{+72} \lor \neg \left(x \leq 1.5 \cdot 10^{+138}\right) \land x \leq 1.55 \cdot 10^{+164}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -9.4999999999999996e123 or 6.19999999999999977e72 < x < 1.50000000000000005e138 or 1.5500000000000001e164 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 81.3%
if -9.4999999999999996e123 < x < 6.19999999999999977e72 or 1.50000000000000005e138 < x < 1.5500000000000001e164Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 89.4%
div-sub89.4%
associate-/l*89.4%
*-lft-identity89.4%
associate-*l/89.3%
lft-mult-inverse89.4%
metadata-eval89.4%
Simplified89.4%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.2e+79) (not (<= x 1.2e+31))) (* 4.0 (/ (- x y) z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.2e+79) || !(x <= 1.2e+31)) {
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 <= (-5.2d+79)) .or. (.not. (x <= 1.2d+31))) 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 <= -5.2e+79) || !(x <= 1.2e+31)) {
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 <= -5.2e+79) or not (x <= 1.2e+31): 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 <= -5.2e+79) || !(x <= 1.2e+31)) 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 <= -5.2e+79) || ~((x <= 1.2e+31))) 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, -5.2e+79], N[Not[LessEqual[x, 1.2e+31]], $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 -5.2 \cdot 10^{+79} \lor \neg \left(x \leq 1.2 \cdot 10^{+31}\right):\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -5.20000000000000029e79 or 1.19999999999999991e31 < x Initial 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 85.6%
if -5.20000000000000029e79 < x < 1.19999999999999991e31Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 92.3%
div-sub92.3%
associate-/l*92.3%
*-lft-identity92.3%
associate-*l/92.2%
lft-mult-inverse92.3%
metadata-eval92.3%
Simplified92.3%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.2e+82) (* 4.0 (/ (- x y) z)) (if (<= x 3.3e+71) (* 4.0 (- -0.5 (/ y z))) (+ (* 4.0 (/ x z)) -2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e+82) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 3.3e+71) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = (4.0 * (x / 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 <= (-1.2d+82)) then
tmp = 4.0d0 * ((x - y) / z)
else if (x <= 3.3d+71) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = (4.0d0 * (x / z)) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e+82) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 3.3e+71) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = (4.0 * (x / z)) + -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.2e+82: tmp = 4.0 * ((x - y) / z) elif x <= 3.3e+71: tmp = 4.0 * (-0.5 - (y / z)) else: tmp = (4.0 * (x / z)) + -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.2e+82) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (x <= 3.3e+71) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(Float64(4.0 * Float64(x / z)) + -2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.2e+82) tmp = 4.0 * ((x - y) / z); elseif (x <= 3.3e+71) tmp = 4.0 * (-0.5 - (y / z)); else tmp = (4.0 * (x / z)) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.2e+82], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.3e+71], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+82}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+71}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} + -2\\
\end{array}
\end{array}
if x < -1.19999999999999999e82Initial 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 88.9%
if -1.19999999999999999e82 < x < 3.2999999999999998e71Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 90.3%
div-sub90.3%
associate-/l*90.3%
*-lft-identity90.3%
associate-*l/90.2%
lft-mult-inverse90.3%
metadata-eval90.3%
Simplified90.3%
if 3.2999999999999998e71 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 90.2%
+-commutative90.2%
metadata-eval90.2%
cancel-sign-sub-inv90.2%
div-sub90.2%
associate-/l*90.2%
*-lft-identity90.2%
associate-*l/90.2%
lft-mult-inverse90.2%
metadata-eval90.2%
sub-neg90.2%
metadata-eval90.2%
distribute-lft-in90.2%
metadata-eval90.2%
Simplified90.2%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.6e+77) (not (<= x 4.4e+33))) (* 4.0 (/ x z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.6e+77) || !(x <= 4.4e+33)) {
tmp = 4.0 * (x / 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 <= (-9.6d+77)) .or. (.not. (x <= 4.4d+33))) then
tmp = 4.0d0 * (x / 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 <= -9.6e+77) || !(x <= 4.4e+33)) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.6e+77) or not (x <= 4.4e+33): tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.6e+77) || !(x <= 4.4e+33)) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.6e+77) || ~((x <= 4.4e+33))) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.6e+77], N[Not[LessEqual[x, 4.4e+33]], $MachinePrecision]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \cdot 10^{+77} \lor \neg \left(x \leq 4.4 \cdot 10^{+33}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -9.5999999999999994e77 or 4.39999999999999988e33 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 69.8%
if -9.5999999999999994e77 < x < 4.39999999999999988e33Initial 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 inf 43.4%
Final simplification55.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 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 31.1%
Final simplification31.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 2023199
(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))