
(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 10 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 100.0%
associate-*l/99.7%
sub-neg99.7%
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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= z -4.1e+69)
-2.0
(if (<= z -0.00026)
t_1
(if (<= z 6.2e-235)
t_0
(if (<= z 4.3e-160) t_1 (if (<= z 1.95e+92) t_0 -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 <= -4.1e+69) {
tmp = -2.0;
} else if (z <= -0.00026) {
tmp = t_1;
} else if (z <= 6.2e-235) {
tmp = t_0;
} else if (z <= 4.3e-160) {
tmp = t_1;
} else if (z <= 1.95e+92) {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (z <= (-4.1d+69)) then
tmp = -2.0d0
else if (z <= (-0.00026d0)) then
tmp = t_1
else if (z <= 6.2d-235) then
tmp = t_0
else if (z <= 4.3d-160) then
tmp = t_1
else if (z <= 1.95d+92) then
tmp = t_0
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 <= -4.1e+69) {
tmp = -2.0;
} else if (z <= -0.00026) {
tmp = t_1;
} else if (z <= 6.2e-235) {
tmp = t_0;
} else if (z <= 4.3e-160) {
tmp = t_1;
} else if (z <= 1.95e+92) {
tmp = t_0;
} 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 <= -4.1e+69: tmp = -2.0 elif z <= -0.00026: tmp = t_1 elif z <= 6.2e-235: tmp = t_0 elif z <= 4.3e-160: tmp = t_1 elif z <= 1.95e+92: tmp = t_0 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 <= -4.1e+69) tmp = -2.0; elseif (z <= -0.00026) tmp = t_1; elseif (z <= 6.2e-235) tmp = t_0; elseif (z <= 4.3e-160) tmp = t_1; elseif (z <= 1.95e+92) tmp = t_0; 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 <= -4.1e+69) tmp = -2.0; elseif (z <= -0.00026) tmp = t_1; elseif (z <= 6.2e-235) tmp = t_0; elseif (z <= 4.3e-160) tmp = t_1; elseif (z <= 1.95e+92) tmp = t_0; 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, -4.1e+69], -2.0, If[LessEqual[z, -0.00026], t$95$1, If[LessEqual[z, 6.2e-235], t$95$0, If[LessEqual[z, 4.3e-160], t$95$1, If[LessEqual[z, 1.95e+92], t$95$0, -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 -4.1 \cdot 10^{+69}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -0.00026:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-235}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-160}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+92}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.0999999999999999e69 or 1.95000000000000006e92 < z Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 67.1%
if -4.0999999999999999e69 < z < -2.59999999999999977e-4 or 6.2e-235 < z < 4.30000000000000014e-160Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 72.8%
if -2.59999999999999977e-4 < z < 6.2e-235 or 4.30000000000000014e-160 < z < 1.95000000000000006e92Initial 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 inf 61.9%
Final simplification65.2%
(FPCore (x y z)
:precision binary64
(if (<= z -8e+151)
-2.0
(if (or (<= z -2.8e+133) (and (not (<= z -4.3e+91)) (<= z 1e+180)))
(* (- x y) (/ 4.0 z))
-2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8e+151) {
tmp = -2.0;
} else if ((z <= -2.8e+133) || (!(z <= -4.3e+91) && (z <= 1e+180))) {
tmp = (x - 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 <= (-8d+151)) then
tmp = -2.0d0
else if ((z <= (-2.8d+133)) .or. (.not. (z <= (-4.3d+91))) .and. (z <= 1d+180)) then
tmp = (x - 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 <= -8e+151) {
tmp = -2.0;
} else if ((z <= -2.8e+133) || (!(z <= -4.3e+91) && (z <= 1e+180))) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8e+151: tmp = -2.0 elif (z <= -2.8e+133) or (not (z <= -4.3e+91) and (z <= 1e+180)): tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8e+151) tmp = -2.0; elseif ((z <= -2.8e+133) || (!(z <= -4.3e+91) && (z <= 1e+180))) tmp = Float64(Float64(x - 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 <= -8e+151) tmp = -2.0; elseif ((z <= -2.8e+133) || (~((z <= -4.3e+91)) && (z <= 1e+180))) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8e+151], -2.0, If[Or[LessEqual[z, -2.8e+133], And[N[Not[LessEqual[z, -4.3e+91]], $MachinePrecision], LessEqual[z, 1e+180]]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+151}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{+133} \lor \neg \left(z \leq -4.3 \cdot 10^{+91}\right) \land z \leq 10^{+180}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -8.00000000000000014e151 or -2.80000000000000016e133 < z < -4.3000000000000001e91 or 1e180 < z Initial program 99.9%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 78.9%
if -8.00000000000000014e151 < z < -2.80000000000000016e133 or -4.3000000000000001e91 < z < 1e180Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 88.1%
associate-/r/88.1%
Applied egg-rr88.1%
Final simplification85.4%
(FPCore (x y z)
:precision binary64
(if (<= z -3.6e+191)
(- (* 4.0 (/ x z)) 2.0)
(if (or (<= z -0.00096) (not (<= z 8.2e+83)))
(- (* -4.0 (/ y z)) 2.0)
(* (- x y) (/ 4.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.6e+191) {
tmp = (4.0 * (x / z)) - 2.0;
} else if ((z <= -0.00096) || !(z <= 8.2e+83)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / 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 <= (-3.6d+191)) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else if ((z <= (-0.00096d0)) .or. (.not. (z <= 8.2d+83))) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.6e+191) {
tmp = (4.0 * (x / z)) - 2.0;
} else if ((z <= -0.00096) || !(z <= 8.2e+83)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.6e+191: tmp = (4.0 * (x / z)) - 2.0 elif (z <= -0.00096) or not (z <= 8.2e+83): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.6e+191) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); elseif ((z <= -0.00096) || !(z <= 8.2e+83)) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.6e+191) tmp = (4.0 * (x / z)) - 2.0; elseif ((z <= -0.00096) || ~((z <= 8.2e+83))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.6e+191], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], If[Or[LessEqual[z, -0.00096], N[Not[LessEqual[z, 8.2e+83]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+191}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{elif}\;z \leq -0.00096 \lor \neg \left(z \leq 8.2 \cdot 10^{+83}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -3.5999999999999999e191Initial program 99.9%
associate-*l/99.6%
sub-neg99.6%
distribute-lft-in99.7%
associate-*l/99.8%
associate-*r/99.8%
fma-def99.8%
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 96.5%
if -3.5999999999999999e191 < z < -9.60000000000000024e-4 or 8.2000000000000002e83 < z Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-lft-in99.6%
associate-*l/99.8%
associate-*r/99.8%
fma-def99.8%
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 88.5%
if -9.60000000000000024e-4 < z < 8.2000000000000002e83Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 91.9%
associate-/r/91.9%
Applied egg-rr91.9%
Final simplification91.2%
(FPCore (x y z)
:precision binary64
(if (<= z -3.2e+191)
(- (* 4.0 (/ x z)) 2.0)
(if (or (<= z -0.38) (not (<= z 9.6e+83)))
(- (* -4.0 (/ y z)) 2.0)
(/ 4.0 (/ z (- x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.2e+191) {
tmp = (4.0 * (x / z)) - 2.0;
} else if ((z <= -0.38) || !(z <= 9.6e+83)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 / (z / (x - y));
}
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 <= (-3.2d+191)) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else if ((z <= (-0.38d0)) .or. (.not. (z <= 9.6d+83))) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = 4.0d0 / (z / (x - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.2e+191) {
tmp = (4.0 * (x / z)) - 2.0;
} else if ((z <= -0.38) || !(z <= 9.6e+83)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 / (z / (x - y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.2e+191: tmp = (4.0 * (x / z)) - 2.0 elif (z <= -0.38) or not (z <= 9.6e+83): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = 4.0 / (z / (x - y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.2e+191) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); elseif ((z <= -0.38) || !(z <= 9.6e+83)) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(4.0 / Float64(z / Float64(x - y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.2e+191) tmp = (4.0 * (x / z)) - 2.0; elseif ((z <= -0.38) || ~((z <= 9.6e+83))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = 4.0 / (z / (x - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.2e+191], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], If[Or[LessEqual[z, -0.38], N[Not[LessEqual[z, 9.6e+83]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(4.0 / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+191}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{elif}\;z \leq -0.38 \lor \neg \left(z \leq 9.6 \cdot 10^{+83}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{4}{\frac{z}{x - y}}\\
\end{array}
\end{array}
if z < -3.2000000000000002e191Initial program 99.9%
associate-*l/99.6%
sub-neg99.6%
distribute-lft-in99.7%
associate-*l/99.8%
associate-*r/99.8%
fma-def99.8%
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 96.5%
if -3.2000000000000002e191 < z < -0.38 or 9.59999999999999965e83 < z Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-lft-in99.6%
associate-*l/99.8%
associate-*r/99.8%
fma-def99.8%
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 88.4%
if -0.38 < z < 9.59999999999999965e83Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 91.9%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.0017) (not (<= z 6e+84))) (- (* -4.0 (/ y z)) 2.0) (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0017) || !(z <= 6e+84)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / 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 <= (-0.0017d0)) .or. (.not. (z <= 6d+84))) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.0017) || !(z <= 6e+84)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.0017) or not (z <= 6e+84): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.0017) || !(z <= 6e+84)) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.0017) || ~((z <= 6e+84))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.0017], N[Not[LessEqual[z, 6e+84]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0017 \lor \neg \left(z \leq 6 \cdot 10^{+84}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -0.00169999999999999991 or 5.99999999999999992e84 < z Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-lft-in99.6%
associate-*l/99.8%
associate-*r/99.8%
fma-def99.8%
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 86.2%
if -0.00169999999999999991 < z < 5.99999999999999992e84Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 91.9%
associate-/r/91.9%
Applied egg-rr91.9%
Final simplification89.4%
(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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -2050000000.0) (not (<= y 6.1e+78))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2050000000.0) || !(y <= 6.1e+78)) {
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 <= (-2050000000.0d0)) .or. (.not. (y <= 6.1d+78))) 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 <= -2050000000.0) || !(y <= 6.1e+78)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2050000000.0) or not (y <= 6.1e+78): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2050000000.0) || !(y <= 6.1e+78)) 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 <= -2050000000.0) || ~((y <= 6.1e+78))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2050000000.0], N[Not[LessEqual[y, 6.1e+78]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2050000000 \lor \neg \left(y \leq 6.1 \cdot 10^{+78}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -2.05e9 or 6.10000000000000011e78 < y Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 63.7%
if -2.05e9 < y < 6.10000000000000011e78Initial 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 45.9%
Final simplification53.9%
(FPCore (x y z) :precision binary64 (+ -2.0 (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
return -2.0 + ((x - y) * (4.0 / z));
}
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) + ((x - y) * (4.0d0 / z))
end function
public static double code(double x, double y, double z) {
return -2.0 + ((x - y) * (4.0 / z));
}
def code(x, y, z): return -2.0 + ((x - y) * (4.0 / z))
function code(x, y, z) return Float64(-2.0 + Float64(Float64(x - y) * Float64(4.0 / z))) end
function tmp = code(x, y, z) tmp = -2.0 + ((x - y) * (4.0 / z)); end
code[x_, y_, z_] := N[(-2.0 + N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 + \left(x - y\right) \cdot \frac{4}{z}
\end{array}
Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
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%
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.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 32.8%
Final simplification32.8%
(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 2023257
(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))