
(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 99.2%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))) (t_1 (* 4.0 (/ x z))))
(if (<= z -6.5e+170)
-2.0
(if (<= z -5.2e+83)
t_1
(if (<= z -780000.0)
-2.0
(if (<= z -4.6e-76)
t_1
(if (<= z 2.7e-207)
t_0
(if (<= z 1.95e-80) t_1 (if (<= z 1.08e+83) t_0 -2.0)))))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -6.5e+170) {
tmp = -2.0;
} else if (z <= -5.2e+83) {
tmp = t_1;
} else if (z <= -780000.0) {
tmp = -2.0;
} else if (z <= -4.6e-76) {
tmp = t_1;
} else if (z <= 2.7e-207) {
tmp = t_0;
} else if (z <= 1.95e-80) {
tmp = t_1;
} else if (z <= 1.08e+83) {
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 = y * ((-4.0d0) / z)
t_1 = 4.0d0 * (x / z)
if (z <= (-6.5d+170)) then
tmp = -2.0d0
else if (z <= (-5.2d+83)) then
tmp = t_1
else if (z <= (-780000.0d0)) then
tmp = -2.0d0
else if (z <= (-4.6d-76)) then
tmp = t_1
else if (z <= 2.7d-207) then
tmp = t_0
else if (z <= 1.95d-80) then
tmp = t_1
else if (z <= 1.08d+83) 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 = y * (-4.0 / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -6.5e+170) {
tmp = -2.0;
} else if (z <= -5.2e+83) {
tmp = t_1;
} else if (z <= -780000.0) {
tmp = -2.0;
} else if (z <= -4.6e-76) {
tmp = t_1;
} else if (z <= 2.7e-207) {
tmp = t_0;
} else if (z <= 1.95e-80) {
tmp = t_1;
} else if (z <= 1.08e+83) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) t_1 = 4.0 * (x / z) tmp = 0 if z <= -6.5e+170: tmp = -2.0 elif z <= -5.2e+83: tmp = t_1 elif z <= -780000.0: tmp = -2.0 elif z <= -4.6e-76: tmp = t_1 elif z <= 2.7e-207: tmp = t_0 elif z <= 1.95e-80: tmp = t_1 elif z <= 1.08e+83: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-4.0 / z)) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (z <= -6.5e+170) tmp = -2.0; elseif (z <= -5.2e+83) tmp = t_1; elseif (z <= -780000.0) tmp = -2.0; elseif (z <= -4.6e-76) tmp = t_1; elseif (z <= 2.7e-207) tmp = t_0; elseif (z <= 1.95e-80) tmp = t_1; elseif (z <= 1.08e+83) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (-4.0 / z); t_1 = 4.0 * (x / z); tmp = 0.0; if (z <= -6.5e+170) tmp = -2.0; elseif (z <= -5.2e+83) tmp = t_1; elseif (z <= -780000.0) tmp = -2.0; elseif (z <= -4.6e-76) tmp = t_1; elseif (z <= 2.7e-207) tmp = t_0; elseif (z <= 1.95e-80) tmp = t_1; elseif (z <= 1.08e+83) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e+170], -2.0, If[LessEqual[z, -5.2e+83], t$95$1, If[LessEqual[z, -780000.0], -2.0, If[LessEqual[z, -4.6e-76], t$95$1, If[LessEqual[z, 2.7e-207], t$95$0, If[LessEqual[z, 1.95e-80], t$95$1, If[LessEqual[z, 1.08e+83], t$95$0, -2.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -6.5 \cdot 10^{+170}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{+83}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -780000:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -4.6 \cdot 10^{-76}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-207}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-80}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.08 \cdot 10^{+83}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -6.5e170 or -5.2000000000000002e83 < z < -7.8e5 or 1.08e83 < z Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 71.3%
if -6.5e170 < z < -5.2000000000000002e83 or -7.8e5 < z < -4.60000000000000012e-76 or 2.7e-207 < z < 1.9499999999999999e-80Initial 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.4%
*-commutative65.4%
Simplified65.4%
if -4.60000000000000012e-76 < z < 2.7e-207 or 1.9499999999999999e-80 < z < 1.08e83Initial program 99.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 64.0%
*-commutative64.0%
Simplified64.0%
Taylor expanded in y around 0 64.0%
associate-*r/64.0%
associate-*l/64.0%
*-commutative64.0%
Simplified64.0%
Final simplification67.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ y z) -4.0)) (t_1 (* 4.0 (/ x z))))
(if (<= z -4.2e+170)
-2.0
(if (<= z -8.2e+83)
t_1
(if (<= z -1300000.0)
-2.0
(if (<= z -6e-73)
t_1
(if (<= z 1.3e-207)
t_0
(if (<= z 1.75e-80) t_1 (if (<= z 1.1e+83) t_0 -2.0)))))))))
double code(double x, double y, double z) {
double t_0 = (y / z) * -4.0;
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -4.2e+170) {
tmp = -2.0;
} else if (z <= -8.2e+83) {
tmp = t_1;
} else if (z <= -1300000.0) {
tmp = -2.0;
} else if (z <= -6e-73) {
tmp = t_1;
} else if (z <= 1.3e-207) {
tmp = t_0;
} else if (z <= 1.75e-80) {
tmp = t_1;
} else if (z <= 1.1e+83) {
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 = (y / z) * (-4.0d0)
t_1 = 4.0d0 * (x / z)
if (z <= (-4.2d+170)) then
tmp = -2.0d0
else if (z <= (-8.2d+83)) then
tmp = t_1
else if (z <= (-1300000.0d0)) then
tmp = -2.0d0
else if (z <= (-6d-73)) then
tmp = t_1
else if (z <= 1.3d-207) then
tmp = t_0
else if (z <= 1.75d-80) then
tmp = t_1
else if (z <= 1.1d+83) 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 = (y / z) * -4.0;
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -4.2e+170) {
tmp = -2.0;
} else if (z <= -8.2e+83) {
tmp = t_1;
} else if (z <= -1300000.0) {
tmp = -2.0;
} else if (z <= -6e-73) {
tmp = t_1;
} else if (z <= 1.3e-207) {
tmp = t_0;
} else if (z <= 1.75e-80) {
tmp = t_1;
} else if (z <= 1.1e+83) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (y / z) * -4.0 t_1 = 4.0 * (x / z) tmp = 0 if z <= -4.2e+170: tmp = -2.0 elif z <= -8.2e+83: tmp = t_1 elif z <= -1300000.0: tmp = -2.0 elif z <= -6e-73: tmp = t_1 elif z <= 1.3e-207: tmp = t_0 elif z <= 1.75e-80: tmp = t_1 elif z <= 1.1e+83: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y / z) * -4.0) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (z <= -4.2e+170) tmp = -2.0; elseif (z <= -8.2e+83) tmp = t_1; elseif (z <= -1300000.0) tmp = -2.0; elseif (z <= -6e-73) tmp = t_1; elseif (z <= 1.3e-207) tmp = t_0; elseif (z <= 1.75e-80) tmp = t_1; elseif (z <= 1.1e+83) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y / z) * -4.0; t_1 = 4.0 * (x / z); tmp = 0.0; if (z <= -4.2e+170) tmp = -2.0; elseif (z <= -8.2e+83) tmp = t_1; elseif (z <= -1300000.0) tmp = -2.0; elseif (z <= -6e-73) tmp = t_1; elseif (z <= 1.3e-207) tmp = t_0; elseif (z <= 1.75e-80) tmp = t_1; elseif (z <= 1.1e+83) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * -4.0), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+170], -2.0, If[LessEqual[z, -8.2e+83], t$95$1, If[LessEqual[z, -1300000.0], -2.0, If[LessEqual[z, -6e-73], t$95$1, If[LessEqual[z, 1.3e-207], t$95$0, If[LessEqual[z, 1.75e-80], t$95$1, If[LessEqual[z, 1.1e+83], t$95$0, -2.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{z} \cdot -4\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+170}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -8.2 \cdot 10^{+83}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1300000:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-207}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{-80}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+83}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.19999999999999996e170 or -8.2000000000000002e83 < z < -1.3e6 or 1.09999999999999999e83 < z Initial program 99.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 71.3%
if -4.19999999999999996e170 < z < -8.2000000000000002e83 or -1.3e6 < z < -6e-73 or 1.3e-207 < z < 1.75000000000000007e-80Initial 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.4%
*-commutative65.4%
Simplified65.4%
if -6e-73 < z < 1.3e-207 or 1.75000000000000007e-80 < z < 1.09999999999999999e83Initial program 99.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 64.0%
*-commutative64.0%
Simplified64.0%
Final simplification67.4%
(FPCore (x y z)
:precision binary64
(if (<= z -1.4e+171)
-2.0
(if (or (<= z -3.5e+82) (and (not (<= z -70000000.0)) (<= z 8.5e+174)))
(* 4.0 (/ (- x y) z))
-2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+171) {
tmp = -2.0;
} else if ((z <= -3.5e+82) || (!(z <= -70000000.0) && (z <= 8.5e+174))) {
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 <= (-1.4d+171)) then
tmp = -2.0d0
else if ((z <= (-3.5d+82)) .or. (.not. (z <= (-70000000.0d0))) .and. (z <= 8.5d+174)) 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 <= -1.4e+171) {
tmp = -2.0;
} else if ((z <= -3.5e+82) || (!(z <= -70000000.0) && (z <= 8.5e+174))) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.4e+171: tmp = -2.0 elif (z <= -3.5e+82) or (not (z <= -70000000.0) and (z <= 8.5e+174)): tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.4e+171) tmp = -2.0; elseif ((z <= -3.5e+82) || (!(z <= -70000000.0) && (z <= 8.5e+174))) 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 <= -1.4e+171) tmp = -2.0; elseif ((z <= -3.5e+82) || (~((z <= -70000000.0)) && (z <= 8.5e+174))) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.4e+171], -2.0, If[Or[LessEqual[z, -3.5e+82], And[N[Not[LessEqual[z, -70000000.0]], $MachinePrecision], LessEqual[z, 8.5e+174]]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+171}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{+82} \lor \neg \left(z \leq -70000000\right) \land z \leq 8.5 \cdot 10^{+174}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.40000000000000002e171 or -3.5e82 < z < -7e7 or 8.5000000000000007e174 < z Initial program 98.8%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 77.6%
if -1.40000000000000002e171 < z < -3.5e82 or -7e7 < z < 8.5000000000000007e174Initial program 99.4%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 85.7%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.9e-50) (not (<= z 1.8e+63))) (- (* 4.0 (/ x z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.9e-50) || !(z <= 1.8e+63)) {
tmp = (4.0 * (x / 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 <= (-4.9d-50)) .or. (.not. (z <= 1.8d+63))) then
tmp = (4.0d0 * (x / 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 <= -4.9e-50) || !(z <= 1.8e+63)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.9e-50) or not (z <= 1.8e+63): tmp = (4.0 * (x / z)) - 2.0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.9e-50) || !(z <= 1.8e+63)) tmp = Float64(Float64(4.0 * Float64(x / 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 <= -4.9e-50) || ~((z <= 1.8e+63))) tmp = (4.0 * (x / z)) - 2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.9e-50], N[Not[LessEqual[z, 1.8e+63]], $MachinePrecision]], N[(N[(4.0 * N[(x / 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 -4.9 \cdot 10^{-50} \lor \neg \left(z \leq 1.8 \cdot 10^{+63}\right):\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -4.8999999999999999e-50 or 1.79999999999999999e63 < z Initial program 99.2%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around 0 100.0%
Taylor expanded in x around inf 85.1%
if -4.8999999999999999e-50 < z < 1.79999999999999999e63Initial program 99.2%
associate-*r/100.0%
associate--l-100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 92.6%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.72e+59) (not (<= y 3.9e+102))) (- (/ y (* z -0.25)) 2.0) (- (* 4.0 (/ x z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.72e+59) || !(y <= 3.9e+102)) {
tmp = (y / (z * -0.25)) - 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 ((y <= (-1.72d+59)) .or. (.not. (y <= 3.9d+102))) then
tmp = (y / (z * (-0.25d0))) - 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 ((y <= -1.72e+59) || !(y <= 3.9e+102)) {
tmp = (y / (z * -0.25)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.72e+59) or not (y <= 3.9e+102): tmp = (y / (z * -0.25)) - 2.0 else: tmp = (4.0 * (x / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.72e+59) || !(y <= 3.9e+102)) tmp = Float64(Float64(y / Float64(z * -0.25)) - 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 ((y <= -1.72e+59) || ~((y <= 3.9e+102))) tmp = (y / (z * -0.25)) - 2.0; else tmp = (4.0 * (x / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.72e+59], N[Not[LessEqual[y, 3.9e+102]], $MachinePrecision]], N[(N[(y / N[(z * -0.25), $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}\;y \leq -1.72 \cdot 10^{+59} \lor \neg \left(y \leq 3.9 \cdot 10^{+102}\right):\\
\;\;\;\;\frac{y}{z \cdot -0.25} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if y < -1.71999999999999996e59 or 3.8999999999999998e102 < y Initial program 99.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.0%
Taylor expanded in x around 0 91.9%
neg-mul-191.9%
distribute-neg-frac91.9%
Simplified91.9%
associate-*r/90.9%
neg-mul-190.9%
associate-*r*90.9%
metadata-eval90.9%
*-commutative90.9%
associate-/l*91.9%
div-inv91.9%
metadata-eval91.9%
Applied egg-rr91.9%
if -1.71999999999999996e59 < y < 3.8999999999999998e102Initial program 99.4%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.0%
Taylor expanded in x around inf 89.3%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= z -7e-73) -2.0 (if (<= z 6.8e+79) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -7e-73) {
tmp = -2.0;
} else if (z <= 6.8e+79) {
tmp = 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 <= (-7d-73)) then
tmp = -2.0d0
else if (z <= 6.8d+79) then
tmp = 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 <= -7e-73) {
tmp = -2.0;
} else if (z <= 6.8e+79) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7e-73: tmp = -2.0 elif z <= 6.8e+79: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7e-73) tmp = -2.0; elseif (z <= 6.8e+79) tmp = Float64(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 <= -7e-73) tmp = -2.0; elseif (z <= 6.8e+79) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7e-73], -2.0, If[LessEqual[z, 6.8e+79], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{-73}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{+79}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -6.9999999999999995e-73 or 6.80000000000000063e79 < z Initial program 99.2%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 61.6%
if -6.9999999999999995e-73 < z < 6.80000000000000063e79Initial program 99.2%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 55.7%
*-commutative55.7%
Simplified55.7%
Taylor expanded in y around 0 55.7%
associate-*r/55.7%
associate-*l/55.7%
*-commutative55.7%
Simplified55.7%
Final simplification58.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 99.2%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 36.5%
Final simplification36.5%
(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 2023274
(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))