
(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 (- (/ (- 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 99.6%
remove-double-neg99.6%
neg-mul-199.6%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= z -1.4e-26)
-2.0
(if (<= z -5.8e-182)
t_1
(if (<= z 1.45e-233)
t_0
(if (<= z 1.05e-188)
t_1
(if (<= z 1.3e-154) t_0 (if (<= z 1.9e+62) t_1 -2.0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (z <= -1.4e-26) {
tmp = -2.0;
} else if (z <= -5.8e-182) {
tmp = t_1;
} else if (z <= 1.45e-233) {
tmp = t_0;
} else if (z <= 1.05e-188) {
tmp = t_1;
} else if (z <= 1.3e-154) {
tmp = t_0;
} else if (z <= 1.9e+62) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (z <= (-1.4d-26)) then
tmp = -2.0d0
else if (z <= (-5.8d-182)) then
tmp = t_1
else if (z <= 1.45d-233) then
tmp = t_0
else if (z <= 1.05d-188) then
tmp = t_1
else if (z <= 1.3d-154) then
tmp = t_0
else if (z <= 1.9d+62) then
tmp = t_1
else
tmp = -2.0d0
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 * (y / z);
double tmp;
if (z <= -1.4e-26) {
tmp = -2.0;
} else if (z <= -5.8e-182) {
tmp = t_1;
} else if (z <= 1.45e-233) {
tmp = t_0;
} else if (z <= 1.05e-188) {
tmp = t_1;
} else if (z <= 1.3e-154) {
tmp = t_0;
} else if (z <= 1.9e+62) {
tmp = t_1;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if z <= -1.4e-26: tmp = -2.0 elif z <= -5.8e-182: tmp = t_1 elif z <= 1.45e-233: tmp = t_0 elif z <= 1.05e-188: tmp = t_1 elif z <= 1.3e-154: tmp = t_0 elif z <= 1.9e+62: tmp = t_1 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -1.4e-26) tmp = -2.0; elseif (z <= -5.8e-182) tmp = t_1; elseif (z <= 1.45e-233) tmp = t_0; elseif (z <= 1.05e-188) tmp = t_1; elseif (z <= 1.3e-154) tmp = t_0; elseif (z <= 1.9e+62) tmp = t_1; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (z <= -1.4e-26) tmp = -2.0; elseif (z <= -5.8e-182) tmp = t_1; elseif (z <= 1.45e-233) tmp = t_0; elseif (z <= 1.05e-188) tmp = t_1; elseif (z <= 1.3e-154) tmp = t_0; elseif (z <= 1.9e+62) tmp = t_1; else tmp = -2.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[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.4e-26], -2.0, If[LessEqual[z, -5.8e-182], t$95$1, If[LessEqual[z, 1.45e-233], t$95$0, If[LessEqual[z, 1.05e-188], t$95$1, If[LessEqual[z, 1.3e-154], t$95$0, If[LessEqual[z, 1.9e+62], t$95$1, -2.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{-26}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-182}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-233}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-188}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.4000000000000001e-26 or 1.89999999999999992e62 < z Initial program 99.2%
*-commutative99.2%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 61.6%
if -1.4000000000000001e-26 < z < -5.79999999999999974e-182 or 1.44999999999999991e-233 < z < 1.05e-188 or 1.3e-154 < z < 1.89999999999999992e62Initial 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 inf 57.7%
if -5.79999999999999974e-182 < z < 1.44999999999999991e-233 or 1.05e-188 < z < 1.3e-154Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 76.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))))
(if (<= y -3.1e+187)
t_0
(if (<= y 1.65e+66) (* -4.0 (- 0.5 (/ x z))) t_0))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -3.1e+187) {
tmp = t_0;
} else if (y <= 1.65e+66) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
if (y <= (-3.1d+187)) then
tmp = t_0
else if (y <= 1.65d+66) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
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 * (y / z);
double tmp;
if (y <= -3.1e+187) {
tmp = t_0;
} else if (y <= 1.65e+66) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if y <= -3.1e+187: tmp = t_0 elif y <= 1.65e+66: tmp = -4.0 * (0.5 - (x / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -3.1e+187) tmp = t_0; elseif (y <= 1.65e+66) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (y <= -3.1e+187) tmp = t_0; elseif (y <= 1.65e+66) tmp = -4.0 * (0.5 - (x / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+187], t$95$0, If[LessEqual[y, 1.65e+66], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -3.1 \cdot 10^{+187}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+66}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.10000000000000012e187 or 1.6500000000000001e66 < y 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 inf 77.1%
if -3.10000000000000012e187 < y < 1.6500000000000001e66Initial program 99.5%
remove-double-neg99.5%
neg-mul-199.5%
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 85.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* -4.0 (- 0.5 (/ x z))))) (if (<= x -1.9e+44) t_0 (if (<= x 1.8e+97) (* -4.0 (- (/ y z) -0.5)) t_0))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (0.5 - (x / z));
double tmp;
if (x <= -1.9e+44) {
tmp = t_0;
} else if (x <= 1.8e+97) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (0.5d0 - (x / z))
if (x <= (-1.9d+44)) then
tmp = t_0
else if (x <= 1.8d+97) then
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
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 * (0.5 - (x / z));
double tmp;
if (x <= -1.9e+44) {
tmp = t_0;
} else if (x <= 1.8e+97) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (0.5 - (x / z)) tmp = 0 if x <= -1.9e+44: tmp = t_0 elif x <= 1.8e+97: tmp = -4.0 * ((y / z) - -0.5) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(0.5 - Float64(x / z))) tmp = 0.0 if (x <= -1.9e+44) tmp = t_0; elseif (x <= 1.8e+97) tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (0.5 - (x / z)); tmp = 0.0; if (x <= -1.9e+44) tmp = t_0; elseif (x <= 1.8e+97) tmp = -4.0 * ((y / z) - -0.5); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e+44], t$95$0, If[LessEqual[x, 1.8e+97], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+97}:\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.9000000000000001e44 or 1.79999999999999983e97 < x Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.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.5%
if -1.9000000000000001e44 < x < 1.79999999999999983e97Initial 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 inf 89.2%
(FPCore (x y z) :precision binary64 (if (<= z -1650.0) (* -4.0 (- (/ y z) -0.5)) (if (<= z 2e+64) (* 4.0 (/ (- x y) z)) (* -4.0 (- 0.5 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1650.0) {
tmp = -4.0 * ((y / z) - -0.5);
} else if (z <= 2e+64) {
tmp = 4.0 * ((x - 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 (z <= (-1650.0d0)) then
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
else if (z <= 2d+64) then
tmp = 4.0d0 * ((x - 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 (z <= -1650.0) {
tmp = -4.0 * ((y / z) - -0.5);
} else if (z <= 2e+64) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1650.0: tmp = -4.0 * ((y / z) - -0.5) elif z <= 2e+64: tmp = 4.0 * ((x - y) / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1650.0) tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); elseif (z <= 2e+64) tmp = Float64(4.0 * Float64(Float64(x - 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 (z <= -1650.0) tmp = -4.0 * ((y / z) - -0.5); elseif (z <= 2e+64) tmp = 4.0 * ((x - y) / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1650.0], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2e+64], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1650:\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+64}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if z < -1650Initial 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 inf 81.4%
if -1650 < z < 2.00000000000000004e64Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 90.7%
if 2.00000000000000004e64 < z Initial program 98.2%
remove-double-neg98.2%
neg-mul-198.2%
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 88.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.52e-27) -2.0 (if (<= z 5.1e+64) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.52e-27) {
tmp = -2.0;
} else if (z <= 5.1e+64) {
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 <= (-1.52d-27)) then
tmp = -2.0d0
else if (z <= 5.1d+64) 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 <= -1.52e-27) {
tmp = -2.0;
} else if (z <= 5.1e+64) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.52e-27: tmp = -2.0 elif z <= 5.1e+64: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.52e-27) tmp = -2.0; elseif (z <= 5.1e+64) 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 <= -1.52e-27) tmp = -2.0; elseif (z <= 5.1e+64) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.52e-27], -2.0, If[LessEqual[z, 5.1e+64], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.52 \cdot 10^{-27}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{+64}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.52000000000000004e-27 or 5.10000000000000024e64 < z Initial program 99.2%
*-commutative99.2%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 61.6%
if -1.52000000000000004e-27 < z < 5.10000000000000024e64Initial 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 inf 47.7%
(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%
*-commutative99.6%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 35.9%
(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 2024076 -o generate:simplify
(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))