
(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.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
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 (/ y z))))
(if (<= x -1e+14)
t_0
(if (<= x -2.3e-100)
t_1
(if (<= x -5.3e-169)
-2.0
(if (<= x 1.75e-262)
t_1
(if (<= x 3.9e-212)
-2.0
(if (<= x 1.75e-158)
t_1
(if (<= x 4e-95) -2.0 (if (<= x 3.4e-31) t_1 t_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 (x <= -1e+14) {
tmp = t_0;
} else if (x <= -2.3e-100) {
tmp = t_1;
} else if (x <= -5.3e-169) {
tmp = -2.0;
} else if (x <= 1.75e-262) {
tmp = t_1;
} else if (x <= 3.9e-212) {
tmp = -2.0;
} else if (x <= 1.75e-158) {
tmp = t_1;
} else if (x <= 4e-95) {
tmp = -2.0;
} else if (x <= 3.4e-31) {
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) * (y / z)
if (x <= (-1d+14)) then
tmp = t_0
else if (x <= (-2.3d-100)) then
tmp = t_1
else if (x <= (-5.3d-169)) then
tmp = -2.0d0
else if (x <= 1.75d-262) then
tmp = t_1
else if (x <= 3.9d-212) then
tmp = -2.0d0
else if (x <= 1.75d-158) then
tmp = t_1
else if (x <= 4d-95) then
tmp = -2.0d0
else if (x <= 3.4d-31) 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 * (y / z);
double tmp;
if (x <= -1e+14) {
tmp = t_0;
} else if (x <= -2.3e-100) {
tmp = t_1;
} else if (x <= -5.3e-169) {
tmp = -2.0;
} else if (x <= 1.75e-262) {
tmp = t_1;
} else if (x <= 3.9e-212) {
tmp = -2.0;
} else if (x <= 1.75e-158) {
tmp = t_1;
} else if (x <= 4e-95) {
tmp = -2.0;
} else if (x <= 3.4e-31) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -1e+14: tmp = t_0 elif x <= -2.3e-100: tmp = t_1 elif x <= -5.3e-169: tmp = -2.0 elif x <= 1.75e-262: tmp = t_1 elif x <= 3.9e-212: tmp = -2.0 elif x <= 1.75e-158: tmp = t_1 elif x <= 4e-95: tmp = -2.0 elif x <= 3.4e-31: 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(y / z)) tmp = 0.0 if (x <= -1e+14) tmp = t_0; elseif (x <= -2.3e-100) tmp = t_1; elseif (x <= -5.3e-169) tmp = -2.0; elseif (x <= 1.75e-262) tmp = t_1; elseif (x <= 3.9e-212) tmp = -2.0; elseif (x <= 1.75e-158) tmp = t_1; elseif (x <= 4e-95) tmp = -2.0; elseif (x <= 3.4e-31) 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 * (y / z); tmp = 0.0; if (x <= -1e+14) tmp = t_0; elseif (x <= -2.3e-100) tmp = t_1; elseif (x <= -5.3e-169) tmp = -2.0; elseif (x <= 1.75e-262) tmp = t_1; elseif (x <= 3.9e-212) tmp = -2.0; elseif (x <= 1.75e-158) tmp = t_1; elseif (x <= 4e-95) tmp = -2.0; elseif (x <= 3.4e-31) 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[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e+14], t$95$0, If[LessEqual[x, -2.3e-100], t$95$1, If[LessEqual[x, -5.3e-169], -2.0, If[LessEqual[x, 1.75e-262], t$95$1, If[LessEqual[x, 3.9e-212], -2.0, If[LessEqual[x, 1.75e-158], t$95$1, If[LessEqual[x, 4e-95], -2.0, If[LessEqual[x, 3.4e-31], t$95$1, t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -1 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-100}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -5.3 \cdot 10^{-169}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-262}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-212}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-158}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-95}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-31}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1e14 or 3.4000000000000001e-31 < 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 65.8%
if -1e14 < x < -2.29999999999999994e-100 or -5.3e-169 < x < 1.75000000000000006e-262 or 3.9e-212 < x < 1.75000000000000006e-158 or 3.99999999999999996e-95 < x < 3.4000000000000001e-31Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 66.2%
if -2.29999999999999994e-100 < x < -5.3e-169 or 1.75000000000000006e-262 < x < 3.9e-212 or 1.75000000000000006e-158 < x < 3.99999999999999996e-95Initial 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 72.2%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -6e+65) (not (<= z 2.2e+16))) (- (* -4.0 (/ y z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+65) || !(z <= 2.2e+16)) {
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 <= (-6d+65)) .or. (.not. (z <= 2.2d+16))) 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 <= -6e+65) || !(z <= 2.2e+16)) {
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 <= -6e+65) or not (z <= 2.2e+16): 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 <= -6e+65) || !(z <= 2.2e+16)) 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 <= -6e+65) || ~((z <= 2.2e+16))) 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, -6e+65], N[Not[LessEqual[z, 2.2e+16]], $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 -6 \cdot 10^{+65} \lor \neg \left(z \leq 2.2 \cdot 10^{+16}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -6.0000000000000004e65 or 2.2e16 < z Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.7%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 81.3%
if -6.0000000000000004e65 < z < 2.2e16Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 93.4%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (<= z -2.3e+172) -2.0 (if (<= z 2.3e+170) (* 4.0 (/ (- x y) z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+172) {
tmp = -2.0;
} else if (z <= 2.3e+170) {
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 <= (-2.3d+172)) then
tmp = -2.0d0
else if (z <= 2.3d+170) 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 <= -2.3e+172) {
tmp = -2.0;
} else if (z <= 2.3e+170) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.3e+172: tmp = -2.0 elif z <= 2.3e+170: tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.3e+172) tmp = -2.0; elseif (z <= 2.3e+170) 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 <= -2.3e+172) tmp = -2.0; elseif (z <= 2.3e+170) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.3e+172], -2.0, If[LessEqual[z, 2.3e+170], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+172}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+170}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.3000000000000001e172 or 2.3000000000000001e170 < z Initial 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 87.2%
if -2.3000000000000001e172 < z < 2.3000000000000001e170Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 83.3%
Final simplification84.0%
(FPCore (x y z) :precision binary64 (if (<= x -0.0085) (* 4.0 (/ (- x y) z)) (if (<= x 4.2e-36) (- (* -4.0 (/ y z)) 2.0) (- (* 4.0 (/ x z)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.0085) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 4.2e-36) {
tmp = (-4.0 * (y / z)) - 2.0;
} 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 <= (-0.0085d0)) then
tmp = 4.0d0 * ((x - y) / z)
else if (x <= 4.2d-36) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
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 <= -0.0085) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 4.2e-36) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.0085: tmp = 4.0 * ((x - y) / z) elif x <= 4.2e-36: tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (4.0 * (x / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.0085) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (x <= 4.2e-36) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); 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 <= -0.0085) tmp = 4.0 * ((x - y) / z); elseif (x <= 4.2e-36) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (4.0 * (x / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.0085], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2e-36], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0085:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-36}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if x < -0.0085000000000000006Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 84.6%
if -0.0085000000000000006 < x < 4.19999999999999982e-36Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.8%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 94.8%
if 4.19999999999999982e-36 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.8%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 90.3%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -8e-21) (not (<= y 2.6e+77))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8e-21) || !(y <= 2.6e+77)) {
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 <= (-8d-21)) .or. (.not. (y <= 2.6d+77))) 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 <= -8e-21) || !(y <= 2.6e+77)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8e-21) or not (y <= 2.6e+77): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8e-21) || !(y <= 2.6e+77)) 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 <= -8e-21) || ~((y <= 2.6e+77))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8e-21], N[Not[LessEqual[y, 2.6e+77]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-21} \lor \neg \left(y \leq 2.6 \cdot 10^{+77}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -7.99999999999999926e-21 or 2.6000000000000002e77 < y 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 inf 61.2%
if -7.99999999999999926e-21 < y < 2.6000000000000002e77Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 43.8%
Final simplification52.3%
(FPCore (x y z) :precision binary64 (+ (* (- x y) (/ 4.0 z)) -2.0))
double code(double x, double y, double z) {
return ((x - y) * (4.0 / 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 = ((x - y) * (4.0d0 / z)) + (-2.0d0)
end function
public static double code(double x, double y, double z) {
return ((x - y) * (4.0 / z)) + -2.0;
}
def code(x, y, z): return ((x - y) * (4.0 / z)) + -2.0
function code(x, y, z) return Float64(Float64(Float64(x - y) * Float64(4.0 / z)) + -2.0) end
function tmp = code(x, y, z) tmp = ((x - y) * (4.0 / z)) + -2.0; end
code[x_, y_, z_] := N[(N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]
\begin{array}{l}
\\
\left(x - y\right) \cdot \frac{4}{z} + -2
\end{array}
Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.8%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
associate-*r/100.0%
associate-*l/99.8%
Applied egg-rr99.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%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 30.4%
Final simplification30.4%
(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 2023238
(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))