
(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 7 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 (/ 4.0 (/ z x))) (t_1 (* -4.0 (/ y z))))
(if (<= y -8.2e+26)
t_1
(if (<= y 1.3e-209)
-2.0
(if (<= y 7e-189)
t_0
(if (<= y 9e-149)
-2.0
(if (<= y 3.55e-84)
t_0
(if (<= y 5.6e+39) -2.0 (if (<= y 1.9e+85) t_0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 / (z / x);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -8.2e+26) {
tmp = t_1;
} else if (y <= 1.3e-209) {
tmp = -2.0;
} else if (y <= 7e-189) {
tmp = t_0;
} else if (y <= 9e-149) {
tmp = -2.0;
} else if (y <= 3.55e-84) {
tmp = t_0;
} else if (y <= 5.6e+39) {
tmp = -2.0;
} else if (y <= 1.9e+85) {
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 = 4.0d0 / (z / x)
t_1 = (-4.0d0) * (y / z)
if (y <= (-8.2d+26)) then
tmp = t_1
else if (y <= 1.3d-209) then
tmp = -2.0d0
else if (y <= 7d-189) then
tmp = t_0
else if (y <= 9d-149) then
tmp = -2.0d0
else if (y <= 3.55d-84) then
tmp = t_0
else if (y <= 5.6d+39) then
tmp = -2.0d0
else if (y <= 1.9d+85) 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 = 4.0 / (z / x);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -8.2e+26) {
tmp = t_1;
} else if (y <= 1.3e-209) {
tmp = -2.0;
} else if (y <= 7e-189) {
tmp = t_0;
} else if (y <= 9e-149) {
tmp = -2.0;
} else if (y <= 3.55e-84) {
tmp = t_0;
} else if (y <= 5.6e+39) {
tmp = -2.0;
} else if (y <= 1.9e+85) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 / (z / x) t_1 = -4.0 * (y / z) tmp = 0 if y <= -8.2e+26: tmp = t_1 elif y <= 1.3e-209: tmp = -2.0 elif y <= 7e-189: tmp = t_0 elif y <= 9e-149: tmp = -2.0 elif y <= 3.55e-84: tmp = t_0 elif y <= 5.6e+39: tmp = -2.0 elif y <= 1.9e+85: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(4.0 / Float64(z / x)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -8.2e+26) tmp = t_1; elseif (y <= 1.3e-209) tmp = -2.0; elseif (y <= 7e-189) tmp = t_0; elseif (y <= 9e-149) tmp = -2.0; elseif (y <= 3.55e-84) tmp = t_0; elseif (y <= 5.6e+39) tmp = -2.0; elseif (y <= 1.9e+85) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 / (z / x); t_1 = -4.0 * (y / z); tmp = 0.0; if (y <= -8.2e+26) tmp = t_1; elseif (y <= 1.3e-209) tmp = -2.0; elseif (y <= 7e-189) tmp = t_0; elseif (y <= 9e-149) tmp = -2.0; elseif (y <= 3.55e-84) tmp = t_0; elseif (y <= 5.6e+39) tmp = -2.0; elseif (y <= 1.9e+85) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 / N[(z / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.2e+26], t$95$1, If[LessEqual[y, 1.3e-209], -2.0, If[LessEqual[y, 7e-189], t$95$0, If[LessEqual[y, 9e-149], -2.0, If[LessEqual[y, 3.55e-84], t$95$0, If[LessEqual[y, 5.6e+39], -2.0, If[LessEqual[y, 1.9e+85], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4}{\frac{z}{x}}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+26}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-209}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-149}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{-84}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+39}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+85}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -8.19999999999999967e26 or 1.89999999999999996e85 < y Initial program 99.1%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 76.7%
*-commutative76.7%
Simplified76.7%
if -8.19999999999999967e26 < y < 1.29999999999999992e-209 or 7.0000000000000003e-189 < y < 8.9999999999999996e-149 or 3.5499999999999998e-84 < y < 5.60000000000000003e39Initial 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 61.4%
if 1.29999999999999992e-209 < y < 7.0000000000000003e-189 or 8.9999999999999996e-149 < y < 3.5499999999999998e-84 or 5.60000000000000003e39 < y < 1.89999999999999996e85Initial program 100.0%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 93.1%
clear-num92.8%
un-div-inv92.8%
Applied egg-rr92.8%
Taylor expanded in x around inf 78.3%
Final simplification70.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (/ z 4.0))) (t_1 (* -4.0 (/ y z))))
(if (<= y -2.2e+26)
t_1
(if (<= y 5.2e-209)
-2.0
(if (<= y 8.5e-187)
t_0
(if (<= y 3.6e-148) -2.0 (if (<= y 1.9e+85) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x / (z / 4.0);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -2.2e+26) {
tmp = t_1;
} else if (y <= 5.2e-209) {
tmp = -2.0;
} else if (y <= 8.5e-187) {
tmp = t_0;
} else if (y <= 3.6e-148) {
tmp = -2.0;
} else if (y <= 1.9e+85) {
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 = x / (z / 4.0d0)
t_1 = (-4.0d0) * (y / z)
if (y <= (-2.2d+26)) then
tmp = t_1
else if (y <= 5.2d-209) then
tmp = -2.0d0
else if (y <= 8.5d-187) then
tmp = t_0
else if (y <= 3.6d-148) then
tmp = -2.0d0
else if (y <= 1.9d+85) 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 = x / (z / 4.0);
double t_1 = -4.0 * (y / z);
double tmp;
if (y <= -2.2e+26) {
tmp = t_1;
} else if (y <= 5.2e-209) {
tmp = -2.0;
} else if (y <= 8.5e-187) {
tmp = t_0;
} else if (y <= 3.6e-148) {
tmp = -2.0;
} else if (y <= 1.9e+85) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x / (z / 4.0) t_1 = -4.0 * (y / z) tmp = 0 if y <= -2.2e+26: tmp = t_1 elif y <= 5.2e-209: tmp = -2.0 elif y <= 8.5e-187: tmp = t_0 elif y <= 3.6e-148: tmp = -2.0 elif y <= 1.9e+85: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(z / 4.0)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -2.2e+26) tmp = t_1; elseif (y <= 5.2e-209) tmp = -2.0; elseif (y <= 8.5e-187) tmp = t_0; elseif (y <= 3.6e-148) tmp = -2.0; elseif (y <= 1.9e+85) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (z / 4.0); t_1 = -4.0 * (y / z); tmp = 0.0; if (y <= -2.2e+26) tmp = t_1; elseif (y <= 5.2e-209) tmp = -2.0; elseif (y <= 8.5e-187) tmp = t_0; elseif (y <= 3.6e-148) tmp = -2.0; elseif (y <= 1.9e+85) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(z / 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+26], t$95$1, If[LessEqual[y, 5.2e-209], -2.0, If[LessEqual[y, 8.5e-187], t$95$0, If[LessEqual[y, 3.6e-148], -2.0, If[LessEqual[y, 1.9e+85], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{z}{4}}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+26}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-209}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-187}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-148}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+85}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -2.20000000000000007e26 or 1.89999999999999996e85 < y Initial program 99.1%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 76.7%
*-commutative76.7%
Simplified76.7%
if -2.20000000000000007e26 < y < 5.19999999999999969e-209 or 8.4999999999999999e-187 < y < 3.5999999999999998e-148Initial 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 63.8%
if 5.19999999999999969e-209 < y < 8.4999999999999999e-187 or 3.5999999999999998e-148 < y < 1.89999999999999996e85Initial 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 59.9%
*-commutative59.9%
associate-/r/59.9%
Simplified59.9%
Final simplification68.6%
(FPCore (x y z)
:precision binary64
(if (<= z -4.1e+93)
-2.0
(if (<= z -3.8e+70)
(* -4.0 (/ y z))
(if (<= z -2050000000000.0)
-2.0
(if (<= z 1.2e+127) (* 4.0 (/ (- x y) z)) -2.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e+93) {
tmp = -2.0;
} else if (z <= -3.8e+70) {
tmp = -4.0 * (y / z);
} else if (z <= -2050000000000.0) {
tmp = -2.0;
} else if (z <= 1.2e+127) {
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 <= (-4.1d+93)) then
tmp = -2.0d0
else if (z <= (-3.8d+70)) then
tmp = (-4.0d0) * (y / z)
else if (z <= (-2050000000000.0d0)) then
tmp = -2.0d0
else if (z <= 1.2d+127) 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 <= -4.1e+93) {
tmp = -2.0;
} else if (z <= -3.8e+70) {
tmp = -4.0 * (y / z);
} else if (z <= -2050000000000.0) {
tmp = -2.0;
} else if (z <= 1.2e+127) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.1e+93: tmp = -2.0 elif z <= -3.8e+70: tmp = -4.0 * (y / z) elif z <= -2050000000000.0: tmp = -2.0 elif z <= 1.2e+127: tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.1e+93) tmp = -2.0; elseif (z <= -3.8e+70) tmp = Float64(-4.0 * Float64(y / z)); elseif (z <= -2050000000000.0) tmp = -2.0; elseif (z <= 1.2e+127) 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 <= -4.1e+93) tmp = -2.0; elseif (z <= -3.8e+70) tmp = -4.0 * (y / z); elseif (z <= -2050000000000.0) tmp = -2.0; elseif (z <= 1.2e+127) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.1e+93], -2.0, If[LessEqual[z, -3.8e+70], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2050000000000.0], -2.0, If[LessEqual[z, 1.2e+127], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+93}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{+70}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -2050000000000:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+127}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.1000000000000001e93 or -3.7999999999999998e70 < z < -2.05e12 or 1.2000000000000001e127 < z 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 77.5%
if -4.1000000000000001e93 < z < -3.7999999999999998e70Initial 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 90.0%
*-commutative90.0%
Simplified90.0%
if -2.05e12 < z < 1.2000000000000001e127Initial program 99.4%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 89.2%
Final simplification85.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -900000000000.0) (not (<= z 0.00025))) (- (* -4.0 (/ y z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -900000000000.0) || !(z <= 0.00025)) {
tmp = (-4.0 * (y / 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 <= (-900000000000.0d0)) .or. (.not. (z <= 0.00025d0))) then
tmp = ((-4.0d0) * (y / 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 <= -900000000000.0) || !(z <= 0.00025)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -900000000000.0) or not (z <= 0.00025): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -900000000000.0) || !(z <= 0.00025)) tmp = Float64(Float64(-4.0 * Float64(y / 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 <= -900000000000.0) || ~((z <= 0.00025))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -900000000000.0], N[Not[LessEqual[z, 0.00025]], $MachinePrecision]], N[(N[(-4.0 * N[(y / 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 -900000000000 \lor \neg \left(z \leq 0.00025\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -9e11 or 2.5000000000000001e-4 < z Initial program 99.2%
*-commutative99.2%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 90.8%
if -9e11 < z < 2.5000000000000001e-4Initial program 100.0%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 92.6%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.5e+26) (not (<= y 2.8e+18))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e+26) || !(y <= 2.8e+18)) {
tmp = -4.0 * (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 ((y <= (-2.5d+26)) .or. (.not. (y <= 2.8d+18))) then
tmp = (-4.0d0) * (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 ((y <= -2.5e+26) || !(y <= 2.8e+18)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.5e+26) or not (y <= 2.8e+18): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.5e+26) || !(y <= 2.8e+18)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.5e+26) || ~((y <= 2.8e+18))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e+26], N[Not[LessEqual[y, 2.8e+18]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+26} \lor \neg \left(y \leq 2.8 \cdot 10^{+18}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -2.5e26 or 2.8e18 < y Initial program 99.2%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
Simplified72.8%
if -2.5e26 < y < 2.8e18Initial 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 53.2%
Final simplification62.6%
(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 35.7%
Final simplification35.7%
(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 2023290
(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))