
(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 9 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 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ y (- y z))))
(if (<= y -6.2e+25)
t_0
(if (<= y -4.3e-103)
t_1
(if (<= y -3.7e-128) t_0 (if (<= y 1.1e+62) (/ x z) t_1))))))
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 <= -6.2e+25) {
tmp = t_0;
} else if (y <= -4.3e-103) {
tmp = t_1;
} else if (y <= -3.7e-128) {
tmp = t_0;
} else if (y <= 1.1e+62) {
tmp = x / z;
} else {
tmp = t_1;
}
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 <= (-6.2d+25)) then
tmp = t_0
else if (y <= (-4.3d-103)) then
tmp = t_1
else if (y <= (-3.7d-128)) then
tmp = t_0
else if (y <= 1.1d+62) then
tmp = x / z
else
tmp = t_1
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 <= -6.2e+25) {
tmp = t_0;
} else if (y <= -4.3e-103) {
tmp = t_1;
} else if (y <= -3.7e-128) {
tmp = t_0;
} else if (y <= 1.1e+62) {
tmp = x / z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = y / (y - z) tmp = 0 if y <= -6.2e+25: tmp = t_0 elif y <= -4.3e-103: tmp = t_1 elif y <= -3.7e-128: tmp = t_0 elif y <= 1.1e+62: tmp = x / z else: tmp = t_1 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 <= -6.2e+25) tmp = t_0; elseif (y <= -4.3e-103) tmp = t_1; elseif (y <= -3.7e-128) tmp = t_0; elseif (y <= 1.1e+62) tmp = Float64(x / z); else tmp = t_1; 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 <= -6.2e+25) tmp = t_0; elseif (y <= -4.3e-103) tmp = t_1; elseif (y <= -3.7e-128) tmp = t_0; elseif (y <= 1.1e+62) tmp = x / z; else tmp = t_1; 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, -6.2e+25], t$95$0, If[LessEqual[y, -4.3e-103], t$95$1, If[LessEqual[y, -3.7e-128], t$95$0, If[LessEqual[y, 1.1e+62], N[(x / z), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.3 \cdot 10^{-103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-128}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+62}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -6.1999999999999996e25 or -4.30000000000000023e-103 < y < -3.7e-128Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
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 0 84.0%
div-sub84.0%
*-inverses84.0%
Simplified84.0%
if -6.1999999999999996e25 < y < -4.30000000000000023e-103 or 1.10000000000000007e62 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
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.2%
if -3.7e-128 < y < 1.10000000000000007e62Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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 71.3%
Final simplification76.2%
(FPCore (x y z) :precision binary64 (if (<= y -5.7e-33) (- 1.0 (/ x y)) (if (<= y 2.35e+67) (- (/ x z) (/ y z)) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.7e-33) {
tmp = 1.0 - (x / y);
} else if (y <= 2.35e+67) {
tmp = (x / z) - (y / z);
} else {
tmp = y / (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 <= (-5.7d-33)) then
tmp = 1.0d0 - (x / y)
else if (y <= 2.35d+67) then
tmp = (x / z) - (y / z)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.7e-33) {
tmp = 1.0 - (x / y);
} else if (y <= 2.35e+67) {
tmp = (x / z) - (y / z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.7e-33: tmp = 1.0 - (x / y) elif y <= 2.35e+67: tmp = (x / z) - (y / z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.7e-33) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 2.35e+67) tmp = Float64(Float64(x / z) - Float64(y / z)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.7e-33) tmp = 1.0 - (x / y); elseif (y <= 2.35e+67) tmp = (x / z) - (y / z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.7e-33], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.35e+67], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.7 \cdot 10^{-33}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -5.70000000000000025e-33Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.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 z around 0 79.2%
div-sub79.2%
*-inverses79.2%
Simplified79.2%
if -5.70000000000000025e-33 < y < 2.35000000000000009e67Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.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 z around inf 80.6%
associate-*r/80.6%
neg-mul-180.6%
neg-sub080.6%
associate--r-80.6%
neg-sub080.6%
Simplified80.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
div-sub80.6%
Simplified80.6%
div-sub80.6%
Applied egg-rr80.6%
if 2.35000000000000009e67 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/100.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
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 91.0%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e-40) 1.0 (if (<= y 2.36e+64) (/ x z) (if (<= y 1.35e+139) (/ (- y) z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e-40) {
tmp = 1.0;
} else if (y <= 2.36e+64) {
tmp = x / z;
} else if (y <= 1.35e+139) {
tmp = -y / 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 <= (-7.5d-40)) then
tmp = 1.0d0
else if (y <= 2.36d+64) then
tmp = x / z
else if (y <= 1.35d+139) then
tmp = -y / 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 <= -7.5e-40) {
tmp = 1.0;
} else if (y <= 2.36e+64) {
tmp = x / z;
} else if (y <= 1.35e+139) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e-40: tmp = 1.0 elif y <= 2.36e+64: tmp = x / z elif y <= 1.35e+139: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e-40) tmp = 1.0; elseif (y <= 2.36e+64) tmp = Float64(x / z); elseif (y <= 1.35e+139) tmp = Float64(Float64(-y) / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.5e-40) tmp = 1.0; elseif (y <= 2.36e+64) tmp = x / z; elseif (y <= 1.35e+139) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e-40], 1.0, If[LessEqual[y, 2.36e+64], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.35e+139], N[((-y) / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-40}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.36 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+139}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7.50000000000000069e-40 or 1.3499999999999999e139 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.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 inf 67.9%
if -7.50000000000000069e-40 < y < 2.36000000000000011e64Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.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 66.7%
if 2.36000000000000011e64 < y < 1.3499999999999999e139Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
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 73.1%
Taylor expanded in y around 0 59.1%
mul-1-neg59.1%
distribute-neg-frac59.1%
Simplified59.1%
Final simplification66.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e-128) (not (<= y 2.7e+49))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-128) || !(y <= 2.7e+49)) {
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 <= (-3.4d-128)) .or. (.not. (y <= 2.7d+49))) 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 <= -3.4e-128) || !(y <= 2.7e+49)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e-128) or not (y <= 2.7e+49): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e-128) || !(y <= 2.7e+49)) 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 <= -3.4e-128) || ~((y <= 2.7e+49))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e-128], N[Not[LessEqual[y, 2.7e+49]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-128} \lor \neg \left(y \leq 2.7 \cdot 10^{+49}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.39999999999999975e-128 or 2.7000000000000001e49 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
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 73.1%
div-sub73.2%
*-inverses73.2%
Simplified73.2%
if -3.39999999999999975e-128 < y < 2.7000000000000001e49Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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 71.8%
Final simplification72.5%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e-33) (- 1.0 (/ x y)) (if (<= y 3.8e+67) (/ (- x y) z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e-33) {
tmp = 1.0 - (x / y);
} else if (y <= 3.8e+67) {
tmp = (x - y) / z;
} else {
tmp = y / (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 <= (-4.2d-33)) then
tmp = 1.0d0 - (x / y)
else if (y <= 3.8d+67) then
tmp = (x - y) / z
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e-33) {
tmp = 1.0 - (x / y);
} else if (y <= 3.8e+67) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e-33: tmp = 1.0 - (x / y) elif y <= 3.8e+67: tmp = (x - y) / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e-33) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 3.8e+67) tmp = Float64(Float64(x - y) / z); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e-33) tmp = 1.0 - (x / y); elseif (y <= 3.8e+67) tmp = (x - y) / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e-33], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e+67], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-33}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+67}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -4.2e-33Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.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 z around 0 79.2%
div-sub79.2%
*-inverses79.2%
Simplified79.2%
if -4.2e-33 < y < 3.8000000000000002e67Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.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 z around inf 80.6%
associate-*r/80.6%
neg-mul-180.6%
neg-sub080.6%
associate--r-80.6%
neg-sub080.6%
Simplified80.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
div-sub80.6%
Simplified80.6%
if 3.8000000000000002e67 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/100.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
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 91.0%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.5e-40) 1.0 (if (<= y 2.35e+67) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e-40) {
tmp = 1.0;
} else if (y <= 2.35e+67) {
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.5d-40)) then
tmp = 1.0d0
else if (y <= 2.35d+67) 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.5e-40) {
tmp = 1.0;
} else if (y <= 2.35e+67) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.5e-40: tmp = 1.0 elif y <= 2.35e+67: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.5e-40) tmp = 1.0; elseif (y <= 2.35e+67) 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.5e-40) tmp = 1.0; elseif (y <= 2.35e+67) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.5e-40], 1.0, If[LessEqual[y, 2.35e+67], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-40}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.5000000000000001e-40 or 2.35000000000000009e67 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.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 inf 63.4%
if -1.5000000000000001e-40 < y < 2.35000000000000009e67Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.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 65.9%
Final simplification64.8%
(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 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%
*-lft-identity100.0%
metadata-eval100.0%
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*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 inf 34.4%
Final simplification34.4%
(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 2023308
(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)))