
(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 10 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 (- (/ y (- y z)) (/ x (- y z))))
double code(double x, double y, double z) {
return (y / (y - z)) - (x / (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 = (y / (y - z)) - (x / (y - z))
end function
public static double code(double x, double y, double z) {
return (y / (y - z)) - (x / (y - z));
}
def code(x, y, z): return (y / (y - z)) - (x / (y - z))
function code(x, y, z) return Float64(Float64(y / Float64(y - z)) - Float64(x / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (y / (y - z)) - (x / (y - z)); end
code[x_, y_, z_] := N[(N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{y - z} - \frac{x}{y - z}
\end{array}
Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.2%
associate-/l*99.1%
neg-mul-199.1%
sub-neg99.1%
+-commutative99.1%
distribute-neg-out99.1%
remove-double-neg99.1%
sub-neg99.1%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (/ (- x) (- y z))))
(if (<= y -8.8e+18)
t_0
(if (<= y 1.5e-71)
t_1
(if (<= y 8e-65)
t_0
(if (<= y 2.1e-19)
t_1
(if (<= y 4.2e+89)
t_0
(if (<= y 1.75e+115) t_1 (+ 1.0 (/ (- z x) y))))))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = -x / (y - z);
double tmp;
if (y <= -8.8e+18) {
tmp = t_0;
} else if (y <= 1.5e-71) {
tmp = t_1;
} else if (y <= 8e-65) {
tmp = t_0;
} else if (y <= 2.1e-19) {
tmp = t_1;
} else if (y <= 4.2e+89) {
tmp = t_0;
} else if (y <= 1.75e+115) {
tmp = t_1;
} else {
tmp = 1.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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / (y - z)
t_1 = -x / (y - z)
if (y <= (-8.8d+18)) then
tmp = t_0
else if (y <= 1.5d-71) then
tmp = t_1
else if (y <= 8d-65) then
tmp = t_0
else if (y <= 2.1d-19) then
tmp = t_1
else if (y <= 4.2d+89) then
tmp = t_0
else if (y <= 1.75d+115) then
tmp = t_1
else
tmp = 1.0d0 + ((z - x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = -x / (y - z);
double tmp;
if (y <= -8.8e+18) {
tmp = t_0;
} else if (y <= 1.5e-71) {
tmp = t_1;
} else if (y <= 8e-65) {
tmp = t_0;
} else if (y <= 2.1e-19) {
tmp = t_1;
} else if (y <= 4.2e+89) {
tmp = t_0;
} else if (y <= 1.75e+115) {
tmp = t_1;
} else {
tmp = 1.0 + ((z - x) / y);
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = -x / (y - z) tmp = 0 if y <= -8.8e+18: tmp = t_0 elif y <= 1.5e-71: tmp = t_1 elif y <= 8e-65: tmp = t_0 elif y <= 2.1e-19: tmp = t_1 elif y <= 4.2e+89: tmp = t_0 elif y <= 1.75e+115: tmp = t_1 else: tmp = 1.0 + ((z - x) / y) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(Float64(-x) / Float64(y - z)) tmp = 0.0 if (y <= -8.8e+18) tmp = t_0; elseif (y <= 1.5e-71) tmp = t_1; elseif (y <= 8e-65) tmp = t_0; elseif (y <= 2.1e-19) tmp = t_1; elseif (y <= 4.2e+89) tmp = t_0; elseif (y <= 1.75e+115) tmp = t_1; else tmp = Float64(1.0 + Float64(Float64(z - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = -x / (y - z); tmp = 0.0; if (y <= -8.8e+18) tmp = t_0; elseif (y <= 1.5e-71) tmp = t_1; elseif (y <= 8e-65) tmp = t_0; elseif (y <= 2.1e-19) tmp = t_1; elseif (y <= 4.2e+89) tmp = t_0; elseif (y <= 1.75e+115) tmp = t_1; else tmp = 1.0 + ((z - x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.8e+18], t$95$0, If[LessEqual[y, 1.5e-71], t$95$1, If[LessEqual[y, 8e-65], t$95$0, If[LessEqual[y, 2.1e-19], t$95$1, If[LessEqual[y, 4.2e+89], t$95$0, If[LessEqual[y, 1.75e+115], t$95$1, N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := \frac{-x}{y - z}\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+115}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\end{array}
\end{array}
if y < -8.8e18 or 1.5000000000000001e-71 < y < 7.99999999999999939e-65 or 2.0999999999999999e-19 < y < 4.19999999999999972e89Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 88.9%
if -8.8e18 < y < 1.5000000000000001e-71 or 7.99999999999999939e-65 < y < 2.0999999999999999e-19 or 4.19999999999999972e89 < y < 1.75000000000000003e115Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/98.9%
associate-/l*98.7%
neg-mul-198.7%
sub-neg98.7%
+-commutative98.7%
distribute-neg-out98.7%
remove-double-neg98.7%
sub-neg98.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 88.9%
neg-mul-188.9%
distribute-neg-frac88.9%
Simplified88.9%
if 1.75000000000000003e115 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 78.6%
associate--l+78.6%
distribute-lft-out--78.6%
div-sub78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
Final simplification87.4%
(FPCore (x y z)
:precision binary64
(if (or (<= y -1.06e+20)
(not
(or (<= y 1.32e-71)
(and (not (<= y 1.15e-65))
(or (<= y 2.2e-15)
(and (not (<= y 1.52e+91)) (<= y 8.4e+122)))))))
(/ y (- y z))
(/ (- x) (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.06e+20) || !((y <= 1.32e-71) || (!(y <= 1.15e-65) && ((y <= 2.2e-15) || (!(y <= 1.52e+91) && (y <= 8.4e+122)))))) {
tmp = y / (y - z);
} 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.06d+20)) .or. (.not. (y <= 1.32d-71) .or. (.not. (y <= 1.15d-65)) .and. (y <= 2.2d-15) .or. (.not. (y <= 1.52d+91)) .and. (y <= 8.4d+122))) then
tmp = y / (y - z)
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.06e+20) || !((y <= 1.32e-71) || (!(y <= 1.15e-65) && ((y <= 2.2e-15) || (!(y <= 1.52e+91) && (y <= 8.4e+122)))))) {
tmp = y / (y - z);
} else {
tmp = -x / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.06e+20) or not ((y <= 1.32e-71) or (not (y <= 1.15e-65) and ((y <= 2.2e-15) or (not (y <= 1.52e+91) and (y <= 8.4e+122))))): tmp = y / (y - z) else: tmp = -x / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.06e+20) || !((y <= 1.32e-71) || (!(y <= 1.15e-65) && ((y <= 2.2e-15) || (!(y <= 1.52e+91) && (y <= 8.4e+122)))))) tmp = Float64(y / Float64(y - z)); else tmp = Float64(Float64(-x) / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.06e+20) || ~(((y <= 1.32e-71) || (~((y <= 1.15e-65)) && ((y <= 2.2e-15) || (~((y <= 1.52e+91)) && (y <= 8.4e+122))))))) tmp = y / (y - z); else tmp = -x / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.06e+20], N[Not[Or[LessEqual[y, 1.32e-71], And[N[Not[LessEqual[y, 1.15e-65]], $MachinePrecision], Or[LessEqual[y, 2.2e-15], And[N[Not[LessEqual[y, 1.52e+91]], $MachinePrecision], LessEqual[y, 8.4e+122]]]]]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+20} \lor \neg \left(y \leq 1.32 \cdot 10^{-71} \lor \neg \left(y \leq 1.15 \cdot 10^{-65}\right) \land \left(y \leq 2.2 \cdot 10^{-15} \lor \neg \left(y \leq 1.52 \cdot 10^{+91}\right) \land y \leq 8.4 \cdot 10^{+122}\right)\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{y - z}\\
\end{array}
\end{array}
if y < -1.06e20 or 1.32e-71 < y < 1.15e-65 or 2.19999999999999986e-15 < y < 1.52e91 or 8.40000000000000063e122 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.6%
associate-/l*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-out99.5%
remove-double-neg99.5%
sub-neg99.5%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 85.7%
if -1.06e20 < y < 1.32e-71 or 1.15e-65 < y < 2.19999999999999986e-15 or 1.52e91 < y < 8.40000000000000063e122Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/98.9%
associate-/l*98.7%
neg-mul-198.7%
sub-neg98.7%
+-commutative98.7%
distribute-neg-out98.7%
remove-double-neg98.7%
sub-neg98.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 89.0%
neg-mul-189.0%
distribute-neg-frac89.0%
Simplified89.0%
Final simplification87.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -3.8e+38)
t_0
(if (<= y -2.4e-92) (- 1.0 (/ x y)) (if (<= y 8e-76) (/ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -3.8e+38) {
tmp = t_0;
} else if (y <= -2.4e-92) {
tmp = 1.0 - (x / y);
} else if (y <= 8e-76) {
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 = y / (y - z)
if (y <= (-3.8d+38)) then
tmp = t_0
else if (y <= (-2.4d-92)) then
tmp = 1.0d0 - (x / y)
else if (y <= 8d-76) 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 = y / (y - z);
double tmp;
if (y <= -3.8e+38) {
tmp = t_0;
} else if (y <= -2.4e-92) {
tmp = 1.0 - (x / y);
} else if (y <= 8e-76) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -3.8e+38: tmp = t_0 elif y <= -2.4e-92: tmp = 1.0 - (x / y) elif y <= 8e-76: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -3.8e+38) tmp = t_0; elseif (y <= -2.4e-92) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 8e-76) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); tmp = 0.0; if (y <= -3.8e+38) tmp = t_0; elseif (y <= -2.4e-92) tmp = 1.0 - (x / y); elseif (y <= 8e-76) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.8e+38], t$95$0, If[LessEqual[y, -2.4e-92], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e-76], N[(x / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-92}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-76}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.7999999999999998e38 or 7.99999999999999942e-76 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.7%
associate-/l*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-out99.5%
remove-double-neg99.5%
sub-neg99.5%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 77.2%
if -3.7999999999999998e38 < y < -2.4000000000000001e-92Initial program 99.8%
*-lft-identity99.8%
metadata-eval99.8%
associate-/r/97.9%
associate-/l*98.0%
neg-mul-198.0%
sub-neg98.0%
+-commutative98.0%
distribute-neg-out98.0%
remove-double-neg98.0%
sub-neg98.0%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in z around 0 56.1%
div-sub56.1%
*-inverses56.1%
Simplified56.1%
if -2.4000000000000001e-92 < y < 7.99999999999999942e-76Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.1%
associate-/l*98.9%
neg-mul-198.9%
sub-neg98.9%
+-commutative98.9%
distribute-neg-out98.9%
remove-double-neg98.9%
sub-neg98.9%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 82.7%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.7e-91) (not (<= y 1.7e-46))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e-91) || !(y <= 1.7e-46)) {
tmp = 1.0 - (x / y);
} else {
tmp = 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.7d-91)) .or. (.not. (y <= 1.7d-46))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e-91) || !(y <= 1.7e-46)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.7e-91) or not (y <= 1.7e-46): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.7e-91) || !(y <= 1.7e-46)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.7e-91) || ~((y <= 1.7e-46))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.7e-91], N[Not[LessEqual[y, 1.7e-46]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-91} \lor \neg \left(y \leq 1.7 \cdot 10^{-46}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.6999999999999997e-91 or 1.69999999999999998e-46 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 65.6%
div-sub65.6%
*-inverses65.6%
Simplified65.6%
if -2.6999999999999997e-91 < y < 1.69999999999999998e-46Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.9%
associate-/l*98.7%
neg-mul-198.7%
sub-neg98.7%
+-commutative98.7%
distribute-neg-out98.7%
remove-double-neg98.7%
sub-neg98.7%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 78.8%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -9.8e+19) (not (<= y 1.6e-46))) (/ y (- y z)) (/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.8e+19) || !(y <= 1.6e-46)) {
tmp = y / (y - z);
} 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 <= (-9.8d+19)) .or. (.not. (y <= 1.6d-46))) then
tmp = y / (y - z)
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 <= -9.8e+19) || !(y <= 1.6e-46)) {
tmp = y / (y - z);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.8e+19) or not (y <= 1.6e-46): tmp = y / (y - z) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.8e+19) || !(y <= 1.6e-46)) tmp = Float64(y / Float64(y - z)); else tmp = Float64(Float64(x - y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9.8e+19) || ~((y <= 1.6e-46))) tmp = y / (y - z); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.8e+19], N[Not[LessEqual[y, 1.6e-46]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{+19} \lor \neg \left(y \leq 1.6 \cdot 10^{-46}\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -9.8e19 or 1.6e-46 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 78.4%
if -9.8e19 < y < 1.6e-46Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.7%
associate-/l*98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 78.4%
associate-*r/78.4%
neg-mul-178.4%
neg-sub078.4%
associate--r-78.4%
neg-sub078.4%
Simplified78.4%
Taylor expanded in y around 0 78.4%
+-commutative78.4%
mul-1-neg78.4%
sub-neg78.4%
div-sub78.4%
Simplified78.4%
Final simplification78.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.15e+17) 1.0 (if (<= y 1.08e-10) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.15e+17) {
tmp = 1.0;
} else if (y <= 1.08e-10) {
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.15d+17)) then
tmp = 1.0d0
else if (y <= 1.08d-10) 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.15e+17) {
tmp = 1.0;
} else if (y <= 1.08e-10) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.15e+17: tmp = 1.0 elif y <= 1.08e-10: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.15e+17) tmp = 1.0; elseif (y <= 1.08e-10) 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.15e+17) tmp = 1.0; elseif (y <= 1.08e-10) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.15e+17], 1.0, If[LessEqual[y, 1.08e-10], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.15e17 or 1.08000000000000002e-10 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 54.7%
if -2.15e17 < y < 1.08000000000000002e-10Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.7%
associate-/l*98.6%
neg-mul-198.6%
sub-neg98.6%
+-commutative98.6%
distribute-neg-out98.6%
remove-double-neg98.6%
sub-neg98.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 68.4%
Final simplification61.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.18e+38) (+ 1.0 (/ z y)) (if (<= y 1.05e-10) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.18e+38) {
tmp = 1.0 + (z / y);
} else if (y <= 1.05e-10) {
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 <= (-1.18d+38)) then
tmp = 1.0d0 + (z / y)
else if (y <= 1.05d-10) 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 <= -1.18e+38) {
tmp = 1.0 + (z / y);
} else if (y <= 1.05e-10) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.18e+38: tmp = 1.0 + (z / y) elif y <= 1.05e-10: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.18e+38) tmp = Float64(1.0 + Float64(z / y)); elseif (y <= 1.05e-10) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.18e+38) tmp = 1.0 + (z / y); elseif (y <= 1.05e-10) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.18e+38], N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-10], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.18 \cdot 10^{+38}:\\
\;\;\;\;1 + \frac{z}{y}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.18e38Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 88.3%
Taylor expanded in y around inf 59.3%
if -1.18e38 < y < 1.05e-10Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.7%
associate-/l*98.6%
neg-mul-198.6%
sub-neg98.6%
+-commutative98.6%
distribute-neg-out98.6%
remove-double-neg98.6%
sub-neg98.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 67.7%
if 1.05e-10 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 51.1%
Final simplification61.7%
(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 99.9%
Final simplification99.9%
(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 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.2%
associate-/l*99.1%
neg-mul-199.1%
sub-neg99.1%
+-commutative99.1%
distribute-neg-out99.1%
remove-double-neg99.1%
sub-neg99.1%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 31.1%
Final simplification31.1%
(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 2023333
(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)))