
(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 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= z -9e+159)
-2.0
(if (<= z -6.5e-71)
(* x (/ 4.0 z))
(if (<= z 1e+88) (* y (/ -4.0 z)) -2.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+159) {
tmp = -2.0;
} else if (z <= -6.5e-71) {
tmp = x * (4.0 / z);
} else if (z <= 1e+88) {
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 <= (-9d+159)) then
tmp = -2.0d0
else if (z <= (-6.5d-71)) then
tmp = x * (4.0d0 / z)
else if (z <= 1d+88) 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 <= -9e+159) {
tmp = -2.0;
} else if (z <= -6.5e-71) {
tmp = x * (4.0 / z);
} else if (z <= 1e+88) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e+159: tmp = -2.0 elif z <= -6.5e-71: tmp = x * (4.0 / z) elif z <= 1e+88: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e+159) tmp = -2.0; elseif (z <= -6.5e-71) tmp = Float64(x * Float64(4.0 / z)); elseif (z <= 1e+88) 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 <= -9e+159) tmp = -2.0; elseif (z <= -6.5e-71) tmp = x * (4.0 / z); elseif (z <= 1e+88) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9e+159], -2.0, If[LessEqual[z, -6.5e-71], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e+88], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+159}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -6.5 \cdot 10^{-71}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;z \leq 10^{+88}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -9.00000000000000053e159 or 9.99999999999999959e87 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 72.9%
if -9.00000000000000053e159 < z < -6.50000000000000005e-71Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 47.8%
associate-*r/47.8%
associate-*l/47.6%
*-commutative47.6%
Simplified47.6%
if -6.50000000000000005e-71 < z < 9.99999999999999959e87Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 61.4%
associate-*r/61.4%
associate-*l/61.4%
metadata-eval61.4%
distribute-neg-frac61.4%
distribute-lft-neg-in61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
distribute-neg-frac61.4%
metadata-eval61.4%
Simplified61.4%
Final simplification62.2%
(FPCore (x y z)
:precision binary64
(if (<= z -9e+159)
-2.0
(if (<= z -8.5e-69)
(* x (/ 4.0 z))
(if (<= z 8.6e+86) (* -4.0 (/ y z)) -2.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+159) {
tmp = -2.0;
} else if (z <= -8.5e-69) {
tmp = x * (4.0 / z);
} else if (z <= 8.6e+86) {
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 (z <= (-9d+159)) then
tmp = -2.0d0
else if (z <= (-8.5d-69)) then
tmp = x * (4.0d0 / z)
else if (z <= 8.6d+86) 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 (z <= -9e+159) {
tmp = -2.0;
} else if (z <= -8.5e-69) {
tmp = x * (4.0 / z);
} else if (z <= 8.6e+86) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e+159: tmp = -2.0 elif z <= -8.5e-69: tmp = x * (4.0 / z) elif z <= 8.6e+86: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e+159) tmp = -2.0; elseif (z <= -8.5e-69) tmp = Float64(x * Float64(4.0 / z)); elseif (z <= 8.6e+86) 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 (z <= -9e+159) tmp = -2.0; elseif (z <= -8.5e-69) tmp = x * (4.0 / z); elseif (z <= 8.6e+86) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9e+159], -2.0, If[LessEqual[z, -8.5e-69], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.6e+86], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+159}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{-69}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{+86}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -9.00000000000000053e159 or 8.6000000000000004e86 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 72.9%
if -9.00000000000000053e159 < z < -8.50000000000000046e-69Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 47.8%
associate-*r/47.8%
associate-*l/47.6%
*-commutative47.6%
Simplified47.6%
if -8.50000000000000046e-69 < z < 8.6000000000000004e86Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 61.4%
*-commutative61.4%
Simplified61.4%
Final simplification62.2%
(FPCore (x y z)
:precision binary64
(if (<= z -9e+159)
-2.0
(if (<= z -8.5e-69)
(/ (* x 4.0) z)
(if (<= z 3.9e+88) (* -4.0 (/ y z)) -2.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e+159) {
tmp = -2.0;
} else if (z <= -8.5e-69) {
tmp = (x * 4.0) / z;
} else if (z <= 3.9e+88) {
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 (z <= (-9d+159)) then
tmp = -2.0d0
else if (z <= (-8.5d-69)) then
tmp = (x * 4.0d0) / z
else if (z <= 3.9d+88) 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 (z <= -9e+159) {
tmp = -2.0;
} else if (z <= -8.5e-69) {
tmp = (x * 4.0) / z;
} else if (z <= 3.9e+88) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e+159: tmp = -2.0 elif z <= -8.5e-69: tmp = (x * 4.0) / z elif z <= 3.9e+88: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e+159) tmp = -2.0; elseif (z <= -8.5e-69) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 3.9e+88) 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 (z <= -9e+159) tmp = -2.0; elseif (z <= -8.5e-69) tmp = (x * 4.0) / z; elseif (z <= 3.9e+88) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9e+159], -2.0, If[LessEqual[z, -8.5e-69], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 3.9e+88], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+159}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{-69}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{+88}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -9.00000000000000053e159 or 3.9000000000000001e88 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 72.9%
if -9.00000000000000053e159 < z < -8.50000000000000046e-69Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 47.8%
associate-*r/47.8%
*-commutative47.8%
Simplified47.8%
if -8.50000000000000046e-69 < z < 3.9000000000000001e88Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 61.4%
*-commutative61.4%
Simplified61.4%
Final simplification62.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.2e+65) (not (<= y 1.6e+21))) (* -4.0 (/ y z)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.2e+65) || !(y <= 1.6e+21)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.2d+65)) .or. (.not. (y <= 1.6d+21))) then
tmp = (-4.0d0) * (y / z)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.2e+65) || !(y <= 1.6e+21)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.2e+65) or not (y <= 1.6e+21): tmp = -4.0 * (y / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.2e+65) || !(y <= 1.6e+21)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.2e+65) || ~((y <= 1.6e+21))) tmp = -4.0 * (y / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.2e+65], N[Not[LessEqual[y, 1.6e+21]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+65} \lor \neg \left(y \leq 1.6 \cdot 10^{+21}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -2.1999999999999998e65 or 1.6e21 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 71.9%
*-commutative71.9%
Simplified71.9%
if -2.1999999999999998e65 < y < 1.6e21Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 89.3%
Final simplification80.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.3e+61) (not (<= x 4.4e+26))) (* -4.0 (- 0.5 (/ x z))) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.3e+61) || !(x <= 4.4e+26)) {
tmp = -4.0 * (0.5 - (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 <= (-3.3d+61)) .or. (.not. (x <= 4.4d+26))) then
tmp = (-4.0d0) * (0.5d0 - (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 <= -3.3e+61) || !(x <= 4.4e+26)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.3e+61) or not (x <= 4.4e+26): tmp = -4.0 * (0.5 - (x / z)) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.3e+61) || !(x <= 4.4e+26)) tmp = Float64(-4.0 * Float64(0.5 - 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 <= -3.3e+61) || ~((x <= 4.4e+26))) tmp = -4.0 * (0.5 - (x / z)); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.3e+61], N[Not[LessEqual[x, 4.4e+26]], $MachinePrecision]], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{+61} \lor \neg \left(x \leq 4.4 \cdot 10^{+26}\right):\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -3.2999999999999998e61 or 4.40000000000000014e26 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub99.9%
distribute-frac-neg299.9%
distribute-frac-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 85.7%
if -3.2999999999999998e61 < x < 4.40000000000000014e26Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around 0 91.6%
associate-*r/91.6%
metadata-eval91.6%
+-commutative91.6%
*-commutative91.6%
fma-undefine91.6%
associate-*r*91.6%
neg-mul-191.6%
associate-/l*91.6%
fma-undefine91.6%
*-commutative91.6%
distribute-neg-in91.6%
sub-neg91.6%
div-sub91.6%
distribute-neg-frac91.6%
associate-/l*91.6%
*-inverses91.6%
metadata-eval91.6%
metadata-eval91.6%
Simplified91.6%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= z -2.2e+162) -2.0 (if (<= z 4.6e+39) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.2e+162) {
tmp = -2.0;
} else if (z <= 4.6e+39) {
tmp = x * (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 <= (-2.2d+162)) then
tmp = -2.0d0
else if (z <= 4.6d+39) then
tmp = x * (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 <= -2.2e+162) {
tmp = -2.0;
} else if (z <= 4.6e+39) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.2e+162: tmp = -2.0 elif z <= 4.6e+39: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.2e+162) tmp = -2.0; elseif (z <= 4.6e+39) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.2e+162) tmp = -2.0; elseif (z <= 4.6e+39) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.2e+162], -2.0, If[LessEqual[z, 4.6e+39], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+162}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+39}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.2000000000000002e162 or 4.60000000000000024e39 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 67.6%
if -2.2000000000000002e162 < z < 4.60000000000000024e39Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 41.7%
associate-*r/41.7%
associate-*l/41.6%
*-commutative41.6%
Simplified41.6%
Final simplification50.4%
(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%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 30.2%
Final simplification30.2%
(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 2024096
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))