
(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 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / 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) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= y -1.4e+177)
(and (not (<= y -2.8e+80))
(or (<= y -4.2e+56)
(and (not (<= y -9.5e+14))
(or (<= y -8400000.0) (not (<= y 1.65e+183)))))))
(* -4.0 (/ y z))
(* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+177) || (!(y <= -2.8e+80) && ((y <= -4.2e+56) || (!(y <= -9.5e+14) && ((y <= -8400000.0) || !(y <= 1.65e+183)))))) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / 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 <= (-1.4d+177)) .or. (.not. (y <= (-2.8d+80))) .and. (y <= (-4.2d+56)) .or. (.not. (y <= (-9.5d+14))) .and. (y <= (-8400000.0d0)) .or. (.not. (y <= 1.65d+183))) then
tmp = (-4.0d0) * (y / z)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+177) || (!(y <= -2.8e+80) && ((y <= -4.2e+56) || (!(y <= -9.5e+14) && ((y <= -8400000.0) || !(y <= 1.65e+183)))))) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e+177) or (not (y <= -2.8e+80) and ((y <= -4.2e+56) or (not (y <= -9.5e+14) and ((y <= -8400000.0) or not (y <= 1.65e+183))))): tmp = -4.0 * (y / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e+177) || (!(y <= -2.8e+80) && ((y <= -4.2e+56) || (!(y <= -9.5e+14) && ((y <= -8400000.0) || !(y <= 1.65e+183)))))) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.4e+177) || (~((y <= -2.8e+80)) && ((y <= -4.2e+56) || (~((y <= -9.5e+14)) && ((y <= -8400000.0) || ~((y <= 1.65e+183))))))) tmp = -4.0 * (y / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+177], And[N[Not[LessEqual[y, -2.8e+80]], $MachinePrecision], Or[LessEqual[y, -4.2e+56], And[N[Not[LessEqual[y, -9.5e+14]], $MachinePrecision], Or[LessEqual[y, -8400000.0], N[Not[LessEqual[y, 1.65e+183]], $MachinePrecision]]]]]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+177} \lor \neg \left(y \leq -2.8 \cdot 10^{+80}\right) \land \left(y \leq -4.2 \cdot 10^{+56} \lor \neg \left(y \leq -9.5 \cdot 10^{+14}\right) \land \left(y \leq -8400000 \lor \neg \left(y \leq 1.65 \cdot 10^{+183}\right)\right)\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.40000000000000001e177 or -2.79999999999999984e80 < y < -4.20000000000000034e56 or -9.5e14 < y < -8.4e6 or 1.65000000000000005e183 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in y around inf 87.0%
*-commutative87.0%
Simplified87.0%
if -1.40000000000000001e177 < y < -2.79999999999999984e80 or -4.20000000000000034e56 < y < -9.5e14 or -8.4e6 < y < 1.65000000000000005e183Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 85.4%
Final simplification85.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (- 0.5 (/ x z)))) (t_1 (/ (* 4.0 (- x y)) z)))
(if (<= y -2.2e+57)
t_1
(if (<= y 1.65e-15)
t_0
(if (<= y 1.65e+54)
t_1
(if (<= y 3.5e+64)
t_0
(if (or (<= y 1.95e+189) (not (<= y 1.2e+252)))
t_1
(* 4.0 (- -0.5 (/ y z))))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (0.5 - (x / z));
double t_1 = (4.0 * (x - y)) / z;
double tmp;
if (y <= -2.2e+57) {
tmp = t_1;
} else if (y <= 1.65e-15) {
tmp = t_0;
} else if (y <= 1.65e+54) {
tmp = t_1;
} else if (y <= 3.5e+64) {
tmp = t_0;
} else if ((y <= 1.95e+189) || !(y <= 1.2e+252)) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-4.0d0) * (0.5d0 - (x / z))
t_1 = (4.0d0 * (x - y)) / z
if (y <= (-2.2d+57)) then
tmp = t_1
else if (y <= 1.65d-15) then
tmp = t_0
else if (y <= 1.65d+54) then
tmp = t_1
else if (y <= 3.5d+64) then
tmp = t_0
else if ((y <= 1.95d+189) .or. (.not. (y <= 1.2d+252))) then
tmp = t_1
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 t_0 = -4.0 * (0.5 - (x / z));
double t_1 = (4.0 * (x - y)) / z;
double tmp;
if (y <= -2.2e+57) {
tmp = t_1;
} else if (y <= 1.65e-15) {
tmp = t_0;
} else if (y <= 1.65e+54) {
tmp = t_1;
} else if (y <= 3.5e+64) {
tmp = t_0;
} else if ((y <= 1.95e+189) || !(y <= 1.2e+252)) {
tmp = t_1;
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (0.5 - (x / z)) t_1 = (4.0 * (x - y)) / z tmp = 0 if y <= -2.2e+57: tmp = t_1 elif y <= 1.65e-15: tmp = t_0 elif y <= 1.65e+54: tmp = t_1 elif y <= 3.5e+64: tmp = t_0 elif (y <= 1.95e+189) or not (y <= 1.2e+252): tmp = t_1 else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(0.5 - Float64(x / z))) t_1 = Float64(Float64(4.0 * Float64(x - y)) / z) tmp = 0.0 if (y <= -2.2e+57) tmp = t_1; elseif (y <= 1.65e-15) tmp = t_0; elseif (y <= 1.65e+54) tmp = t_1; elseif (y <= 3.5e+64) tmp = t_0; elseif ((y <= 1.95e+189) || !(y <= 1.2e+252)) tmp = t_1; else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (0.5 - (x / z)); t_1 = (4.0 * (x - y)) / z; tmp = 0.0; if (y <= -2.2e+57) tmp = t_1; elseif (y <= 1.65e-15) tmp = t_0; elseif (y <= 1.65e+54) tmp = t_1; elseif (y <= 3.5e+64) tmp = t_0; elseif ((y <= 1.95e+189) || ~((y <= 1.2e+252))) tmp = t_1; else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -2.2e+57], t$95$1, If[LessEqual[y, 1.65e-15], t$95$0, If[LessEqual[y, 1.65e+54], t$95$1, If[LessEqual[y, 3.5e+64], t$95$0, If[Or[LessEqual[y, 1.95e+189], N[Not[LessEqual[y, 1.2e+252]], $MachinePrecision]], t$95$1, N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \left(0.5 - \frac{x}{z}\right)\\
t_1 := \frac{4 \cdot \left(x - y\right)}{z}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{+189} \lor \neg \left(y \leq 1.2 \cdot 10^{+252}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if y < -2.2000000000000001e57 or 1.65e-15 < y < 1.65e54 or 3.4999999999999999e64 < y < 1.95e189 or 1.2e252 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 89.4%
associate-*r/89.4%
Simplified89.4%
if -2.2000000000000001e57 < y < 1.65e-15 or 1.65e54 < y < 3.4999999999999999e64Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.2%
if 1.95e189 < y < 1.2e252Initial program 100.0%
*-commutative100.0%
associate-/l*99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in x around 0 98.6%
associate-*r/98.6%
metadata-eval98.6%
+-commutative98.6%
*-commutative98.6%
fma-undefine98.6%
associate-*r*98.6%
neg-mul-198.6%
associate-/l*98.6%
fma-undefine98.6%
*-commutative98.6%
distribute-neg-in98.6%
sub-neg98.6%
div-sub98.6%
distribute-neg-frac98.6%
associate-/l*98.6%
*-inverses98.6%
metadata-eval98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification90.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (- 0.5 (/ x z)))) (t_1 (* (- x y) (/ 4.0 z))))
(if (<= y -5e+54)
t_1
(if (<= y 3e-15)
t_0
(if (<= y 3.8e+52)
t_1
(if (<= y 3.6e+64)
t_0
(if (or (<= y 4.55e+195) (not (<= y 3.9e+253)))
t_1
(* 4.0 (- -0.5 (/ y z))))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (0.5 - (x / z));
double t_1 = (x - y) * (4.0 / z);
double tmp;
if (y <= -5e+54) {
tmp = t_1;
} else if (y <= 3e-15) {
tmp = t_0;
} else if (y <= 3.8e+52) {
tmp = t_1;
} else if (y <= 3.6e+64) {
tmp = t_0;
} else if ((y <= 4.55e+195) || !(y <= 3.9e+253)) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-4.0d0) * (0.5d0 - (x / z))
t_1 = (x - y) * (4.0d0 / z)
if (y <= (-5d+54)) then
tmp = t_1
else if (y <= 3d-15) then
tmp = t_0
else if (y <= 3.8d+52) then
tmp = t_1
else if (y <= 3.6d+64) then
tmp = t_0
else if ((y <= 4.55d+195) .or. (.not. (y <= 3.9d+253))) then
tmp = t_1
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 t_0 = -4.0 * (0.5 - (x / z));
double t_1 = (x - y) * (4.0 / z);
double tmp;
if (y <= -5e+54) {
tmp = t_1;
} else if (y <= 3e-15) {
tmp = t_0;
} else if (y <= 3.8e+52) {
tmp = t_1;
} else if (y <= 3.6e+64) {
tmp = t_0;
} else if ((y <= 4.55e+195) || !(y <= 3.9e+253)) {
tmp = t_1;
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (0.5 - (x / z)) t_1 = (x - y) * (4.0 / z) tmp = 0 if y <= -5e+54: tmp = t_1 elif y <= 3e-15: tmp = t_0 elif y <= 3.8e+52: tmp = t_1 elif y <= 3.6e+64: tmp = t_0 elif (y <= 4.55e+195) or not (y <= 3.9e+253): tmp = t_1 else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(0.5 - Float64(x / z))) t_1 = Float64(Float64(x - y) * Float64(4.0 / z)) tmp = 0.0 if (y <= -5e+54) tmp = t_1; elseif (y <= 3e-15) tmp = t_0; elseif (y <= 3.8e+52) tmp = t_1; elseif (y <= 3.6e+64) tmp = t_0; elseif ((y <= 4.55e+195) || !(y <= 3.9e+253)) tmp = t_1; else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (0.5 - (x / z)); t_1 = (x - y) * (4.0 / z); tmp = 0.0; if (y <= -5e+54) tmp = t_1; elseif (y <= 3e-15) tmp = t_0; elseif (y <= 3.8e+52) tmp = t_1; elseif (y <= 3.6e+64) tmp = t_0; elseif ((y <= 4.55e+195) || ~((y <= 3.9e+253))) tmp = t_1; else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e+54], t$95$1, If[LessEqual[y, 3e-15], t$95$0, If[LessEqual[y, 3.8e+52], t$95$1, If[LessEqual[y, 3.6e+64], t$95$0, If[Or[LessEqual[y, 4.55e+195], N[Not[LessEqual[y, 3.9e+253]], $MachinePrecision]], t$95$1, N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \left(0.5 - \frac{x}{z}\right)\\
t_1 := \left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.55 \cdot 10^{+195} \lor \neg \left(y \leq 3.9 \cdot 10^{+253}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if y < -5.00000000000000005e54 or 3e-15 < y < 3.8e52 or 3.60000000000000014e64 < y < 4.5499999999999999e195 or 3.9000000000000001e253 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 89.4%
associate-*r/89.4%
*-commutative89.4%
associate-/l*89.3%
Simplified89.3%
if -5.00000000000000005e54 < y < 3e-15 or 3.8e52 < y < 3.60000000000000014e64Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.2%
if 4.5499999999999999e195 < y < 3.9000000000000001e253Initial program 100.0%
*-commutative100.0%
associate-/l*99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in x around 0 98.6%
associate-*r/98.6%
metadata-eval98.6%
+-commutative98.6%
*-commutative98.6%
fma-undefine98.6%
associate-*r*98.6%
neg-mul-198.6%
associate-/l*98.6%
fma-undefine98.6%
*-commutative98.6%
distribute-neg-in98.6%
sub-neg98.6%
div-sub98.6%
distribute-neg-frac98.6%
associate-/l*98.6%
*-inverses98.6%
metadata-eval98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification90.7%
(FPCore (x y z)
:precision binary64
(if (or (<= y -2.8e+170)
(and (not (<= y -5.1e+116))
(or (<= y -1.7e+57) (not (<= y 2.9e+137)))))
(* 4.0 (- -0.5 (/ y z)))
(* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+170) || (!(y <= -5.1e+116) && ((y <= -1.7e+57) || !(y <= 2.9e+137)))) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = -4.0 * (0.5 - (x / 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 <= (-2.8d+170)) .or. (.not. (y <= (-5.1d+116))) .and. (y <= (-1.7d+57)) .or. (.not. (y <= 2.9d+137))) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+170) || (!(y <= -5.1e+116) && ((y <= -1.7e+57) || !(y <= 2.9e+137)))) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.8e+170) or (not (y <= -5.1e+116) and ((y <= -1.7e+57) or not (y <= 2.9e+137))): tmp = 4.0 * (-0.5 - (y / z)) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+170) || (!(y <= -5.1e+116) && ((y <= -1.7e+57) || !(y <= 2.9e+137)))) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.8e+170) || (~((y <= -5.1e+116)) && ((y <= -1.7e+57) || ~((y <= 2.9e+137))))) tmp = 4.0 * (-0.5 - (y / z)); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+170], And[N[Not[LessEqual[y, -5.1e+116]], $MachinePrecision], Or[LessEqual[y, -1.7e+57], N[Not[LessEqual[y, 2.9e+137]], $MachinePrecision]]]], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+170} \lor \neg \left(y \leq -5.1 \cdot 10^{+116}\right) \land \left(y \leq -1.7 \cdot 10^{+57} \lor \neg \left(y \leq 2.9 \cdot 10^{+137}\right)\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -2.80000000000000015e170 or -5.09999999999999999e116 < y < -1.69999999999999996e57 or 2.89999999999999985e137 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around 0 86.7%
associate-*r/86.7%
metadata-eval86.7%
+-commutative86.7%
*-commutative86.7%
fma-undefine86.7%
associate-*r*86.7%
neg-mul-186.7%
associate-/l*86.7%
fma-undefine86.7%
*-commutative86.7%
distribute-neg-in86.7%
sub-neg86.7%
div-sub86.8%
distribute-neg-frac86.8%
associate-/l*86.8%
*-inverses86.8%
metadata-eval86.8%
metadata-eval86.8%
Simplified86.8%
if -2.80000000000000015e170 < y < -5.09999999999999999e116 or -1.69999999999999996e57 < y < 2.89999999999999985e137Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 85.7%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (if (<= z -5.5e-35) -2.0 (if (<= z 1.42e-14) (/ (* x 4.0) z) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e-35) {
tmp = -2.0;
} else if (z <= 1.42e-14) {
tmp = (x * 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 <= (-5.5d-35)) then
tmp = -2.0d0
else if (z <= 1.42d-14) then
tmp = (x * 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 <= -5.5e-35) {
tmp = -2.0;
} else if (z <= 1.42e-14) {
tmp = (x * 4.0) / z;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.5e-35: tmp = -2.0 elif z <= 1.42e-14: tmp = (x * 4.0) / z else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.5e-35) tmp = -2.0; elseif (z <= 1.42e-14) tmp = Float64(Float64(x * 4.0) / z); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.5e-35) tmp = -2.0; elseif (z <= 1.42e-14) tmp = (x * 4.0) / z; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.5e-35], -2.0, If[LessEqual[z, 1.42e-14], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-35}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{-14}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -5.4999999999999997e-35 or 1.42000000000000004e-14 < z Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 52.8%
if -5.4999999999999997e-35 < z < 1.42000000000000004e-14Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 57.9%
associate-*r/57.9%
*-commutative57.9%
Simplified57.9%
(FPCore (x y z) :precision binary64 (if (<= z -5.8e-35) -2.0 (if (<= z 3.7e-17) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.8e-35) {
tmp = -2.0;
} else if (z <= 3.7e-17) {
tmp = x * (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 <= (-5.8d-35)) then
tmp = -2.0d0
else if (z <= 3.7d-17) then
tmp = x * (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 <= -5.8e-35) {
tmp = -2.0;
} else if (z <= 3.7e-17) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.8e-35: tmp = -2.0 elif z <= 3.7e-17: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.8e-35) tmp = -2.0; elseif (z <= 3.7e-17) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.8e-35) tmp = -2.0; elseif (z <= 3.7e-17) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.8e-35], -2.0, If[LessEqual[z, 3.7e-17], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-35}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -5.8000000000000004e-35 or 3.6999999999999997e-17 < z Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 52.8%
if -5.8000000000000004e-35 < z < 3.6999999999999997e-17Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 57.9%
associate-*r/57.9%
associate-*l/57.8%
*-commutative57.8%
Simplified57.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%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 29.7%
(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 2024107
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))