
(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.4%
sub-neg99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (- -0.5 (/ y z)))))
(if (<= y -4.5e+36)
t_0
(if (<= y 3.8e+52)
(+ (* 4.0 (/ x z)) -2.0)
(if (<= y 3.25e+122) t_0 (* 4.0 (/ (- x y) z)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (-0.5 - (y / z));
double tmp;
if (y <= -4.5e+36) {
tmp = t_0;
} else if (y <= 3.8e+52) {
tmp = (4.0 * (x / z)) + -2.0;
} else if (y <= 3.25e+122) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 4.0d0 * ((-0.5d0) - (y / z))
if (y <= (-4.5d+36)) then
tmp = t_0
else if (y <= 3.8d+52) then
tmp = (4.0d0 * (x / z)) + (-2.0d0)
else if (y <= 3.25d+122) then
tmp = t_0
else
tmp = 4.0d0 * ((x - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (-0.5 - (y / z));
double tmp;
if (y <= -4.5e+36) {
tmp = t_0;
} else if (y <= 3.8e+52) {
tmp = (4.0 * (x / z)) + -2.0;
} else if (y <= 3.25e+122) {
tmp = t_0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (-0.5 - (y / z)) tmp = 0 if y <= -4.5e+36: tmp = t_0 elif y <= 3.8e+52: tmp = (4.0 * (x / z)) + -2.0 elif y <= 3.25e+122: tmp = t_0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(-0.5 - Float64(y / z))) tmp = 0.0 if (y <= -4.5e+36) tmp = t_0; elseif (y <= 3.8e+52) tmp = Float64(Float64(4.0 * Float64(x / z)) + -2.0); elseif (y <= 3.25e+122) tmp = t_0; else tmp = Float64(4.0 * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (-0.5 - (y / z)); tmp = 0.0; if (y <= -4.5e+36) tmp = t_0; elseif (y <= 3.8e+52) tmp = (4.0 * (x / z)) + -2.0; elseif (y <= 3.25e+122) tmp = t_0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+36], t$95$0, If[LessEqual[y, 3.8e+52], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[y, 3.25e+122], t$95$0, N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+52}:\\
\;\;\;\;4 \cdot \frac{x}{z} + -2\\
\mathbf{elif}\;y \leq 3.25 \cdot 10^{+122}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if y < -4.49999999999999997e36 or 3.8e52 < y < 3.24999999999999982e122Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 94.0%
div-sub94.0%
*-commutative94.0%
*-lft-identity94.0%
associate-*l/94.0%
associate-*r*94.0%
lft-mult-inverse94.0%
metadata-eval94.0%
Simplified94.0%
if -4.49999999999999997e36 < y < 3.8e52Initial program 100.0%
associate-*l/99.1%
sub-neg99.1%
distribute-rgt-neg-in99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 89.9%
metadata-eval89.9%
cancel-sign-sub-inv89.9%
div-sub89.9%
sub-neg89.9%
associate-/l*89.9%
*-lft-identity89.9%
associate-*l/89.8%
lft-mult-inverse89.9%
metadata-eval89.9%
metadata-eval89.9%
distribute-lft-in89.9%
metadata-eval89.9%
Simplified89.9%
if 3.24999999999999982e122 < 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 z around 0 100.0%
Final simplification92.5%
(FPCore (x y z)
:precision binary64
(if (<= y -5e+38)
(* 4.0 (/ (- (* z -0.5) y) z))
(if (<= y 5.3e+51)
(+ (* 4.0 (/ x z)) -2.0)
(if (<= y 7.6e+124) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e+38) {
tmp = 4.0 * (((z * -0.5) - y) / z);
} else if (y <= 5.3e+51) {
tmp = (4.0 * (x / z)) + -2.0;
} else if (y <= 7.6e+124) {
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 (y <= (-5d+38)) then
tmp = 4.0d0 * (((z * (-0.5d0)) - y) / z)
else if (y <= 5.3d+51) then
tmp = (4.0d0 * (x / z)) + (-2.0d0)
else if (y <= 7.6d+124) 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 (y <= -5e+38) {
tmp = 4.0 * (((z * -0.5) - y) / z);
} else if (y <= 5.3e+51) {
tmp = (4.0 * (x / z)) + -2.0;
} else if (y <= 7.6e+124) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e+38: tmp = 4.0 * (((z * -0.5) - y) / z) elif y <= 5.3e+51: tmp = (4.0 * (x / z)) + -2.0 elif y <= 7.6e+124: 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 (y <= -5e+38) tmp = Float64(4.0 * Float64(Float64(Float64(z * -0.5) - y) / z)); elseif (y <= 5.3e+51) tmp = Float64(Float64(4.0 * Float64(x / z)) + -2.0); elseif (y <= 7.6e+124) 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 (y <= -5e+38) tmp = 4.0 * (((z * -0.5) - y) / z); elseif (y <= 5.3e+51) tmp = (4.0 * (x / z)) + -2.0; elseif (y <= 7.6e+124) tmp = 4.0 * (-0.5 - (y / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e+38], N[(4.0 * N[(N[(N[(z * -0.5), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.3e+51], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[y, 7.6e+124], 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}\;y \leq -5 \cdot 10^{+38}:\\
\;\;\;\;4 \cdot \frac{z \cdot -0.5 - y}{z}\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{+51}:\\
\;\;\;\;4 \cdot \frac{x}{z} + -2\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+124}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if y < -4.9999999999999997e38Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 92.6%
if -4.9999999999999997e38 < y < 5.2999999999999997e51Initial program 100.0%
associate-*l/99.1%
sub-neg99.1%
distribute-rgt-neg-in99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 89.9%
metadata-eval89.9%
cancel-sign-sub-inv89.9%
div-sub89.9%
sub-neg89.9%
associate-/l*89.9%
*-lft-identity89.9%
associate-*l/89.8%
lft-mult-inverse89.9%
metadata-eval89.9%
metadata-eval89.9%
distribute-lft-in89.9%
metadata-eval89.9%
Simplified89.9%
if 5.2999999999999997e51 < y < 7.5999999999999997e124Initial program 99.9%
associate-*l/99.9%
sub-neg99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 99.5%
div-sub99.5%
*-commutative99.5%
*-lft-identity99.5%
associate-*l/99.5%
associate-*r*99.5%
lft-mult-inverse99.5%
metadata-eval99.5%
Simplified99.5%
if 7.5999999999999997e124 < 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 z around 0 100.0%
Final simplification92.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* y -4.0) z)))
(if (<= y -2.4e+39)
t_0
(if (<= y -5.2e-221) (* 4.0 (/ x z)) (if (<= y 4e+77) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = (y * -4.0) / z;
double tmp;
if (y <= -2.4e+39) {
tmp = t_0;
} else if (y <= -5.2e-221) {
tmp = 4.0 * (x / z);
} else if (y <= 4e+77) {
tmp = -2.0;
} 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 = (y * (-4.0d0)) / z
if (y <= (-2.4d+39)) then
tmp = t_0
else if (y <= (-5.2d-221)) then
tmp = 4.0d0 * (x / z)
else if (y <= 4d+77) then
tmp = -2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * -4.0) / z;
double tmp;
if (y <= -2.4e+39) {
tmp = t_0;
} else if (y <= -5.2e-221) {
tmp = 4.0 * (x / z);
} else if (y <= 4e+77) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * -4.0) / z tmp = 0 if y <= -2.4e+39: tmp = t_0 elif y <= -5.2e-221: tmp = 4.0 * (x / z) elif y <= 4e+77: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * -4.0) / z) tmp = 0.0 if (y <= -2.4e+39) tmp = t_0; elseif (y <= -5.2e-221) tmp = Float64(4.0 * Float64(x / z)); elseif (y <= 4e+77) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * -4.0) / z; tmp = 0.0; if (y <= -2.4e+39) tmp = t_0; elseif (y <= -5.2e-221) tmp = 4.0 * (x / z); elseif (y <= 4e+77) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -2.4e+39], t$95$0, If[LessEqual[y, -5.2e-221], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+77], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot -4}{z}\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-221}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+77}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.4000000000000001e39 or 3.99999999999999993e77 < 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 76.9%
*-commutative76.9%
associate-*l/76.9%
Simplified76.9%
if -2.4000000000000001e39 < y < -5.2000000000000004e-221Initial 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 61.3%
if -5.2000000000000004e-221 < y < 3.99999999999999993e77Initial program 99.9%
associate-*l/98.7%
sub-neg98.7%
distribute-rgt-neg-in98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in z around inf 54.5%
Final simplification64.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e+62) (not (<= x 1.05e+133))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+62) || !(x <= 1.05e+133)) {
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 <= (-5.8d+62)) .or. (.not. (x <= 1.05d+133))) 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 <= -5.8e+62) || !(x <= 1.05e+133)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e+62) or not (x <= 1.05e+133): 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 <= -5.8e+62) || !(x <= 1.05e+133)) 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 <= -5.8e+62) || ~((x <= 1.05e+133))) 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, -5.8e+62], N[Not[LessEqual[x, 1.05e+133]], $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 -5.8 \cdot 10^{+62} \lor \neg \left(x \leq 1.05 \cdot 10^{+133}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -5.79999999999999968e62 or 1.05e133 < 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 79.7%
if -5.79999999999999968e62 < x < 1.05e133Initial program 100.0%
associate-*l/99.2%
sub-neg99.2%
distribute-rgt-neg-in99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around 0 83.8%
div-sub83.8%
*-commutative83.8%
*-lft-identity83.8%
associate-*l/83.2%
associate-*r*83.2%
lft-mult-inverse83.8%
metadata-eval83.8%
Simplified83.8%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5e+49) (not (<= z 1.35e+62))) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+49) || !(z <= 1.35e+62)) {
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 <= (-5d+49)) .or. (.not. (z <= 1.35d+62))) 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 <= -5e+49) || !(z <= 1.35e+62)) {
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 <= -5e+49) or not (z <= 1.35e+62): 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 <= -5e+49) || !(z <= 1.35e+62)) 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 <= -5e+49) || ~((z <= 1.35e+62))) 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, -5e+49], N[Not[LessEqual[z, 1.35e+62]], $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 -5 \cdot 10^{+49} \lor \neg \left(z \leq 1.35 \cdot 10^{+62}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -5.0000000000000004e49 or 1.35e62 < 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 x around 0 90.5%
div-sub90.5%
*-commutative90.5%
*-lft-identity90.5%
associate-*l/90.4%
associate-*r*90.4%
lft-mult-inverse90.5%
metadata-eval90.5%
Simplified90.5%
if -5.0000000000000004e49 < z < 1.35e62Initial program 100.0%
associate-*l/99.1%
sub-neg99.1%
distribute-rgt-neg-in99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in z around 0 90.8%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (<= z -1.06e+44) -2.0 (if (<= z 1.35e+62) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.06e+44) {
tmp = -2.0;
} else if (z <= 1.35e+62) {
tmp = 4.0 * (x / 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.06d+44)) then
tmp = -2.0d0
else if (z <= 1.35d+62) then
tmp = 4.0d0 * (x / 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.06e+44) {
tmp = -2.0;
} else if (z <= 1.35e+62) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.06e+44: tmp = -2.0 elif z <= 1.35e+62: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.06e+44) tmp = -2.0; elseif (z <= 1.35e+62) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.06e+44) tmp = -2.0; elseif (z <= 1.35e+62) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.06e+44], -2.0, If[LessEqual[z, 1.35e+62], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \cdot 10^{+44}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+62}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.06e44 or 1.35e62 < 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 73.0%
if -1.06e44 < z < 1.35e62Initial program 100.0%
associate-*l/99.1%
sub-neg99.1%
distribute-rgt-neg-in99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 47.6%
Final simplification56.9%
(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.4%
sub-neg99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around inf 33.3%
Final simplification33.3%
(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 2023279
(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))