
(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 (fma 4.0 (/ (- x y) z) -2.0))
double code(double x, double y, double z) {
return fma(4.0, ((x - y) / z), -2.0);
}
function code(x, y, z) return fma(4.0, Float64(Float64(x - y) / z), -2.0) end
code[x_, y_, z_] := N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, \frac{x - y}{z}, -2\right)
\end{array}
Initial program 98.9%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.7%
associate-*l/98.8%
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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* (/ y z) -4.0)))
(if (<= x -1.65e+43)
t_0
(if (<= x -60.0)
t_1
(if (<= x -2.8e-31)
t_0
(if (<= x 3e-308)
-2.0
(if (<= x 1.7e-224)
t_1
(if (<= x 2.05e-189) -2.0 (if (<= x 1.55e+53) t_1 t_0)))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = (y / z) * -4.0;
double tmp;
if (x <= -1.65e+43) {
tmp = t_0;
} else if (x <= -60.0) {
tmp = t_1;
} else if (x <= -2.8e-31) {
tmp = t_0;
} else if (x <= 3e-308) {
tmp = -2.0;
} else if (x <= 1.7e-224) {
tmp = t_1;
} else if (x <= 2.05e-189) {
tmp = -2.0;
} else if (x <= 1.55e+53) {
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 = (y / z) * (-4.0d0)
if (x <= (-1.65d+43)) then
tmp = t_0
else if (x <= (-60.0d0)) then
tmp = t_1
else if (x <= (-2.8d-31)) then
tmp = t_0
else if (x <= 3d-308) then
tmp = -2.0d0
else if (x <= 1.7d-224) then
tmp = t_1
else if (x <= 2.05d-189) then
tmp = -2.0d0
else if (x <= 1.55d+53) 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 = (y / z) * -4.0;
double tmp;
if (x <= -1.65e+43) {
tmp = t_0;
} else if (x <= -60.0) {
tmp = t_1;
} else if (x <= -2.8e-31) {
tmp = t_0;
} else if (x <= 3e-308) {
tmp = -2.0;
} else if (x <= 1.7e-224) {
tmp = t_1;
} else if (x <= 2.05e-189) {
tmp = -2.0;
} else if (x <= 1.55e+53) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = (y / z) * -4.0 tmp = 0 if x <= -1.65e+43: tmp = t_0 elif x <= -60.0: tmp = t_1 elif x <= -2.8e-31: tmp = t_0 elif x <= 3e-308: tmp = -2.0 elif x <= 1.7e-224: tmp = t_1 elif x <= 2.05e-189: tmp = -2.0 elif x <= 1.55e+53: 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(Float64(y / z) * -4.0) tmp = 0.0 if (x <= -1.65e+43) tmp = t_0; elseif (x <= -60.0) tmp = t_1; elseif (x <= -2.8e-31) tmp = t_0; elseif (x <= 3e-308) tmp = -2.0; elseif (x <= 1.7e-224) tmp = t_1; elseif (x <= 2.05e-189) tmp = -2.0; elseif (x <= 1.55e+53) 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 = (y / z) * -4.0; tmp = 0.0; if (x <= -1.65e+43) tmp = t_0; elseif (x <= -60.0) tmp = t_1; elseif (x <= -2.8e-31) tmp = t_0; elseif (x <= 3e-308) tmp = -2.0; elseif (x <= 1.7e-224) tmp = t_1; elseif (x <= 2.05e-189) tmp = -2.0; elseif (x <= 1.55e+53) 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[(N[(y / z), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -1.65e+43], t$95$0, If[LessEqual[x, -60.0], t$95$1, If[LessEqual[x, -2.8e-31], t$95$0, If[LessEqual[x, 3e-308], -2.0, If[LessEqual[x, 1.7e-224], t$95$1, If[LessEqual[x, 2.05e-189], -2.0, If[LessEqual[x, 1.55e+53], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := \frac{y}{z} \cdot -4\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -60:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-308}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-224}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-189}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+53}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.6500000000000001e43 or -60 < x < -2.7999999999999999e-31 or 1.5500000000000001e53 < x Initial program 98.4%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 66.4%
if -1.6500000000000001e43 < x < -60 or 3.00000000000000022e-308 < x < 1.69999999999999996e-224 or 2.05000000000000015e-189 < x < 1.5500000000000001e53Initial program 98.6%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 61.4%
if -2.7999999999999999e-31 < x < 3.00000000000000022e-308 or 1.69999999999999996e-224 < x < 2.05000000000000015e-189Initial 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 58.3%
Final simplification63.0%
(FPCore (x y z)
:precision binary64
(if (or (<= x -6.5e+191)
(not (or (<= x -5e+151) (and (not (<= x -6e+74)) (<= x 2.9e+181)))))
(* 4.0 (/ x z))
(* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.5e+191) || !((x <= -5e+151) || (!(x <= -6e+74) && (x <= 2.9e+181)))) {
tmp = 4.0 * (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 <= (-6.5d+191)) .or. (.not. (x <= (-5d+151)) .or. (.not. (x <= (-6d+74))) .and. (x <= 2.9d+181))) then
tmp = 4.0d0 * (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 <= -6.5e+191) || !((x <= -5e+151) || (!(x <= -6e+74) && (x <= 2.9e+181)))) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.5e+191) or not ((x <= -5e+151) or (not (x <= -6e+74) and (x <= 2.9e+181))): tmp = 4.0 * (x / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.5e+191) || !((x <= -5e+151) || (!(x <= -6e+74) && (x <= 2.9e+181)))) tmp = Float64(4.0 * 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 <= -6.5e+191) || ~(((x <= -5e+151) || (~((x <= -6e+74)) && (x <= 2.9e+181))))) tmp = 4.0 * (x / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.5e+191], N[Not[Or[LessEqual[x, -5e+151], And[N[Not[LessEqual[x, -6e+74]], $MachinePrecision], LessEqual[x, 2.9e+181]]]], $MachinePrecision]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{+191} \lor \neg \left(x \leq -5 \cdot 10^{+151} \lor \neg \left(x \leq -6 \cdot 10^{+74}\right) \land x \leq 2.9 \cdot 10^{+181}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -6.50000000000000008e191 or -5.0000000000000002e151 < x < -6e74 or 2.9e181 < x Initial program 97.4%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 85.1%
if -6.50000000000000008e191 < x < -5.0000000000000002e151 or -6e74 < x < 2.9e181Initial program 99.5%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 81.1%
div-sub81.1%
*-commutative81.1%
*-lft-identity81.1%
associate-*l/81.0%
associate-*r*81.0%
lft-mult-inverse81.1%
metadata-eval81.1%
Simplified81.1%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.25e+42) (not (<= z 1.5e+197))) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+42) || !(z <= 1.5e+197)) {
tmp = 4.0 * (-0.5 - (y / z));
} 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 <= (-1.25d+42)) .or. (.not. (z <= 1.5d+197))) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
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 <= -1.25e+42) || !(z <= 1.5e+197)) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.25e+42) or not (z <= 1.5e+197): tmp = 4.0 * (-0.5 - (y / z)) else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.25e+42) || !(z <= 1.5e+197)) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); 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 <= -1.25e+42) || ~((z <= 1.5e+197))) tmp = 4.0 * (-0.5 - (y / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.25e+42], N[Not[LessEqual[z, 1.5e+197]], $MachinePrecision]], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+42} \lor \neg \left(z \leq 1.5 \cdot 10^{+197}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -1.25000000000000002e42 or 1.5000000000000001e197 < 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 x around 0 84.1%
div-sub84.1%
*-commutative84.1%
*-lft-identity84.1%
associate-*l/83.9%
associate-*r*83.9%
lft-mult-inverse84.1%
metadata-eval84.1%
Simplified84.1%
if -1.25000000000000002e42 < z < 1.5000000000000001e197Initial program 98.4%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 87.6%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.6e+99) (not (<= z 5.5e-20))) (+ -2.0 (* 4.0 (/ x z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e+99) || !(z <= 5.5e-20)) {
tmp = -2.0 + (4.0 * (x / z));
} 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 <= (-5.6d+99)) .or. (.not. (z <= 5.5d-20))) then
tmp = (-2.0d0) + (4.0d0 * (x / z))
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 <= -5.6e+99) || !(z <= 5.5e-20)) {
tmp = -2.0 + (4.0 * (x / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.6e+99) or not (z <= 5.5e-20): tmp = -2.0 + (4.0 * (x / z)) else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.6e+99) || !(z <= 5.5e-20)) tmp = Float64(-2.0 + Float64(4.0 * Float64(x / z))); 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 <= -5.6e+99) || ~((z <= 5.5e-20))) tmp = -2.0 + (4.0 * (x / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.6e+99], N[Not[LessEqual[z, 5.5e-20]], $MachinePrecision]], N[(-2.0 + N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+99} \lor \neg \left(z \leq 5.5 \cdot 10^{-20}\right):\\
\;\;\;\;-2 + 4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -5.6e99 or 5.4999999999999996e-20 < z Initial program 98.0%
associate-*l/99.5%
sub-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 89.3%
+-commutative89.3%
metadata-eval89.3%
cancel-sign-sub-inv89.3%
div-sub89.4%
sub-neg89.4%
associate-/l*89.4%
*-rgt-identity89.4%
*-commutative89.4%
associate-*l/89.2%
lft-mult-inverse89.4%
metadata-eval89.4%
metadata-eval89.4%
distribute-lft-in89.4%
metadata-eval89.4%
Simplified89.4%
if -5.6e99 < z < 5.4999999999999996e-20Initial program 99.4%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 91.1%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (* (/ 4.0 z) (+ (- x y) (* z -0.5))))
double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (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 / z) * ((x - y) + (z * (-0.5d0)))
end function
public static double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (z * -0.5));
}
def code(x, y, z): return (4.0 / z) * ((x - y) + (z * -0.5))
function code(x, y, z) return Float64(Float64(4.0 / z) * Float64(Float64(x - y) + Float64(z * -0.5))) end
function tmp = code(x, y, z) tmp = (4.0 / z) * ((x - y) + (z * -0.5)); end
code[x_, y_, z_] := N[(N[(4.0 / z), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{z} \cdot \left(\left(x - y\right) + z \cdot -0.5\right)
\end{array}
Initial program 98.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= z -2.45e+106) -2.0 (if (<= z 6e-20) (* (/ y z) -4.0) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.45e+106) {
tmp = -2.0;
} else if (z <= 6e-20) {
tmp = (y / z) * -4.0;
} 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.45d+106)) then
tmp = -2.0d0
else if (z <= 6d-20) then
tmp = (y / z) * (-4.0d0)
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.45e+106) {
tmp = -2.0;
} else if (z <= 6e-20) {
tmp = (y / z) * -4.0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.45e+106: tmp = -2.0 elif z <= 6e-20: tmp = (y / z) * -4.0 else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.45e+106) tmp = -2.0; elseif (z <= 6e-20) tmp = Float64(Float64(y / z) * -4.0); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.45e+106) tmp = -2.0; elseif (z <= 6e-20) tmp = (y / z) * -4.0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.45e+106], -2.0, If[LessEqual[z, 6e-20], N[(N[(y / z), $MachinePrecision] * -4.0), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{+106}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-20}:\\
\;\;\;\;\frac{y}{z} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.44999999999999999e106 or 6.00000000000000057e-20 < z Initial program 98.0%
associate-*l/99.5%
sub-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in z around inf 65.4%
if -2.44999999999999999e106 < z < 6.00000000000000057e-20Initial program 99.4%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 46.6%
Final simplification53.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 98.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 31.1%
Final simplification31.1%
(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 2023208
(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))