
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x - y) / (z - y)
end function
public static double code(double x, double y, double z) {
return (x - y) / (z - y);
}
def code(x, y, z): return (x - y) / (z - y)
function code(x, y, z) return Float64(Float64(x - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x - y) / (z - y)
end function
public static double code(double x, double y, double z) {
return (x - y) / (z - y);
}
def code(x, y, z): return (x - y) / (z - y)
function code(x, y, z) return Float64(Float64(x - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x - y) / (z - y)
end function
public static double code(double x, double y, double z) {
return (x - y) / (z - y);
}
def code(x, y, z): return (x - y) / (z - y)
function code(x, y, z) return Float64(Float64(x - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- y) z)))
(if (<= y -4.6e+62)
1.0
(if (<= y -0.000116)
(/ (- x) y)
(if (<= y -2.85e-86)
t_0
(if (<= y 4.2e-47)
(/ x z)
(if (<= y 6.5e+88) t_0 (if (<= y 7.5e+115) (/ x z) 1.0))))))))
double code(double x, double y, double z) {
double t_0 = -y / z;
double tmp;
if (y <= -4.6e+62) {
tmp = 1.0;
} else if (y <= -0.000116) {
tmp = -x / y;
} else if (y <= -2.85e-86) {
tmp = t_0;
} else if (y <= 4.2e-47) {
tmp = x / z;
} else if (y <= 6.5e+88) {
tmp = t_0;
} else if (y <= 7.5e+115) {
tmp = x / z;
} else {
tmp = 1.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 / z
if (y <= (-4.6d+62)) then
tmp = 1.0d0
else if (y <= (-0.000116d0)) then
tmp = -x / y
else if (y <= (-2.85d-86)) then
tmp = t_0
else if (y <= 4.2d-47) then
tmp = x / z
else if (y <= 6.5d+88) then
tmp = t_0
else if (y <= 7.5d+115) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -y / z;
double tmp;
if (y <= -4.6e+62) {
tmp = 1.0;
} else if (y <= -0.000116) {
tmp = -x / y;
} else if (y <= -2.85e-86) {
tmp = t_0;
} else if (y <= 4.2e-47) {
tmp = x / z;
} else if (y <= 6.5e+88) {
tmp = t_0;
} else if (y <= 7.5e+115) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = -y / z tmp = 0 if y <= -4.6e+62: tmp = 1.0 elif y <= -0.000116: tmp = -x / y elif y <= -2.85e-86: tmp = t_0 elif y <= 4.2e-47: tmp = x / z elif y <= 6.5e+88: tmp = t_0 elif y <= 7.5e+115: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-y) / z) tmp = 0.0 if (y <= -4.6e+62) tmp = 1.0; elseif (y <= -0.000116) tmp = Float64(Float64(-x) / y); elseif (y <= -2.85e-86) tmp = t_0; elseif (y <= 4.2e-47) tmp = Float64(x / z); elseif (y <= 6.5e+88) tmp = t_0; elseif (y <= 7.5e+115) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -y / z; tmp = 0.0; if (y <= -4.6e+62) tmp = 1.0; elseif (y <= -0.000116) tmp = -x / y; elseif (y <= -2.85e-86) tmp = t_0; elseif (y <= 4.2e-47) tmp = x / z; elseif (y <= 6.5e+88) tmp = t_0; elseif (y <= 7.5e+115) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-y) / z), $MachinePrecision]}, If[LessEqual[y, -4.6e+62], 1.0, If[LessEqual[y, -0.000116], N[((-x) / y), $MachinePrecision], If[LessEqual[y, -2.85e-86], t$95$0, If[LessEqual[y, 4.2e-47], N[(x / z), $MachinePrecision], If[LessEqual[y, 6.5e+88], t$95$0, If[LessEqual[y, 7.5e+115], N[(x / z), $MachinePrecision], 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-y}{z}\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+62}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -0.000116:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq -2.85 \cdot 10^{-86}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-47}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.59999999999999968e62 or 7.4999999999999997e115 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.7%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 66.4%
if -4.59999999999999968e62 < y < -1.16e-4Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 65.9%
neg-mul-165.9%
distribute-neg-frac65.9%
Simplified65.9%
Taylor expanded in y around inf 40.0%
associate-*r/40.0%
mul-1-neg40.0%
Simplified40.0%
if -1.16e-4 < y < -2.8500000000000002e-86 or 4.2000000000000001e-47 < y < 6.5000000000000002e88Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 68.8%
Taylor expanded in y around 0 47.5%
associate-*r/47.5%
neg-mul-147.5%
Simplified47.5%
if -2.8500000000000002e-86 < y < 4.2000000000000001e-47 or 6.5000000000000002e88 < y < 7.4999999999999997e115Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 76.6%
Final simplification65.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ y (- y z))))
(if (<= y -1.15e-17)
t_0
(if (<= y -6.2e-101)
t_1
(if (<= y 3.9e-47)
(/ x z)
(if (or (<= y 3.55e+174) (not (<= y 1.8e+248))) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = y / (y - z);
double tmp;
if (y <= -1.15e-17) {
tmp = t_0;
} else if (y <= -6.2e-101) {
tmp = t_1;
} else if (y <= 3.9e-47) {
tmp = x / z;
} else if ((y <= 3.55e+174) || !(y <= 1.8e+248)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = y / (y - z)
if (y <= (-1.15d-17)) then
tmp = t_0
else if (y <= (-6.2d-101)) then
tmp = t_1
else if (y <= 3.9d-47) then
tmp = x / z
else if ((y <= 3.55d+174) .or. (.not. (y <= 1.8d+248))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = y / (y - z);
double tmp;
if (y <= -1.15e-17) {
tmp = t_0;
} else if (y <= -6.2e-101) {
tmp = t_1;
} else if (y <= 3.9e-47) {
tmp = x / z;
} else if ((y <= 3.55e+174) || !(y <= 1.8e+248)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = y / (y - z) tmp = 0 if y <= -1.15e-17: tmp = t_0 elif y <= -6.2e-101: tmp = t_1 elif y <= 3.9e-47: tmp = x / z elif (y <= 3.55e+174) or not (y <= 1.8e+248): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -1.15e-17) tmp = t_0; elseif (y <= -6.2e-101) tmp = t_1; elseif (y <= 3.9e-47) tmp = Float64(x / z); elseif ((y <= 3.55e+174) || !(y <= 1.8e+248)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); t_1 = y / (y - z); tmp = 0.0; if (y <= -1.15e-17) tmp = t_0; elseif (y <= -6.2e-101) tmp = t_1; elseif (y <= 3.9e-47) tmp = x / z; elseif ((y <= 3.55e+174) || ~((y <= 1.8e+248))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e-17], t$95$0, If[LessEqual[y, -6.2e-101], t$95$1, If[LessEqual[y, 3.9e-47], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 3.55e+174], N[Not[LessEqual[y, 1.8e+248]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-47}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{+174} \lor \neg \left(y \leq 1.8 \cdot 10^{+248}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.15000000000000004e-17 or 3.5500000000000001e174 < y < 1.80000000000000001e248Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 79.9%
div-sub79.9%
*-inverses79.9%
Simplified79.9%
if -1.15000000000000004e-17 < y < -6.19999999999999946e-101 or 3.89999999999999978e-47 < y < 3.5500000000000001e174 or 1.80000000000000001e248 < y Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.7%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 77.6%
if -6.19999999999999946e-101 < y < 3.89999999999999978e-47Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 77.3%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ (- x y) z)))
(if (<= y -1.12e+24)
t_0
(if (<= y 3.8e-93)
t_1
(if (<= y 6e-50) (/ (- x) (- y z)) (if (<= y 7.5e+115) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = (x - y) / z;
double tmp;
if (y <= -1.12e+24) {
tmp = t_0;
} else if (y <= 3.8e-93) {
tmp = t_1;
} else if (y <= 6e-50) {
tmp = -x / (y - z);
} else if (y <= 7.5e+115) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = (x - y) / z
if (y <= (-1.12d+24)) then
tmp = t_0
else if (y <= 3.8d-93) then
tmp = t_1
else if (y <= 6d-50) then
tmp = -x / (y - z)
else if (y <= 7.5d+115) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = (x - y) / z;
double tmp;
if (y <= -1.12e+24) {
tmp = t_0;
} else if (y <= 3.8e-93) {
tmp = t_1;
} else if (y <= 6e-50) {
tmp = -x / (y - z);
} else if (y <= 7.5e+115) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = (x - y) / z tmp = 0 if y <= -1.12e+24: tmp = t_0 elif y <= 3.8e-93: tmp = t_1 elif y <= 6e-50: tmp = -x / (y - z) elif y <= 7.5e+115: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(Float64(x - y) / z) tmp = 0.0 if (y <= -1.12e+24) tmp = t_0; elseif (y <= 3.8e-93) tmp = t_1; elseif (y <= 6e-50) tmp = Float64(Float64(-x) / Float64(y - z)); elseif (y <= 7.5e+115) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); t_1 = (x - y) / z; tmp = 0.0; if (y <= -1.12e+24) tmp = t_0; elseif (y <= 3.8e-93) tmp = t_1; elseif (y <= 6e-50) tmp = -x / (y - z); elseif (y <= 7.5e+115) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1.12e+24], t$95$0, If[LessEqual[y, 3.8e-93], t$95$1, If[LessEqual[y, 6e-50], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e+115], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -1.12 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-93}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-50}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+115}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.12e24 or 7.4999999999999997e115 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 82.8%
div-sub82.9%
*-inverses82.9%
Simplified82.9%
if -1.12e24 < y < 3.7999999999999999e-93 or 5.99999999999999981e-50 < y < 7.4999999999999997e115Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.4%
inv-pow99.4%
Applied egg-rr99.4%
Taylor expanded in z around inf 82.2%
associate-*r/82.2%
sub-neg82.2%
mul-1-neg82.2%
distribute-lft-in82.2%
neg-mul-182.2%
neg-mul-182.2%
mul-1-neg82.2%
remove-double-neg82.2%
+-commutative82.2%
unsub-neg82.2%
Simplified82.2%
if 3.7999999999999999e-93 < y < 5.99999999999999981e-50Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Simplified100.0%
Final simplification83.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -4.2e-14)
t_0
(if (<= y -4.2e-102) (/ (- y) z) (if (<= y 1.35e-25) (/ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4.2e-14) {
tmp = t_0;
} else if (y <= -4.2e-102) {
tmp = -y / z;
} else if (y <= 1.35e-25) {
tmp = x / z;
} 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 = 1.0d0 - (x / y)
if (y <= (-4.2d-14)) then
tmp = t_0
else if (y <= (-4.2d-102)) then
tmp = -y / z
else if (y <= 1.35d-25) then
tmp = x / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4.2e-14) {
tmp = t_0;
} else if (y <= -4.2e-102) {
tmp = -y / z;
} else if (y <= 1.35e-25) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -4.2e-14: tmp = t_0 elif y <= -4.2e-102: tmp = -y / z elif y <= 1.35e-25: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -4.2e-14) tmp = t_0; elseif (y <= -4.2e-102) tmp = Float64(Float64(-y) / z); elseif (y <= 1.35e-25) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -4.2e-14) tmp = t_0; elseif (y <= -4.2e-102) tmp = -y / z; elseif (y <= 1.35e-25) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.2e-14], t$95$0, If[LessEqual[y, -4.2e-102], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 1.35e-25], N[(x / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -4.2 \cdot 10^{-14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.1999999999999998e-14 or 1.35000000000000008e-25 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.7%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 73.0%
div-sub73.0%
*-inverses73.0%
Simplified73.0%
if -4.1999999999999998e-14 < y < -4.2e-102Initial program 99.8%
sub-neg99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
+-commutative99.8%
sub-neg99.8%
neg-mul-199.8%
associate-/r*99.8%
div-sub99.8%
remove-double-neg99.8%
neg-mul-199.8%
associate-/l*99.8%
associate-/r/99.8%
metadata-eval99.8%
*-lft-identity99.8%
remove-double-neg99.8%
neg-mul-199.8%
associate-/l*99.8%
associate-/r/99.8%
metadata-eval99.8%
*-lft-identity99.8%
unsub-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 77.4%
Taylor expanded in y around 0 67.6%
associate-*r/67.6%
neg-mul-167.6%
Simplified67.6%
if -4.2e-102 < y < 1.35000000000000008e-25Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 75.6%
Final simplification73.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.14e+27) (not (<= y 7.5e+115))) (- 1.0 (/ x y)) (/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.14e+27) || !(y <= 7.5e+115)) {
tmp = 1.0 - (x / y);
} else {
tmp = (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 <= (-1.14d+27)) .or. (.not. (y <= 7.5d+115))) then
tmp = 1.0d0 - (x / y)
else
tmp = (x - y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.14e+27) || !(y <= 7.5e+115)) {
tmp = 1.0 - (x / y);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.14e+27) or not (y <= 7.5e+115): tmp = 1.0 - (x / y) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.14e+27) || !(y <= 7.5e+115)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(Float64(x - y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.14e+27) || ~((y <= 7.5e+115))) tmp = 1.0 - (x / y); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.14e+27], N[Not[LessEqual[y, 7.5e+115]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.14 \cdot 10^{+27} \lor \neg \left(y \leq 7.5 \cdot 10^{+115}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -1.1400000000000001e27 or 7.4999999999999997e115 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 82.8%
div-sub82.9%
*-inverses82.9%
Simplified82.9%
if -1.1400000000000001e27 < y < 7.4999999999999997e115Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.5%
inv-pow99.5%
Applied egg-rr99.5%
Taylor expanded in z around inf 80.2%
associate-*r/80.2%
sub-neg80.2%
mul-1-neg80.2%
distribute-lft-in80.2%
neg-mul-180.2%
neg-mul-180.2%
mul-1-neg80.2%
remove-double-neg80.2%
+-commutative80.2%
unsub-neg80.2%
Simplified80.2%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.4e+34) 1.0 (if (<= y 7.5e+115) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+34) {
tmp = 1.0;
} else if (y <= 7.5e+115) {
tmp = x / z;
} else {
tmp = 1.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 <= (-2.4d+34)) then
tmp = 1.0d0
else if (y <= 7.5d+115) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+34) {
tmp = 1.0;
} else if (y <= 7.5e+115) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.4e+34: tmp = 1.0 elif y <= 7.5e+115: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.4e+34) tmp = 1.0; elseif (y <= 7.5e+115) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.4e+34) tmp = 1.0; elseif (y <= 7.5e+115) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+34], 1.0, If[LessEqual[y, 7.5e+115], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+34}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.39999999999999987e34 or 7.4999999999999997e115 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 62.9%
if -2.39999999999999987e34 < y < 7.4999999999999997e115Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 61.4%
Final simplification62.0%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 33.0%
Final simplification33.0%
(FPCore (x y z) :precision binary64 (- (/ x (- z y)) (/ y (- z y))))
double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / (z - y)) - (y / (z - y))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
def code(x, y, z): return (x / (z - y)) - (y / (z - y))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) - (y / (z - y)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}
herbie shell --seed 2024021
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:herbie-target
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))