
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 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 = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ (/ (* x 4.0) y) 1.0)))
(if (<= x -2.6e+82)
t_1
(if (<= x 5e-272)
t_0
(if (<= x 9.2e-192)
2.0
(if (<= x 1.42e-149)
t_0
(if (<= x 1.9e-130)
2.0
(if (<= x 8e-47)
t_0
(if (<= x 1.3e-9)
t_1
(if (<= x 132000000000.0)
t_0
(if (<= x 5e+118) 2.0 t_1)))))))))))
double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = ((x * 4.0) / y) + 1.0;
double tmp;
if (x <= -2.6e+82) {
tmp = t_1;
} else if (x <= 5e-272) {
tmp = t_0;
} else if (x <= 9.2e-192) {
tmp = 2.0;
} else if (x <= 1.42e-149) {
tmp = t_0;
} else if (x <= 1.9e-130) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 1.3e-9) {
tmp = t_1;
} else if (x <= 132000000000.0) {
tmp = t_0;
} else if (x <= 5e+118) {
tmp = 2.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 = ((-4.0d0) * (z / y)) + 1.0d0
t_1 = ((x * 4.0d0) / y) + 1.0d0
if (x <= (-2.6d+82)) then
tmp = t_1
else if (x <= 5d-272) then
tmp = t_0
else if (x <= 9.2d-192) then
tmp = 2.0d0
else if (x <= 1.42d-149) then
tmp = t_0
else if (x <= 1.9d-130) then
tmp = 2.0d0
else if (x <= 8d-47) then
tmp = t_0
else if (x <= 1.3d-9) then
tmp = t_1
else if (x <= 132000000000.0d0) then
tmp = t_0
else if (x <= 5d+118) then
tmp = 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = ((x * 4.0) / y) + 1.0;
double tmp;
if (x <= -2.6e+82) {
tmp = t_1;
} else if (x <= 5e-272) {
tmp = t_0;
} else if (x <= 9.2e-192) {
tmp = 2.0;
} else if (x <= 1.42e-149) {
tmp = t_0;
} else if (x <= 1.9e-130) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 1.3e-9) {
tmp = t_1;
} else if (x <= 132000000000.0) {
tmp = t_0;
} else if (x <= 5e+118) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (-4.0 * (z / y)) + 1.0 t_1 = ((x * 4.0) / y) + 1.0 tmp = 0 if x <= -2.6e+82: tmp = t_1 elif x <= 5e-272: tmp = t_0 elif x <= 9.2e-192: tmp = 2.0 elif x <= 1.42e-149: tmp = t_0 elif x <= 1.9e-130: tmp = 2.0 elif x <= 8e-47: tmp = t_0 elif x <= 1.3e-9: tmp = t_1 elif x <= 132000000000.0: tmp = t_0 elif x <= 5e+118: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0) t_1 = Float64(Float64(Float64(x * 4.0) / y) + 1.0) tmp = 0.0 if (x <= -2.6e+82) tmp = t_1; elseif (x <= 5e-272) tmp = t_0; elseif (x <= 9.2e-192) tmp = 2.0; elseif (x <= 1.42e-149) tmp = t_0; elseif (x <= 1.9e-130) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 1.3e-9) tmp = t_1; elseif (x <= 132000000000.0) tmp = t_0; elseif (x <= 5e+118) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-4.0 * (z / y)) + 1.0; t_1 = ((x * 4.0) / y) + 1.0; tmp = 0.0; if (x <= -2.6e+82) tmp = t_1; elseif (x <= 5e-272) tmp = t_0; elseif (x <= 9.2e-192) tmp = 2.0; elseif (x <= 1.42e-149) tmp = t_0; elseif (x <= 1.9e-130) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 1.3e-9) tmp = t_1; elseif (x <= 132000000000.0) tmp = t_0; elseif (x <= 5e+118) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -2.6e+82], t$95$1, If[LessEqual[x, 5e-272], t$95$0, If[LessEqual[x, 9.2e-192], 2.0, If[LessEqual[x, 1.42e-149], t$95$0, If[LessEqual[x, 1.9e-130], 2.0, If[LessEqual[x, 8e-47], t$95$0, If[LessEqual[x, 1.3e-9], t$95$1, If[LessEqual[x, 132000000000.0], t$95$0, If[LessEqual[x, 5e+118], 2.0, t$95$1]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
t_1 := \frac{x \cdot 4}{y} + 1\\
\mathbf{if}\;x \leq -2.6 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-272}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-149}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-130}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 132000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+118}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.5999999999999998e82 or 7.9999999999999998e-47 < x < 1.3000000000000001e-9 or 4.99999999999999972e118 < x Initial program 100.0%
Taylor expanded in x around inf 81.5%
*-commutative81.5%
associate-*l/81.5%
Simplified81.5%
if -2.5999999999999998e82 < x < 4.99999999999999982e-272 or 9.20000000000000073e-192 < x < 1.42e-149 or 1.8999999999999999e-130 < x < 7.9999999999999998e-47 or 1.3000000000000001e-9 < x < 1.32e11Initial program 100.0%
Taylor expanded in z around inf 66.0%
*-commutative66.0%
Simplified66.0%
if 4.99999999999999982e-272 < x < 9.20000000000000073e-192 or 1.42e-149 < x < 1.8999999999999999e-130 or 1.32e11 < x < 4.99999999999999972e118Initial program 100.0%
Taylor expanded in y around inf 73.2%
Final simplification72.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -3.1e+86)
t_1
(if (<= x 1.65e-276)
t_0
(if (<= x 7.2e-192)
2.0
(if (<= x 1.85e-150)
t_0
(if (<= x 4.5e-126)
2.0
(if (<= x 8e-47)
t_0
(if (<= x 1.2e-9)
t_1
(if (<= x 95000000000.0)
t_0
(if (<= x 5.2e+118) 2.0 t_1)))))))))))
double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -3.1e+86) {
tmp = t_1;
} else if (x <= 1.65e-276) {
tmp = t_0;
} else if (x <= 7.2e-192) {
tmp = 2.0;
} else if (x <= 1.85e-150) {
tmp = t_0;
} else if (x <= 4.5e-126) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 1.2e-9) {
tmp = t_1;
} else if (x <= 95000000000.0) {
tmp = t_0;
} else if (x <= 5.2e+118) {
tmp = 2.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 = ((-4.0d0) * (z / y)) + 1.0d0
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-3.1d+86)) then
tmp = t_1
else if (x <= 1.65d-276) then
tmp = t_0
else if (x <= 7.2d-192) then
tmp = 2.0d0
else if (x <= 1.85d-150) then
tmp = t_0
else if (x <= 4.5d-126) then
tmp = 2.0d0
else if (x <= 8d-47) then
tmp = t_0
else if (x <= 1.2d-9) then
tmp = t_1
else if (x <= 95000000000.0d0) then
tmp = t_0
else if (x <= 5.2d+118) then
tmp = 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -3.1e+86) {
tmp = t_1;
} else if (x <= 1.65e-276) {
tmp = t_0;
} else if (x <= 7.2e-192) {
tmp = 2.0;
} else if (x <= 1.85e-150) {
tmp = t_0;
} else if (x <= 4.5e-126) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 1.2e-9) {
tmp = t_1;
} else if (x <= 95000000000.0) {
tmp = t_0;
} else if (x <= 5.2e+118) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (-4.0 * (z / y)) + 1.0 t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -3.1e+86: tmp = t_1 elif x <= 1.65e-276: tmp = t_0 elif x <= 7.2e-192: tmp = 2.0 elif x <= 1.85e-150: tmp = t_0 elif x <= 4.5e-126: tmp = 2.0 elif x <= 8e-47: tmp = t_0 elif x <= 1.2e-9: tmp = t_1 elif x <= 95000000000.0: tmp = t_0 elif x <= 5.2e+118: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -3.1e+86) tmp = t_1; elseif (x <= 1.65e-276) tmp = t_0; elseif (x <= 7.2e-192) tmp = 2.0; elseif (x <= 1.85e-150) tmp = t_0; elseif (x <= 4.5e-126) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 1.2e-9) tmp = t_1; elseif (x <= 95000000000.0) tmp = t_0; elseif (x <= 5.2e+118) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-4.0 * (z / y)) + 1.0; t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -3.1e+86) tmp = t_1; elseif (x <= 1.65e-276) tmp = t_0; elseif (x <= 7.2e-192) tmp = 2.0; elseif (x <= 1.85e-150) tmp = t_0; elseif (x <= 4.5e-126) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 1.2e-9) tmp = t_1; elseif (x <= 95000000000.0) tmp = t_0; elseif (x <= 5.2e+118) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.1e+86], t$95$1, If[LessEqual[x, 1.65e-276], t$95$0, If[LessEqual[x, 7.2e-192], 2.0, If[LessEqual[x, 1.85e-150], t$95$0, If[LessEqual[x, 4.5e-126], 2.0, If[LessEqual[x, 8e-47], t$95$0, If[LessEqual[x, 1.2e-9], t$95$1, If[LessEqual[x, 95000000000.0], t$95$0, If[LessEqual[x, 5.2e+118], 2.0, t$95$1]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-276}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-150}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-126}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 95000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+118}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.1000000000000002e86 or 7.9999999999999998e-47 < x < 1.2e-9 or 5.20000000000000032e118 < x Initial program 100.0%
Taylor expanded in x around inf 81.5%
associate-*r/81.5%
associate-*l/81.4%
*-commutative81.4%
Simplified81.4%
if -3.1000000000000002e86 < x < 1.64999999999999996e-276 or 7.1999999999999998e-192 < x < 1.85e-150 or 4.50000000000000025e-126 < x < 7.9999999999999998e-47 or 1.2e-9 < x < 9.5e10Initial program 100.0%
Taylor expanded in z around inf 66.0%
*-commutative66.0%
Simplified66.0%
if 1.64999999999999996e-276 < x < 7.1999999999999998e-192 or 1.85e-150 < x < 4.50000000000000025e-126 or 9.5e10 < x < 5.20000000000000032e118Initial program 100.0%
Taylor expanded in y around inf 73.2%
Final simplification72.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -1.4e+82)
t_1
(if (<= x 1.92e-274)
t_0
(if (<= x 7.8e-192)
2.0
(if (<= x 1.55e-149)
t_0
(if (<= x 5.2e-128)
2.0
(if (<= x 8e-47)
t_0
(if (<= x 7.5e-9)
t_1
(if (<= x 96000000000.0)
t_0
(if (<= x 5.2e+118) 2.0 t_1)))))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -1.4e+82) {
tmp = t_1;
} else if (x <= 1.92e-274) {
tmp = t_0;
} else if (x <= 7.8e-192) {
tmp = 2.0;
} else if (x <= 1.55e-149) {
tmp = t_0;
} else if (x <= 5.2e-128) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 7.5e-9) {
tmp = t_1;
} else if (x <= 96000000000.0) {
tmp = t_0;
} else if (x <= 5.2e+118) {
tmp = 2.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 = 1.0d0 + (z * ((-4.0d0) / y))
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-1.4d+82)) then
tmp = t_1
else if (x <= 1.92d-274) then
tmp = t_0
else if (x <= 7.8d-192) then
tmp = 2.0d0
else if (x <= 1.55d-149) then
tmp = t_0
else if (x <= 5.2d-128) then
tmp = 2.0d0
else if (x <= 8d-47) then
tmp = t_0
else if (x <= 7.5d-9) then
tmp = t_1
else if (x <= 96000000000.0d0) then
tmp = t_0
else if (x <= 5.2d+118) then
tmp = 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -1.4e+82) {
tmp = t_1;
} else if (x <= 1.92e-274) {
tmp = t_0;
} else if (x <= 7.8e-192) {
tmp = 2.0;
} else if (x <= 1.55e-149) {
tmp = t_0;
} else if (x <= 5.2e-128) {
tmp = 2.0;
} else if (x <= 8e-47) {
tmp = t_0;
} else if (x <= 7.5e-9) {
tmp = t_1;
} else if (x <= 96000000000.0) {
tmp = t_0;
} else if (x <= 5.2e+118) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -1.4e+82: tmp = t_1 elif x <= 1.92e-274: tmp = t_0 elif x <= 7.8e-192: tmp = 2.0 elif x <= 1.55e-149: tmp = t_0 elif x <= 5.2e-128: tmp = 2.0 elif x <= 8e-47: tmp = t_0 elif x <= 7.5e-9: tmp = t_1 elif x <= 96000000000.0: tmp = t_0 elif x <= 5.2e+118: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -1.4e+82) tmp = t_1; elseif (x <= 1.92e-274) tmp = t_0; elseif (x <= 7.8e-192) tmp = 2.0; elseif (x <= 1.55e-149) tmp = t_0; elseif (x <= 5.2e-128) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 7.5e-9) tmp = t_1; elseif (x <= 96000000000.0) tmp = t_0; elseif (x <= 5.2e+118) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (-4.0 / y)); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -1.4e+82) tmp = t_1; elseif (x <= 1.92e-274) tmp = t_0; elseif (x <= 7.8e-192) tmp = 2.0; elseif (x <= 1.55e-149) tmp = t_0; elseif (x <= 5.2e-128) tmp = 2.0; elseif (x <= 8e-47) tmp = t_0; elseif (x <= 7.5e-9) tmp = t_1; elseif (x <= 96000000000.0) tmp = t_0; elseif (x <= 5.2e+118) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+82], t$95$1, If[LessEqual[x, 1.92e-274], t$95$0, If[LessEqual[x, 7.8e-192], 2.0, If[LessEqual[x, 1.55e-149], t$95$0, If[LessEqual[x, 5.2e-128], 2.0, If[LessEqual[x, 8e-47], t$95$0, If[LessEqual[x, 7.5e-9], t$95$1, If[LessEqual[x, 96000000000.0], t$95$0, If[LessEqual[x, 5.2e+118], 2.0, t$95$1]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.92 \cdot 10^{-274}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-149}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-128}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 96000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+118}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.4e82 or 7.9999999999999998e-47 < x < 7.49999999999999933e-9 or 5.20000000000000032e118 < x Initial program 100.0%
Taylor expanded in x around inf 81.5%
associate-*r/81.5%
associate-*l/81.4%
*-commutative81.4%
Simplified81.4%
if -1.4e82 < x < 1.91999999999999992e-274 or 7.8000000000000005e-192 < x < 1.54999999999999994e-149 or 5.19999999999999961e-128 < x < 7.9999999999999998e-47 or 7.49999999999999933e-9 < x < 9.6e10Initial program 100.0%
Taylor expanded in z around inf 66.0%
associate-*r/66.0%
metadata-eval66.0%
associate-*r*66.0%
neg-mul-166.0%
*-commutative66.0%
associate-*r/65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-in65.8%
distribute-neg-frac65.8%
metadata-eval65.8%
Simplified65.8%
if 1.91999999999999992e-274 < x < 7.8000000000000005e-192 or 1.54999999999999994e-149 < x < 5.19999999999999961e-128 or 9.6e10 < x < 5.20000000000000032e118Initial program 100.0%
Taylor expanded in y around inf 73.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1010000000000.0) (not (<= z 1e-79))) (+ 2.0 (* -4.0 (/ z y))) (+ 2.0 (/ (* x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1010000000000.0) || !(z <= 1e-79)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + ((x * 4.0) / y);
}
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 <= (-1010000000000.0d0)) .or. (.not. (z <= 1d-79))) then
tmp = 2.0d0 + ((-4.0d0) * (z / y))
else
tmp = 2.0d0 + ((x * 4.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1010000000000.0) || !(z <= 1e-79)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + ((x * 4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1010000000000.0) or not (z <= 1e-79): tmp = 2.0 + (-4.0 * (z / y)) else: tmp = 2.0 + ((x * 4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1010000000000.0) || !(z <= 1e-79)) tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(2.0 + Float64(Float64(x * 4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1010000000000.0) || ~((z <= 1e-79))) tmp = 2.0 + (-4.0 * (z / y)); else tmp = 2.0 + ((x * 4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1010000000000.0], N[Not[LessEqual[z, 1e-79]], $MachinePrecision]], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1010000000000 \lor \neg \left(z \leq 10^{-79}\right):\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{x \cdot 4}{y}\\
\end{array}
\end{array}
if z < -1.01e12 or 1e-79 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 82.7%
if -1.01e12 < z < 1e-79Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
Simplified98.1%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.3e+90) (not (<= x 3.4e+124))) (+ (/ (* x 4.0) y) 1.0) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.3e+90) || !(x <= 3.4e+124)) {
tmp = ((x * 4.0) / y) + 1.0;
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-3.3d+90)) .or. (.not. (x <= 3.4d+124))) then
tmp = ((x * 4.0d0) / y) + 1.0d0
else
tmp = 2.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.3e+90) || !(x <= 3.4e+124)) {
tmp = ((x * 4.0) / y) + 1.0;
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.3e+90) or not (x <= 3.4e+124): tmp = ((x * 4.0) / y) + 1.0 else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.3e+90) || !(x <= 3.4e+124)) tmp = Float64(Float64(Float64(x * 4.0) / y) + 1.0); else tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.3e+90) || ~((x <= 3.4e+124))) tmp = ((x * 4.0) / y) + 1.0; else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.3e+90], N[Not[LessEqual[x, 3.4e+124]], $MachinePrecision]], N[(N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{+90} \lor \neg \left(x \leq 3.4 \cdot 10^{+124}\right):\\
\;\;\;\;\frac{x \cdot 4}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -3.30000000000000008e90 or 3.4e124 < x Initial program 100.0%
Taylor expanded in x around inf 83.0%
*-commutative83.0%
associate-*l/83.0%
Simplified83.0%
if -3.30000000000000008e90 < x < 3.4e124Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 88.2%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.25e+66) 2.0 (if (<= y 6.8e+121) (+ 1.0 (* x (/ 4.0 y))) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.25e+66) {
tmp = 2.0;
} else if (y <= 6.8e+121) {
tmp = 1.0 + (x * (4.0 / y));
} 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 (y <= (-3.25d+66)) then
tmp = 2.0d0
else if (y <= 6.8d+121) then
tmp = 1.0d0 + (x * (4.0d0 / y))
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.25e+66) {
tmp = 2.0;
} else if (y <= 6.8e+121) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.25e+66: tmp = 2.0 elif y <= 6.8e+121: tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.25e+66) tmp = 2.0; elseif (y <= 6.8e+121) tmp = Float64(1.0 + Float64(x * Float64(4.0 / y))); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.25e+66) tmp = 2.0; elseif (y <= 6.8e+121) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.25e+66], 2.0, If[LessEqual[y, 6.8e+121], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{+66}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+121}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -3.2500000000000001e66 or 6.80000000000000021e121 < y Initial program 100.0%
Taylor expanded in y around inf 72.9%
if -3.2500000000000001e66 < y < 6.80000000000000021e121Initial program 100.0%
Taylor expanded in x around inf 48.5%
associate-*r/48.5%
associate-*l/48.4%
*-commutative48.4%
Simplified48.4%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
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 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(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%
Taylor expanded in y around inf 30.9%
herbie shell --seed 2024091
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))